Skip to content

Instantly share code, notes, and snippets.

@Karm
Created September 20, 2021 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Karm/56b5d7286482e45fc3bbb54aa00fbfaf to your computer and use it in GitHub Desktop.
Save Karm/56b5d7286482e45fc3bbb54aa00fbfaf to your computer and use it in GitHub Desktop.
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