In an attempt to live inside the Windows Powershell shell as much as possible, i figured i would need a way to use powershell to do .NET Framework command line things such as "InstallUtil" and "MSBuild". After very little digging, it was clear i needed to create a Windows PowerShell profile and update the environment variables used by visual studio from there.

Finding out about environment variables in Windows PowerShell was simple:

help about_environment_variable

This will help you discover that to access an environment variable you can use $env:<varname>.

So a quick search for those pesky .bat files that configure the VS environment. (Tip: Look in the Program Files\Microsoft Visual Studio 8\Common7\Tools folder for .bat files)

Now we can create our profile. In your documents folder (whereever that may be, in vista its \users\username\documents) create a new folder named WindowsPowerShell.

To create a profile, create a new file named Microsoft.PowerShell_profile.ps1. In this file you should copy the contents of the var setting batch file, and update for PowerShell syntax. Mine looked like this (i'm VS on Vista)

$env:VSINSTALLDIR="C:\Program Files\Microsoft Visual Studio 8"
$env:VCINSTALLDIR="C:\Program Files\Microsoft Visual Studio 8\VC"
$env:FrameworkDir="C:\Windows\Microsoft.NET\Framework"
$env:FrameworkVersion="v2.0.50727"
$env:FrameworkSDKDir="C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0"

$env:DevEnvDir="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE"

$env:PATH="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;C:\Program Files\Microsoft Visual Studio 8\VC\BIN;C:\Program Files\Microsoft Visual Studio 8\Common7\Tools;C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\bin;C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\bin;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin;C:\Windows\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\VCPackages;" + $env:path

$env:INCLUDE="C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\INCLUDE;C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE;C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\include;" + $env:include

$env:LIB="C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB;C:\Program Files\Microsoft Visual Studio 8\VC\LIB;C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib;C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\lib;" + $env:lib

$env:LIBPATH="C:\Windows\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\LIB"

To test, open a Windows PowerShell shell and type InstallUtil. If its all working you should see the syntax for the InstallUtil command.

THIS POSTING IS PROVIDED "AS IS" WITH NO WARRANTIES, AND CONFERS NO RIGHTS