Browse Source

Add a powershell script that sets the VS env vars

Panagiotis Christopoulos Charitos 1 year ago
parent
commit
3f188180cc
1 changed files with 25 additions and 0 deletions
  1. 25 0
      Tools/SetupVSEnvironment.ps1

+ 25 - 0
Tools/SetupVSEnvironment.ps1

@@ -0,0 +1,25 @@
+# Set the environment variables of the Visual Studio native prompt
+
+$path1="C:\opt\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
+$path2="C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
+
+if(Test-Path $path1) {
+  $path=$path1
+}
+elseif(Test-Path $path2) {
+  $path=$path2
+}
+else {
+  echo "vcvars64.bat not found"
+  exit
+}
+
+echo "Will call `"$path`""
+
+cmd.exe /c "call `"$path`" && set > %temp%\vcvars.txt"
+
+Get-Content "$env:temp\vcvars.txt" | Foreach-Object {
+  if($_ -match "^(.*?)=(.*)$") {
+    Set-Content "env:\$($matches[1])" $matches[2]
+  }
+}