For my project I need to use the Visual Studio Development Tools as additional command line features, for instance to create dlls with the tlbimp utility.
According to the Microsoft documentation, I need to properly configure my environment variables for the Visual Studio Command Line, by calling the vsvars32.bat.
The
vsvars32.batfile sets the appropriate environment variables to enable command-line builds. (More info: https://msdn.microsoft.com/en-us//library/1700bbwd.aspx)
What looks annoying in my case, it's that these features are temporary available in my PowerShell prompt. Every time I need to re-run that batch file. Is there a clever way to make them persistent?
You can configure or modify (if it already exists) your Powershell profile in order to automatically invoke the vsvars32.bat batch file:
function Invoke-Batchfile ($file) {
$cmd = "`"$file`" & set"
cmd /c $cmd | Foreach-Object {
$p, $v = $_.split('=')
Set-Item -path env:$p -value $v
}
}
Invoke-Batchfile "$env:VSCOMNTOOLS\vsvars32.bat"
Take into account that you first need to define as well an environment variable pointing to your Visual Studio installation path, according to the used version:
$env:VSCOMNTOOLS = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools"
$env:VSCOMNTOOLS = "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools"
Now, everytime you open your Poweshell prompt, the Visual Studio development tools' features will be available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With