Web Development with VisualSVN

Web development with Visual Studio often requires sophisticated configuration management. However, VisualSVN supports the most of possible configurations and is widely used by web developers.

The major web development options under Visual Studio are:

  • using Web Application projects;
  • using file system based Web Site projects;
  • using local IIS based Web Site projects;
  • using remote IIS based Web Site projects;

VisualSVN completely supports web development with Web Application projects and partially supports web development with Web Site projects. Please read the rest of the chapter carefully if you are using Web Site projects.

You can also consider migrating your Web Site projects to Web Application projects. For further details please follow the guidelines.

Web Development with Web Site Projects

VisualSVN requires all projects to be stored in a single file system subtree. This restriction can make initial configuration a little difficult if you are using Web Site projects.

File System Based Web Site Projects

The content of file system based Web Site projects are located on your hard drive. Unfortunately, Visual Studio arranges Web Site projects separately from other solution items, by default. But you can easily reconfigure you solution layout to allow VisualSVN to control your Web Site projects.

When you create a new Web Site project Visual Studio arranges your solution files as shown below.

Default layout of a file system based Web Site project

As you can see, the Web Site project and other solution files are located in separate file system subtrees. To make VisualSVN able to control your solution you need to create your Web Site project differently. Here are the simple steps to follow so VisualSVN can control your Web Site Project Solution:

Create a Blank Solution project as shown in the picture below.

Creating Blank Solution

Then choose the File | Add | New Web Site main menu command and specify the location for the Web site as the same root folder as your solution file.

Adding new Web Site to a solution

Now your Web Site project and solution file are located in the same file system subtree as shown below.

Required layout of a file system based Web Site project

Now you can choose the VisualSVN | Add Solution to Subversion main menu command to put your solution under Subversion control and commit the first version of your source files to a repository using the VisualSVN | Commit main menu command. You should then see green traffic lights status icons in Solution Explorer as shown in the picture below.

Green traffic lights status icons

You can easily change the layout of your pre-existing Web Site project by following these steps:

  1. remove the Web Site project from your solution (this just removes a reference to the Web Site project from the solution file. The content of the Web Site project will be preserved on your hard drive);
  2. move your Web Site project folder to the same file system subtree as your solution file using Windows Explorer;
  3. add the Web Site project back to your solution from its new location using the File | Add | Existing Web Site main menu command.

Local IIS Based Web Site Projects

The content of local IIS based Web Site projects are located in a virtual directory on your local IIS web server. This virtual directory is configured automatically by Visual Studio when you create new Web Site project.

Despite the fact that your project is stored on your local web server Visual Studio accesses the content of the project using a plain UNC path. By default the virtual directory points to a physical folder located within C:\Inetpub\wwwroot. The default layout of a local IIS based Web Site project is shown in the picture below.

The default layout of local IIS based Web Site projects

In order to allow VisualSVN to control your local IIS based Web Site project you should change the virtual directory mapping. Follow these steps to do this:

Create a Blank Solution project as done in the previous section. Then choose the File | Add | New Web Site main menu command to create new Web Site project and specify location for it on the local IIS web server as shown in the picture below.

Adding new Web Site to a solution

Then close the solution in Visual Studio and go to Windows Explorer. In order to change the mapping of the automatically created virtual directory you need to copy content of the web site to a more appropriate location. But you need to take care to retain the NTFS permission settings.

Choose the Properties context menu command for the old physical folder within C:\Inetpub\wwwroot.

Opening properties for old Web Site location

Click the Security tab and press the Advanced button. Then uncheck the "Inherit from parent..." checkbox and press the Copy button in the dialog to copy the permissions entries that were previously inherited from the parent of this folder. Then press OK to apply your changes.

Disabling NTFS permissions inheritance

To copy the content of the Web Site project to your solution tree please execute the following command (without line breaks):

xcopy
C:\Inetpub\wwwroot\MyWebSite
"<path-to-your-solution>\MyWebSite\"
/E /K /O /X

This command will copy the entire content of your Web Site project to the new location with all NTFS permissions preserved.

Then open the IIS console and delete the old virtual directory.

Deleting of old virtual directory

Then create new virtual directory and map it to a new physical location of your Web Site project.

Mapping virtual directory to a new Web Site location

Then choose the Properties context menu command and make sure that the newly created virtual directory has appropriate ASP.NET settings.

Checking ASP.NET Settings for new virtual directory

Then choose the Directory Security tab and press the topmost Edit button to modify the anonymous access and authentication settings. Please check the Integrated Windows authentication checkbox to allow debugging from within Visual Studio. Please note: This action is optional and can harm production web server security.

Enabling Windows Authentication for new virtual directory

Then go back to Visual Studio and open your solution again. Your Web Site project will be opened from its new location. Now you can choose the VisualSVN | Add Solution to Subversion main menu command to put your solution under Subversion control and commit the first version of your source files to a repository using the VisualSVN | Commit main menu command. Finally, you should see green traffic lights status icons in Solution Explorer as shown in the picture below.

Green traffic lights status icons

Please note that you can easily change the layout of your pre-existing local IIS based Web Site project. Just skip the steps related to a new solution and Web Site project creation in the instructions above.

Remote IIS Based Web Site Projects

The content of a remote IIS based Web Site project is located in a virtual directory at a remote IIS web server. Remote IIS based Web Site projects are almost unsupported by VisualSVN.

The only possible way to control remote IIS based Web Site projects with VisualSVN is to map a remote virtual directory to a physical folder on a local machine. But this solution is not very practical and requires sophisticated NTFS permissions management.