Tuesday, October 19, 2010

Quick Tip: Using Visual Studio Command Prompt Programs from Windows PowerShell


You use the Visual Studio Command Prompt to invoke programs like cs.exe and xsd.exe and you want to invoke those programs from within PowerShell.


You can use the right-click to paste short cut that is not available in a regular DOS shell.


This procedure explcitly invokes the DOS interpreter causing you to leave the PowerShell immidiate mode environment.


It is possible to create a powershell script that causes the same environment changes programatically, but it's more complicated.  See here.


Right click on the shortcut (usually found in the start menu) that you would use to launch the Visual Studio Command Prompt.

In the properties window that appears, in the Shortcut tab, locate the value of Target.  It should be something like:

%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" amd64
You may replace amd64 above with one of:

   x86 | ia64 | amd64 | x86_amd64 | x86_ia64

Launch PowerShell.

Use copy and paste (in powershell right-click is a short cut to paste text from the clipboard)  to construct a command similar to:

cmd /k 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat' amd64


No comments:

Post a Comment