How to right click on a folder in Windows Explorer and select “Open as Visual Studio Website”

I found this here - it is pretty useful

http://weblogs.asp.net/bradleyb/archive/2005/12/09/432802.aspx

This is how to add a command to the shell to open a folder as a web site in Visual Studio 2005 or 2008.

Visual Studio 2005/2008 does not support this by default but you can enable the scenario by writing a macro.

To do this, create a new macro either in an existing module or in a new module. For this example I’m going to add a module call Website to the MyMacros project.

If you’re new to macros in Visual Studio 2005, select menu Tools/Macros/Macros IDE, then select the MyMacros project and add a module.

Before you can use the new Website extensibility objects within VS you’ll need to add a reference to VsWebSite.Interop.dll.

Once added you can add the following code:

Public Module Website
    Sub OpenWebsite(Optional ByVal path As String = "")
        If (String.Compare(path, String.Empty) = 0) Then
            MsgBox("Must supply a folder path to the OpenWebsite macro", MsgBoxStyle.OkOnly)
        Else
            Dim webPkg As VsWebSite.VSWebPackage
            webPkg = DTE.GetObject("WebPackage")
            webPkg.OpenWebSite(path, VsWebSite.OpenWebsiteOptions.OpenWebsiteOption_None, False)
        End If
    End Sub
End Module

After this code is added you’ll be able to run the macro. You can test it out in the command window.

From the Command Window in VS:

>Macros.MyMacros.Website.OpenWebsite C:\MyProjects\MyCompany\CompanySite

From the Command Line:

devenv /command "Macros.MyMacros.Website.OpenWebsite C:\MyProjects\MyCompany\CompanySite"

After its working you can register a shell command enabling an “Open as Visual Studio Website” command on any folder in windows explorer.

To do this copy the following into a OpenWebsite.reg file and run it.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\OpenVSWeb]
@="Open as Visual Studio Website"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\OpenVSWeb\command]
@="devenv.exe /command \\\"Macros.MyMacros.Website.OpenWebsite %1\\\""

Now you should be able to right click on a folder in Windows Explorer and select “Open as Visual Studio Website”.