Saturday, February 14, 2009

Adding Visual Studio Solution to the File -> New menu in Windows Explorer (in XP)

I was at a .Net User Group meeting the other night listening to a presentation by Keith Elder on how to structure your Visual Studio Solutions and Projects. The presentation was great, and although we are using a slightly different method I did pick up a few things that we could use that would be helpful.

One thing that caught me during the presentation was Keith created the folder structure for the application in windows explorer and then opened visual studio and created a solution file. I can’t remember if he created it in the wrong location or had to move it to a different folder after Visual Studio created it, but at this point at light bulb went off in my head and remembered something I learned in JP Boodhoo’s .Net Boot Camp which was the ability to create a new solution from the File -> New menu in Windows Explorer. So here is how you do it:

1. Create a folder in the %WINDIR% called ShellNew if it doesn’t already exists.
2. In the ShellNew Folder add a file name Visual Studio Solution.sln the file should contain the text below.

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

3. Open up regedit and go to HKEY_CLASSES_ROOT/.sln
4. Add a new key called ShellNew .
5. In ShellNew add a new string value with the name FileName and the value Visual Studio Solution.
6. Close explorer and reopen it. Click File -> New and you should now see Visual Studio Solution in the menu