Partager via


Add a project to a solution under source control

You can add a project to a solution that is under source control the same way you would add a project to a solution that is not under source control. There are a few differences that are specific to source control that are listed in the following procedures.

For information about how to add a project to source control using Microsoft Visual Studio Team System Team Explorer, see How to: Add a Project or Solution to Version Control on MSDN.

Add projects to a solution under source control

To add a new project to a solution under source control

  1. Add a new project.

    For more information, see Add a new or existing project to a solution.

    Important

    Make sure that you create the new project in the solution folder in your local Microsoft Team Foundation workspace. Otherwise, Team Foundation will not be able to find the new project files.

    The project is added to your solution, and the solution file is modified to list the new project files. Each newly created file is identified by a plus sign JJ170530.df7cb6be-7111-47b1-8f1b-e1f12fd14ac3(fr-fr,VS.110).png, and a check mark JJ170530.62863683-36e0-4c3e-818f-ffe18a7fec91(fr-fr,VS.110).png appears next to the solution file to show that it is checked out to you.

    The Projects panel after you add a project named Flavors

    JJ170530.500fcfcf-d006-4708-9cfd-bc9aca3ec6dd(fr-fr,VS.110).png

  2. As a best practice, build (Ctrl+Shift+B) or run (F5) your solution before checking it in to make sure that nothing is broken.

  3. Check in the new files and the changed solution file.

    For more information, see Check files in and out.

To add an existing project to a solution under source control

  1. Copy the existing project folder to the solution folder in your local Microsoft Team Foundation workspace.

  2. Add the existing project.

    For more information, see Add a new or existing project to a solution.

    The existing project is added to your solution, and the solution file is modified to list the project files. Each added file is identified by a plus signs JJ170530.df7cb6be-7111-47b1-8f1b-e1f12fd14ac3(fr-fr,VS.110).png, and a check mark JJ170530.62863683-36e0-4c3e-818f-ffe18a7fec91(fr-fr,VS.110).png appears next to the solution file to show that it is checked out to you.

    [!REMARQUE]

    If you see locks JJ170530.de1ca98f-81f1-4666-930e-e509e31ea168(fr-fr,VS.110).png next to the project files instead of plus signs JJ170530.df7cb6be-7111-47b1-8f1b-e1f12fd14ac3(fr-fr,VS.110).png, you might be adding a project that previously existed in the solution but was removed (though not deleted from your hard disk).

  3. As a best practice, build (Ctrl+Shift+B) or run (F5) your solution before checking it in to make sure that nothing is broken.

  4. Check in the added files and the changed solution file.

    For more information, see Check files in and out.

Delete projects from a solution under source control

To delete a new project that has not yet been checked in

  1. Right-click the new project, and then click Undo Pending Changes.

    ConseilConseil

    By right-clicking the new project instead of the solution, you make sure that only the new project files are selected in the Undo Pending Changes dialog box. Any other pending changes will not be selected, so those changes will not be undone.

  2. Select the solution file, because it was modified to add a reference to the new project and you want to undo that change.

    Mise en gardeAttention

    If there is a chance that the solution file has some other changes that have not yet been checked in, compare your current local version to the version that was last checked in. For more information, see View or compare the changes made to files. If the only difference in your solution file is the line that references the new project that you want to delete, you can safely select the solution file to undo the changes. If there are other changes that you need to keep, do not select the solution file. Instead, after completing this procedure, open the solution file in a text editor and manually remove the reference to the project. You can then check in the solution file along with the other file changes that are related to the changes made in the solution file.

  3. Click Undo Pending Changes.

    The new project is deleted from the solution and from source control, without deleting the new project folder from your hard disk. It is a good idea to build (Ctrl+Shift+B) or run (F5) your solution to make sure nothing is broken before making further changes to the solution.

To delete an existing project from a solution under source control

  1. Open the solution in Microsoft Visual Studio 2010 Team System. You must use Visual Studio 2010 because you cannot open a solution in Team Explorer, and you cannot delete a project from source control using Blend.

    Important

    You might be tempted to right-click the project folder in the Source Control Explorer panel of Visual Studio 2010 and click Delete, but this will not remove the reference to the project in the solution file. To remove a project and any references to the project, you must do so in the Solution Explorer panel with the solution open.

  2. If you do not see the Solution Explorer panel, click View, and then click Solution Explorer.

  3. Right-click the project that you want to delete, and then click Remove.

    The project is removed from the solution and deleted from the Team Foundation server, without deleting the new project folder from your hard disk. The solution file is checked out to you and modified to remove any reference to the project. If you want, you can manually delete the project folder from your hard disk.

  4. Build (Ctrl+Shift+B) or run (F5) your solution to make sure nothing is broken.

  5. Right-click the solution, and then click Check In.

  6. In the Check In dialog box, make sure all the files that you want to check in (including the solution file) are selected, and then click Check In.

Voir aussi

Tâches

Check files in and out

Rename or delete a file under source control

Concepts

Add a solution to source control