Last active
January 23, 2018 19:05
-
-
Save bradwilson/6e169abcef7899f01db314dd95d8812c to your computer and use it in GitHub Desktop.
VS 2017 PowerShell script; if you need invoke-cmdscript, it's here: https://gist.github.com/bradwilson/3fca203370d54304eff1cce21ffc32aa
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
param( | |
[string]$edition, | |
[switch]$noWeb = $false | |
) | |
# Try and find a version of Visual Studio in the expected location, since the VS150COMNTOOLS environment variable isn't there any more | |
$basePath = join-path (join-path ${env:ProgramFiles(x86)} "Microsoft Visual Studio") "2017" | |
if ((test-path $basePath) -eq $false) { | |
write-warning "Visual Studio 2017 is not installed." | |
exit 1 | |
} | |
if ($edition -eq "") { | |
$editions = (get-childitem $basePath | where-object { $_.PSIsContainer }) | |
if ($editions.Count -eq 0) { | |
write-warning "Visual Studio 2017 is not installed." | |
exit 1 | |
} | |
if ($editions.Count -gt 1) { | |
write-warning "Multiple editions of Visual Studio 2017 are installed. Please specify one of the editions ($($editions -join ', ')) with the -edition switch." | |
exit 1 | |
} | |
$edition = $editions[0] | |
} | |
$path = join-path (join-path (join-path $basePath $edition) "Common7") "Tools" | |
if ((test-path $path) -eq $false) { | |
write-warning "Visual Studion 2017 $edition could not be found." | |
exit 1 | |
} | |
$cmdPath = join-path $path "VsDevCmd.bat" | |
if ((test-path $cmdPath) -eq $false) { | |
write-warning "File not found: $cmdPath" | |
exit 1 | |
} | |
invoke-cmdscript $cmdPath | |
if ($noWeb -eq $false) { | |
$path = join-path (join-path (join-path $basePath $edition) "Web") "External" | |
if (test-path $path) { | |
$env:Path = $env:Path + ";" + $path | |
} else { | |
write-warning "Path $path not found; specify -noWeb to skip searching for web tools" | |
} | |
} |
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
param( | |
[string]$edition, | |
[switch]$noWeb = $false | |
) | |
$basePath = join-path (join-path ${env:ProgramFiles(x86)} "Microsoft Visual Studio") "Preview" | |
if ((test-path $basePath) -eq $false) { | |
write-warning "Visual Studio Preview is not installed." | |
exit 1 | |
} | |
if ($edition -eq "") { | |
$editions = (get-childitem $basePath | where-object { $_.PSIsContainer }) | |
if ($editions.Count -eq 0) { | |
write-warning "Visual Studio Preview is not installed." | |
exit 1 | |
} | |
if ($editions.Count -gt 1) { | |
write-warning "Multiple editions of Visual Studio 2017 are installed. Please specify one of the editions ($($editions -join ', ')) with the -edition switch." | |
exit 1 | |
} | |
$edition = $editions[0] | |
} | |
$path = join-path (join-path (join-path $basePath $edition) "Common7") "Tools" | |
if ((test-path $path) -eq $false) { | |
write-warning "Visual Studion Preview $edition could not be found." | |
exit 1 | |
} | |
$cmdPath = join-path $path "VsDevCmd.bat" | |
if ((test-path $cmdPath) -eq $false) { | |
write-warning "File not found: $cmdPath" | |
exit 1 | |
} | |
invoke-cmdscript $cmdPath | |
if ($noWeb -eq $false) { | |
$path = join-path (join-path (join-path $basePath $edition) "Web") "External" | |
if (test-path $path) { | |
$env:Path = $env:Path + ";" + $path | |
} else { | |
write-warning "Path $path not found; specify -noWeb to skip searching for web tools" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment