Skip to content

Instantly share code, notes, and snippets.

@viniciusjarina
Last active March 11, 2020 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viniciusjarina/08967de9dba3432bbc436e1b9ba5339d to your computer and use it in GitHub Desktop.
Save viniciusjarina/08967de9dba3432bbc436e1b9ba5339d to your computer and use it in GitHub Desktop.
Using Visual Studio 2017 From Windows Terminal

Using Visual Studio 2017 From Windows Terminal

VS 2017 doens't provide a PowerShell module like VS 2019. To make it work we need to do an small hack using VsDevCmd.bat to export VSDevCmd env vars to PowerShell

Save the VS2017.ps1 and add a new profile to the profiles.json

"commandline": "powershell.exe -NoExit -Command \". { . C:\\Users\\vinja\\Documents\\WindowsPowerShell\\VS2017.ps1 }\""
{
"acrylicOpacity": 0.80000001192092896,
"background": "#0C0C0C",
"closeOnExit": true,
"colorScheme": "Campbell",
"commandline": "powershell.exe -NoExit -Command \". { . C:\\Users\\vinja\\Documents\\WindowsPowerShell\\VS2017.ps1 }\"",
"cursorColor": "#FFFFFF",
"cursorShape": "bar",
"fontFace": "Consolas",
"fontSize": 16,
"guid": "{369059B1-5A06-4478-954B-0AEE6C6657DF}",
"historySize": 9001,
"icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
"name": "Windows PowerShell (VS 2017)",
"padding": "0, 0, 0, 0",
"snapOnInput": true,
"startingDirectory": "%USERPROFILE%",
"useAcrylic": true
},
pushd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools"
cmd /c "VsDevCmd.bat&set" |
foreach {
if ($_ -match "=") {
$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
}
}
popd
@viniciusjarina
Copy link
Author

Noticed: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools" is the path to your VS if you are using Enterprise or Community the path will probably be different

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment