Click here to Skip to main content
Click here to Skip to main content
Go to top

Build Visual Studio .Net 2003 and 2005 solutions or projects by right clicking in Explorer

, 26 Jul 2006
Rate this:
Please Sign up or sign in to vote.
Implementing a Windows Shell Extension to provide "Build Here" functionality

Build Here

Introduction

This article explains how to easily extend Windows shell functionality. By integrating your application with the Shell, you can extend the Shell's functionality and customize certain aspects of its behavior. In order of increasing complexity, you can extend the Shell by:

  • Putting information in the registry or in special files.
  • Implementing a Shell extension handler.
  • Implementing a namespace extension.

File associations use verbs as shorthand for actions that are invoked on items in the Shell namespace, including files and folders. Verbs are closely related to the Shell shortcut menus, where each menu item is associated with a verb.

Supplemental verbs are any verbs other than the standard canonical verbs, and are most often used to add custom behavior beyond what the default system verbs provide. On Windows XP or later, you can add supplemental verbs to the SystemFileAssociations extension, or to the Shell subkey for the PerceivedType key.

Using the code

For example, suppose CoolLogEditor is a text LOG editor and the developers of CoolTextEditor want to add a supplemental verb that displays "CoolLogEditor" when you right-click any file of the ".log" extension type To accomplish this, a key named CoolLogEditor is added to the registry as follows:

[HKEY_CLASSES_ROOT\SystemFileAssociations\.log\shell\CoolLogEditor\command]
@="CoolLogEditor.exe \"%1\"\"

For more information refer to the following MSDN articles

Here is how VS.Net BuildHere works

Following are registry keys which will add a menu item on the File Explorer. When you right click a Microsoft Visual Studio 2003 or 2005 Project or Solution a batch file find outs correct version of the Project or Solution and sets environment and runs compile command for it.

Registry Values for menu item "VS.Net BuildHere-Debug":
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\SystemFileAssociations\.sln\shell\
VS.Net BuildHere-Debug\command]
@="cmd.exe /k \"\"[INSTALLDIR]\VS.Net BuildHere-Debug.bat\" \"%1\"\""

[HKEY_CLASSES_ROOT\SystemFileAssociations\.sln\shell\
VS.Net BuildHere-Release\command]
@="cmd.exe /k \"\"[INSTALLDIR]\VS.Net BuildHere-Release.bat\" \"%1\"\""

[HKEY_CLASSES_ROOT\SystemFileAssociations\.csproj\shell\
VS.Net BuildHere-Debug\command]
@="cmd.exe /k \"\"[INSTALLDIR]\VS.Net BuildHere-Debug.bat\" \"%1\"\""

[HKEY_CLASSES_ROOT\SystemFileAssociations\.csproj\shell\
VS.Net BuildHere-Release\command]
@="cmd.exe /k \"\"[INSTALLDIR]\VS.Net BuildHere-Release.bat\" \"%1\"\""

[HKEY_CLASSES_ROOT\SystemFileAssociations\.vcproj\shell\
VS.Net BuildHere-Debug\command]
@="cmd.exe /k \"\"[INSTALLDIR]\VS.Net BuildHere-Debug.bat\" \"%1\"\""

[HKEY_CLASSES_ROOT\SystemFileAssociations\.vcproj\shell\
VS.Net BuildHere-Release\command]
@="cmd.exe /k \"\"[INSTALLDIR]\VS.Net BuildHere-Release.bat\" \"%1\"\""

[HKEY_CLASSES_ROOT\SystemFileAssociations\.vbproj\shell\
VS.Net BuildHere-Debug\command]
@="cmd.exe /k \"\"[INSTALLDIR]\VS.Net BuildHere-Debug.bat\" \"%1\"\""

[HKEY_CLASSES_ROOT\SystemFileAssociations\.vbproj\shell\
VS.Net BuildHere-Release\command]
@="cmd.exe /k \"\"[INSTALLDIR]\VS.Net BuildHere-Release.bat\" \"%1\"\""

