Nick Parker
My ramblings on .NET...

MSBuild Context Menu Revisited

Saturday, 10 September 2005 10:37 by nickp

I mentioned in a previous post how to add a context menu for invoking MSBuild against any .*proj file. The only problem I had was I wasn't able to pass the file name to MSBuild, which would have typically been qualified with "%1" following the MSBuild command. When MSBuild is invoked and a file isn't passed to it, it searches the directory to find one. The problem is, if there are more than one .*proj files in the same directory, it doesn't know which file to run. To solve this, I moved the setting of the environment variables to the AutoRun key of the command prompt, this way, the environment variables are always set. Then I only had to invoke MSBuild from my command entry in which I was able to pass the selected file. Here are the two registry entries needed.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor]
"AutoRun"="\"%VS80COMNTOOLS%vsvars32.bat\""
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Run with MSBuild\command]
@="cmd /k msbuild \"%1\""

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   .NET | Productivity
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Related posts

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

August 28. 2008 16:57