Perforce Public Knowledge Base - Add VS 2010 Project to Perforce using P4VS
Perforce Software logo
Reset Search
 

 

Article

Add VS 2010 Project to Perforce using P4VS

« Go Back

Information

 
Problem

How do I add an existing Visual Studio 2010 project to Perforce using the P4VS plugin integration?

Solution

Here are steps to add an existing Visual Studio 2010 project to Perforce using the P4VS plugin integration, while also creating a Perforce client workspace for the project.

NOTE: If you have existing Visual Studio projects that were using the P4SCC plugin, you must first migrate (remove the bindings, etc) the projects before trying to use them in P4VS.

The Perforce recommended way to remove source control bindings is to allow Visual Studio to take care of this for you.

  • Uninstall the P4SCC plug-in.
  • Next, load your solution into .NET and, when prompted, choose the option to "Permanently Remove Source Control Associated Bindings."
When .NET finishes, the source control binding should be gone and so should the Visual Studio source-control-specific files ending with *scc, including MSSCCPRJ.SCC file(s).

 

There is a document, Migrating Project and Solution Files from P4SCC to P4VS, that describes this process in great detail.

NOTE: Confirm that P4VS is the current source control plug-in in Visual Studio 2010.

  • In Visual Studio 2010, go to the menu Tools -> Options
  • Under Options go to Source Control -> Plug-in Selection
  • Make sure you see selected in the drop-down box: P4VS - Perforce Plugin for Visual Studio

 

EXAMPLE

NOTE: This example uses a Other Languages -> Visual Basic -> Windows Forms Application project named vs10winform, located at C:\myspaces\vs10winform, with a solution named vs10winform.sln.

  1. Open the existing Visual Studio Project.
    • Double-click the solution (.sln) file from within the project directory in Windows Explorer. For example:
      C:\myspaces\vs10winform\vs10winform.sln
      
      
    • OR In Visual Studio, go to:
        File -> Open -> Project/Solution
      
      In the Open Project dialog, select the project and click the Open button.
 
  • Open a connection to Perforce.
    File -> Open Connection to a Perforce Depot
    
  • The P4 Open Connection dialog appears. For Server, fill in the Perforce server name and port. For User, fill in the Perforce user name. For Workspace, click the New button.
  • In the New Workspace dialog enter the name. For example, vs10winform. Click the OK button.
  • In the New Workspace dialog, set up the Root and View fields.
    Root:   C:\myspaces\vs10winform
    
    View:
            //scc/... //vs10winform/...
    
    
    Click the SAVE button.
  • Back at the P4 Open Connection dialog, you see the new workspace filled in under the Workspace field. Click the OK button.
  • Now back in Visual Studio, mark the project for add.
    • Select the project in Solution Explorer, right-click and select Mark for Add from the context menu.
  • OR Select the project in Solution Explorer. Go to menu:
     File -> Perforce -> Mark for Add
    
  • A P4VS dialog opens with text:
      Adding new solution's files to the Perforce depot
    
    
    and gives the option to select the default or new pending changelist. (Selecting New from the drop-down enables the Changelist description edit box.)

    Click the OK button.
  • Now back in Visual Studio, look in Solution Explorer and notice the red plus-marks next to the Solution and project folders, indicating these are checked out for add in Perforce.

    In Visual Studio, go to menu View -> Pending Changelists, if you want to make the dialog visible.

    Notice also on the command line, that Perforce reports the VS project as being checked out:
    //scc/vs10winform.sln#1 - add default change (text) by testguy@vs10winform
    //scc/vs10winform/Form1.Designer.vb#1 - add default change (text) by testguy@vs10winform
    //scc/vs10winform/Form1.vb#1 - add default change (text) by testguy@vs10winform
    //scc/vs10winform/My Project/Application.Designer.vb#1 - add default change (text) by testguy@vs10winform
    //scc/vs10winform/My Project/Application.myapp#1 - add default change (text) by testguy@vs10winform
    //scc/vs10winform/My Project/AssemblyInfo.vb#1 - add default change (text) by testguy@vs10winform
    //scc/vs10winform/My Project/Resources.Designer.vb#1 - add default change (text) by testguy@vs10winform
    //scc/vs10winform/My Project/Resources.resx#1 - add default change (text) by testguy@vs10winform
    //scc/vs10winform/My Project/Settings.Designer.vb#1 - add default change (text) by testguy@vs10winform
    //scc/vs10winform/My Project/Settings.settings#1 - add default change (text) by testguy@vs10winform
    //scc/vs10winform/vs10winform.vbproj#1 - add default change (text) by testguy@vs10winform
    
  • Check in and submit your project from within Visual Studio.
    You can do this from the File menu:
     1. Click menu File -> Perforce -> Submit
     2. A Submit Files dialog appears. Write a changelist description and click the Submit button.
    
    
    or submit using the context menu:
     1. In Solution Explorer, select the project, right-click and select Submit.
     2. A Submit Files dialog appears. Write a changelist description and click the Submit button. 
 

Now the Visual Studio project files are added to Perforce using the P4VS plugin integration.

You can check to see that the Visual Studio project files were added to Perforce. The example below uses the 'p4 files' command from the command line.
 

EXAMPLE

$ p4 files //scc/vs10winform/...
//scc/vs10winform/Form1.Designer.vb#1 - add change 1122 (text)
//scc/vs10winform/Form1.vb#1 - add change 1122 (text)
//scc/vs10winform/My Project/Application.Designer.vb#1 - add change 1122 (text)
//scc/vs10winform/My Project/Application.myapp#1 - add change 1122 (text)
//scc/vs10winform/My Project/AssemblyInfo.vb#1 - add change 1122 (text)
//scc/vs10winform/My Project/Resources.Designer.vb#1 - add change 1122 (text)
//scc/vs10winform/My Project/Resources.resx#1 - add change 1122 (text)
//scc/vs10winform/My Project/Settings.Designer.vb#1 - add change 1122 (text)
//scc/vs10winform/My Project/Settings.settings#1 - add change 1122 (text)
//scc/vs10winform/vs10winform.vbproj#1 - add change 1122 (text)

 

NOTE: The example above was created using the following versions and components: (Help -> About Microsoft Visual Studio)

  • Notice now in Solution Explorer that the project will have either a lock icon or a green dot icon next to it. Mouse over the icon and you will see the confirming text:
      #1/1  Checked In
    
    • Microsoft Visual Studio 2010
      Version 10.0.30319.1 RTMRel
      Microsoft .NET Framework
      Version 4.0.30319 RTMRel
      Installed Version: Professional
 
  • Microsoft Office Developer Tools 01018-532-2002102-70964
    Microsoft Visual Basic 2010 01018-532-2002102-70964
    Microsoft Visual C# 2010 01018-532-2002102-70964
    Microsoft Visual C++ 2010 01018-532-2002102-70964
    Microsoft Visual F# 2010 01018-532-2002102-70964
    Microsoft Visual Studio 2010 Team Explorer 01018-532-2002102-70964
    Microsoft Visual Web Developer 2010 01018-532-2002102-70964
    Crystal Reports Templates for Microsoft Visual Studio 2010
    Microsoft Visual Studio 2010 SharePoint Developer Tools 10.0.30319
 
  • P4VS - Perforce Plugin for Visual Studio 2012.1.46.3760

 

There is also a P4VS User's Guide as an available reference.

Related Links

Feedback

 

Was this article helpful?


   

Feedback

Please tell us how we can make this article more useful.

Characters Remaining: 255