Web development with Visual Studio and Plastic SCM
Web applications development is one of the most usual activities carried out by most software companies using Visual Studio. The IDE version 2005 introduced numerous improvements allowing working with this kind of applications. These improvements make working with Web applications more similar to conventional Windows applications. When it's about web development it is also essential to introduce parallel development and in order to do this the first step is to have a version control system to manage changes. This article will explain different solutions, as well as the right way of configuring Visual Studio to use it together with a version control system on web projects.
Deployment configurations of web development and version control systems
Although developing web applications with Visual Studio is quite similar to conventional applications development, there are some special features that impose certain constraints that should be taken into account. Visual Studio supports the following three working modes for version control on web projects:
This mode is the one that better adjusts to working with a version control and the one recommended by Microsoft. Each developer has his own web server (IIS) installed locally to enable executing and debugging applications. Code modifications are done on a local copy which works against the centralized version control. This is the usual working mode when using a version control.
Microsoft does not recommend to use this method if you pretend to work with a version control system. There is only one centralized server which will execute and debug the web application. This server will also host every source control copy. Workspaces will be placed on a remote machine and will be shared through net units or UNC paths. This working mode is no longer supported by Visual Studio 2005 and newer versions even though it was available on the 2003 version.
Microsoft does not recommend to use this mode but it is still used by many companies. There is only one web server configured to execute and debug web applications. Developers usually work from the server´s FrontPage extensions. Programmers cannot work isolated with this type of development. Practically no version control supports this working mode.
Working with Plastic SCM and Visual Studio
In order to work with Visual Studio and Plastic SCM the isolated development working mode is mandatory. This way parallel development is possible, which are great news for users. The only disadvantage on isolated development is that the debugging and testing environment used by the developer is quite different from a real production system. Developers´ computers are usually less powerful than the server where the real system will be actually executed, and they also have a different software configuration. Nevertheless, the benefit of being able to make parallel changes and not being constrained to debug only a user at a time (as the other modes do, since there is only one web server) far out weights the possible disadvantages. Anyway, it is possible to sort out this limitation introducing a testing or preproduction server on which the application can be installed and tested.
Creating a web Project associated to Plastic SCM with Visual Studio
The steps to create a new Project and associate it to Plastic SCM are described below. It is important to apply the following instructions on the indicated order:
- Create a workspace in c:\Inetpub\wwwroot (the folder where the IIS server is located).
- Create a blank solution in this folder or in any subfolder.
- Add Web projects to the solution.
- File / New / Web Application / ASP.NET
- Select as path http://localhost/Project
- Add the solution to Plastic SCM.
The recommended directory structure to achieve the best performance under a version control is shown below:
Opening the Project for the first time with Visual Studio
We'll focus on 2005 version and newer versions. Also, we'll assume that Plastic SCM and the Visual Studio Package are installed on the computer.
- Open Visual Studio 2005.
- Select File / Open from Plastic SCM
- Select a workspace or create a new one.
- Select the solution's folder you want to open and click on OK.
Isolated development model without IIS installed
It is not necessary to have IIS installed from the 2005 version of Visual Studio on. When debugging and executing, Visual Studio will use a small local web server. In order to work with Plastic SCM and the source code folders located on the local folder system, you have to:
- Open Visual Studio 2005.
- Create a blank solution on the user's workspace.
- Add to the solution the new web project.
- Add the solution to the source control.
IMPORTANT: If a blank solution is not created on the first place and it is directly created on the web site, Visual Studio will automatically create a solution and place it in "My Documents\Visual Studio 200x\Projects\Project Name\", within the user's local folder. This means that the solution folder will not be included on the source control.
Moving a web project to another computer
Before adding the code to Plastic SCM's control, sometimes it's necessary to move the web Project source code from one computer to another. Once the project is under Plastic SCM control it's not necessary to do this operation again, because you can use the "Open from Plastic SCM" operation as explained above.
To move the source code from one machine to another:
- First copy the source code from the original location to the new one.
- Create a new IIS virtual directory on the destination computer pointing to the folder where the Project is located (this is ok if the original project is working against 'localhost'; for remote projects the solution file should be manually modified).
- Adjust the new web application permissions.
- Open the Project with Visual Studio and adjust the starting options if necessary.
To work properly with an IIS installed on the local machine, the user should:
- Be a member of the machine' administrators team, in order to access IIS metadata or configure the access rules from the IIS.
- Be a member of the debugging users´ group in order to debug Web applications.
- The web application should have activated the "use Windows integrated authentication" box on the directory security tab.
c:\ is not on a workspace
This problem arises when a web Project is created without having previously created a blank solution. When an empty web Project is created, Visual Studio places the solution's folder on the local user's path, as explained before. When you try to add this folder, every parent folder going down from c:\ is attempted to be added to Plastic SCM, and if they are not on a workspace, an error will be notified. To solve this issue:
- Create a blank solution located on the shared folder inside the user's workspace.
- Add the new web Project to the blank solution.
- Web Projects and Source Control Integration in Visual Studio .NET http://msdn.microsoft.com/en-us/library/aa290068%28v=vs.71%29.aspx
- How to move your Visual Studio .NET Web project to another computer: http://support.microsoft.com/kb/326495/en-us
- Plastic SCM Visual Studio Package guide: /releases/3.0.1/manuals-html/en/idesguide.htm