Created
September 20, 2021 09:18
-
-
Save Karm/56b5d7286482e45fc3bbb54aa00fbfaf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Declare-EnvVar([string]$name, [string]$value) { | |
Write-Host "Setting envvar ${name}=${value}" | |
[Environment]::SetEnvironmentVariable($name, $value, "Machine"); | |
[Environment]::SetEnvironmentVariable($name, $value, "Process"); | |
RefreshEnv | |
} | |
function MakeShortcutLn([string]$target, [string]$link) { | |
$WScriptShell = New-Object -ComObject WScript.Shell | |
$shortcut = $WScriptShell.CreateShortcut($link) | |
$shortcut.TargetPath = $target | |
$shortcut.Save() | |
} | |
function InstallVisualStudio() { | |
choco install visualstudio2019community | |
choco install visualstudio2019-workload-nativedesktop | |
choco install visualstudio2019-workload-universal | |
$ideHome = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\" | |
Declare-EnvVar "Path" "$env:Path;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build;$ideHome" | |
MakeShortcutLn "$ideHome\devenv.exe" "$ideHome\devenv.lnk" | |
} | |
function InstallChoco() { | |
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 | |
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) | |
choco feature enable -n allowGlobalConfirmation | |
# Also enable Nuget | |
Install-PackageProvider -Name NuGet -Force | |
} | |
# Enable long paths | |
$regkey = "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" | |
set-itemproperty -path $regkey -name LongPathsEnabled -value 1 | |
InstallChoco | |
InstallVisualStudio |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment