Perforce with Visual Studio .NET
Integrate Perforce with Visual Studio .NET and Web projects
SUMMARY
This article describes the intricacies of using Perforce when integrating with Visual Studio .Net, and, more specifically, Web projects.
DETAIL
Please note that:
- Only the Enterprise and Professional editions of .NET 2002 and .NET 2003 support version control; the Standard edition of those products does not.
- The Express version of .NET 2005 does not support version control; the other editions of .NET 2005 do.
- Due to server security enhancements, the 2004.2 and greater versions of P4SCC.DLL require a 2002.1 or later Perforce server.
Which version of the Perforce SCC plug-in should I use?
You should use the most recent build. See the Release Notes for details.
What Visual Studio .NET features are untested or unsupported?
The following are either untested or unsupported by the current SCC plug-in:
- Setup and Deployment projects
- Web Projects
More about Web projects
Though unsupported, Perforce has been successfully configured with Web projects. Unlike other projects, which typically reside in your workspace, Web projects reside in the Web server root (for example, C:Inetpubwwwroot). For details about using source control in conjunction with Web projects, see Web Projects and Source Control Integration in Visual Studio .NET. Perforce is known to work with the “isolated development” method described in this document, using the “File share” access method. This approach requires you to set up and open Web projects in a specific manner, as described in detail on the Web page cited above.
Recommendation: create the solution first, then add the Web project to it. Do not create the project first. If you do, Visual Studio creates a solution with default settings that are probably incompatible with Perforce requirements.
Requirements:
You need the following software installed on your client computer:
- IIS Web server
- .NET framework
Note: If you installed IIS after installing Visual Studio, you might encounter errors attempting to create Web projects. Consult MSDN for general troubleshooting and details about repairing the .NET framework.
Configuring the workspace
Define a workspace with a null root and a view that maps both the path to your solutions and the path to your Web projects (under the Web server root). For example:
Root: null
View:
//depot/solutions/... //myworkspace/c:/p4clients/solutions/...
//depot/webprojects/... //myworkspace/c:/Inetpub/wwwroot/...
Important:
a) the drive letter in any path must be lower case (c: and not C:)
b) this approach has been verified and worked for .NET 2003
Now you can create Web projects and add them to source control as described in the Perforce guide Using IDE Plugins.
Opening Web projects from the depot
When you want to open Web projects that reside in the depot but not on your computer (projects created by other programmers), you must define workspaces as described above. The first time you open a project from the depot, perform the following steps:
- Choose File> Source Control>Open from Source Control...
- In the depot, browse to the Web project you want to open, select the project or solution file and click OK. The Open Project dialog is displayed.
- Again, select the project or solution file and click OK. The Set Project Location dialog is displayed.
- In the Enter Working Copy Location field, specify the location as an URL in the following format: http://localhost/projectname.
- Click OK.
You only need to open the project from source control the first time you open it. Thereafter, choose Open Project.
Known Issues
-
Do not put the .suo (user preferences) file under source control.
-
We have heard reports of problems if a temporary file with the extension .vsscc is checked in.
-
Do not add Visual Studio files to Perforce using P4Win. If you've done this, you must bind the files to Perforce from within Visual Studio, as follows:
- Load the project.
- Choose Files>Source Control>Change Source Control.
- Highlight the solution and project files.
- Choose Bind.
- Click OK.
After you have done this, you should be able to checkout the files.
- In Perforce, add is a two-step process, while Visual Studio expects "auto-add".
To add a file to an existing solution in Visual Studio .NET:
- To open a file for add, choose Add New|Existing Item.
- To submit a file, select the file and choose Check In Now.
To see which files are open for add, choose Show Pending Checkins.
-
The Solution Explorer in Visual Studio .NET uses a reference-based mechanism to specify the contents and structure of a project or solution, regardless of the actual structure of the files in the file system. Nonetheless, Microsoft suggests that all files in source control reside under the directory where the .sln file resides.
-
To map a project from another machine/location, after your initial sync, choose Files->Source Control->Open from Source Control. This command updates the files with the new user and workspace attributes during an implicit bind. The first time you do this, you must enter the full path to the solution file.
Visual Studio workspace project files
The name of the Visual Studio file(s) depends on which Visual Studio product created the file(s). Below is the list of the most common types:
| File Extension | Description |
|---|---|
| .actproj | ACT project |
| .atp | ACT project |
| .csproj | C# project |
| .dbp | Database project |
| .dmp | Crash Dump project |
| .dsp | Project Converter |
| .dsw | Visual Studio Workspace |
| .etp | Enterprise Template project |
| .exe | EXE project |
| .hwproj | Microsoft Help project |
| .mdmp | Crash Dump project |
| .mdp | Project Converter (VC 4.x) |
| .sln | Solution |
| .vbproj | Visual Basic project |
| .vcproj | Visual C project |
| .vdp | Setup and Deployment project |
| .vdproj | Setup and Deployment project |
| .vsmacros | Binary based macro project |
| .vsmproj | Unicode based macro project |
| .opt | Source Code Control related |
| .vssscc | Source Code Control related |
| .vcproj.vspscc | Source Code Control related |
| .csproj.vspscc | Source Code Control related |
| MSSCCPRJ.SCC | Source Code Control related |
MSSCCPRJ.SCC is a "special" file; it contains user specific configuration settings and it should NEVER be added to Perforce. Note, that some temporary files might be added and reverted behind the scenes. See Using IDE Plug-Ins Guide for the guidelines as to what files should (not) be checked into Perforce.
Enabling trace logging
Enable trace logging only if requested to do so by Perforce Technical Support to debug a specific Perforce SCC plug-in problem. To enable trace logging (2003.2 version of p4scc.dll and higher):
- Launch .NET.
- Choose Options>Source Control>SCC Provider.
- Click the Advanced button and go to the General tab.
- Check the Enable logging to file and Log All options..
- Restart .NET.
The trace information is written to "C:\Documents and Settings\your_login_name\.p4scc\log.txt".
For more info
For further information on the Perforce SCC Plug-In, see:
Perforce-User archives