SetupVSEnvironment.ps1 638 B

12345678910111213141516171819202122232425
  1. # Set the environment variables of the Visual Studio native prompt
  2. $path1="C:\opt\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
  3. $path2="C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
  4. if(Test-Path $path1) {
  5. $path=$path1
  6. }
  7. elseif(Test-Path $path2) {
  8. $path=$path2
  9. }
  10. else {
  11. echo "vcvars64.bat not found"
  12. exit
  13. }
  14. echo "Will call `"$path`""
  15. cmd.exe /c "call `"$path`" && set > %temp%\vcvars.txt"
  16. Get-Content "$env:temp\vcvars.txt" | Foreach-Object {
  17. if($_ -match "^(.*?)=(.*)$") {
  18. Set-Content "env:\$($matches[1])" $matches[2]
  19. }
  20. }