Thursday, March 06, 2008

Replace Visual Studio Command Prompt with Powershell

I've been using sqlmetal a lot lately.  The easiest way to use it is through the Visual Studio Command Prompt.  In my case, I'm using the Visual Studio 2008(9.0) command prompt.  The PowerShell lover in me hated the fact that I had to go to another shell to do this.  After a brief inquiry, the all great Google led me to this excellent post by Robert Anderson which explains how to edit your PowerShell profile to correctly set all the environment variables used by the Visual Studio 2005 command prompt.  I've made a few tweaks for Visual Studio 2008 and am re-posting it for your enjoyment.

Just add the code below to your profile.

#Set environment variables for Visual Studio Command Prompt
pushd 'C:\Program Files\Microsoft Visual Studio 9.0\vc'
cmd /c “vcvarsall.bat&set” |
foreach {
if ($_ -match “=”) {
$v = $_.split(“=”); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
write-host "`nVisual Studio 2008 Command Prompt variables set." -ForegroundColor Yellow


Anonymous said...

Keep posting stuff like this i really like it

Arun said...