[HKEY_CLASSES_ROOT\SystemFileAssociations\.vjsproj\shell\
VS.Net BuildHere-Debug\command]
@="cmd.exe /k \"\"[INSTALLDIR]\VS.Net BuildHere-Debug.bat\" \"%1\"\""

[HKEY_CLASSES_ROOT\SystemFileAssociations\.vjsproj\shell\
VS.Net BuildHere-Release\command]
@="cmd.exe /k \"\"[INSTALLDIR]\VS.Net BuildHere-Release.bat\" \"%1\"\""

[HKEY_CLASSES_ROOT\SystemFileAssociations\.vdproj\shell\
VS.Net BuildHere-Debug\command]
@="cmd.exe /k \"\"[INSTALLDIR]\VS.Net BuildHere-Debug.bat\" \"%1\"\""

[HKEY_CLASSES_ROOT\SystemFileAssociations\.vdproj\shell\
VS.Net BuildHere-Release\command]
@="cmd.exe /k \"\"[INSTALLDIR]\VS.Net BuildHere-Release.bat\" \"%1\"\""

Batch File (VS.Net BuildHere-Debug.bat):
@rem Author: Priyakant Patel
@rem http://www.priyakant.com

@prompt $S

@rem if ProductVersion starts with 8 then it is Microsoft Visual Studio 
@rem .Net 2005

@findstr "<.*ProductVersion.*>.*8.*</.*PRODUCTVERSION.*>" %1
@IF %ERRORLEVEL% LSS 1 goto LABEL_VS8

@rem if File Format Version starts with 9 then it is Microsoft Visual 
@Studio .Net 2005

@findstr ".*Format.*Version.*9" %1
@IF %ERRORLEVEL% LSS 1 goto LABEL_VS8

@findstr "#.*Visual.*Studio.*2005" %1
@IF %ERRORLEVEL% LSS 1 goto LABEL_VS8

:LABEL_VS7
@cls
@echo *** *** Project is a Microsoft Visual Studio .Net 2003 *** ***
Call "%VS71COMNTOOLS%vsvars32.bat"
@echo **** building following solution in ~~Debug~~ mode ****
@echo %1
@devenv %1 /rebuild Debug

@goto LABEL_END

:LABEL_VS8
@cls
@echo *** *** Project is a Microsoft Visual Studio .Net 2005 *** ***
Call "%VS80COMNTOOLS%vsvars32.bat"
@echo **** building following solution in ~~Debug~~ mode ****
@echo %1
@devenv %1 /rebuild Debug

@goto LABEL_END

@echo Before end
:LABEL_END
@echo Hit enter to exit
@pause
@exit

Conclusion

I hope you will enjoy this handy tool.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Priyakant Patel
Technical Lead XXX
United States United States
No Biography provided

Comments and Discussions

 
GeneralMy vote of 5 PinmemberSharjith28-Feb-12 6:44 
GeneralMy vote of 2 Pinmembervegaam24-Sep-09 21:13 
GeneralNot seeing anything when i right click Pinmembersrisan14-May-08 4:37 
QuestionHow to insert a menu when right click blank place? Pinmemberhays.zhao6-Jun-07 21:36 
GeneralExtend Functionality PinmemberMarco_Frigerio_13-Mar-07 6:52 
Generalerror question please Pinmembererikkl200020-Oct-06 8:23 
GeneralRe: error question please Pinmembererikkl200020-Oct-06 9:44 
GeneralRe: error question please PinmemberPriyakant Patel3-Nov-06 8:46 
Questionwhy go to all that trouble, finding which version of the Pinmemberganirc26-Jul-06 17:46 
AnswerRe: why go to all that trouble, finding which version of the PinmemberPriyakant Patel27-Jul-06 5:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140926.1 | Last Updated 26 Jul 2006
Article Copyright 2006 by Priyakant Patel
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid