07 luglio
Setting the .NET environment for a Powershell prompt
VS.NET installs a shortcut that, when invoked, sets the necessary environment variables you need to access the command line tools that comes with VS and the .NET and brings up a command prompt. The shortcut leads to a batch file located in the VS install directory, called vsvars32.bat.
A lot of developers want this environment set also when working in Powershell. Unfortunately, merely calling this batch file from inside Powershell won't work. The only way to run a batch file from Powershell is by invoking an instance of cmd.exe (or ${env:COMSPEC} and passing it the path of the batch file. This obviously runs in its own process, and when this process exits, its environment will not be propagated to the process that called it (Powershell).
There are several ways to get around this. You can, if you're not as lazy as I am, rewrite the vsvars32.bat file to a Powershell script and dotsource it on startup. Another way would be to first start up the VS command prompt by clicking on the shortcut, and then invoking Powershell manually from the prompt. I suspect a lot of people do the latter.
Personally, I've created my own shortcut that targets the following command line:
cmd.exe /k "D:\Program Files\Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat" && powershell.exe
The /k argument to cmd.exe tells it to leave the command prompt open after executing the command that follows. && is used to provide more than one command for cmd.exe to run.
When clicked, this shortcut leaves me with a Powershell prompt that has all the necessary command line utilities in my ${env:PATH}.