Compartir a través de


Add files and folders to a project under source control

You can add files, link to files, and add folders to a project that is under source control the same way you would in projects that are not under source control. There are a few differences that are specific to source control that are listed in the following procedures.

SugerenciaSugerencia

Other team members will not see added files, linked files, or added folders until you check in your changes. Because each of the following procedures adds a line to the project file (.csproj, .vbproj), you might need to merge your changes if another team member modifies the project file while you have it checked out.

For more information, see Merge and resolve conflicts when checking files in.

To create a new file in a project under source control

  1. In the Projects panel, right-click the project to which you want to add a new file, and then click Add New Item.

  2. In the New Item dialog box, select one of the following:

    • Window   A top-level window or dialog box.

    • UserControl   A custom control that can be reused across other applications.

    • Page   A document that can contain part of your project and that can be reached by navigation, either within a browser-hosted application, or within a navigation window.

    • Resource Dictionary   A set of resources that can be shared among various parts of your project.

    • Class   An empty class declaration.

  3. Next to Name, type a descriptive name for the file, and then click OK.

  4. Check in the project file.

    For more information, see Check files in and out.

To add an existing file to a project under source control

  1. Right-click the file and click Add to source control.

    For more information, see Add or link to an existing item.

    SugerenciaSugerencia

    If the file you want to add is an image or video, you can drag it onto the artboard.

    The file is copied to the project folder in your local Microsoft Team Foundation workspace. In the Projects panel, the plus sign JJ169925.df7cb6be-7111-47b1-8f1b-e1f12fd14ac3(es-es,VS.110).png displayed next to the new file shows that the file has been added, but not yet checked in. The project file is updated to reference the new file. A check mark JJ169925.62863683-36e0-4c3e-818f-ffe18a7fec91(es-es,VS.110).png appears next to the project file to show that it is checked out to you.

  2. Check in the modified project file and the added file.

    For more information, see Check files in and out.

The following procedure provides steps for linking to a file that is in the same solution. You should not link to a file that is in a different solution.

SugerenciaSugerencia

As a best practice, you should not link to files in a project under source control unless the file to which you are linking is part of the same solution and is located somewhere in the solution folder in your Team Foundation workspace. If you link to a file that is outside the solution, you can't check in the file as part of the solution, and so other team members might not have access to the file, or might not have the correct version of the file.

  1. In the Projects panel, right-click a project, and then click Link to Existing Item.

  2. In the Link to Existing Item dialog box, browse to a file that is in the same solution in your local workspace, click it, and then click Open.

    SugerenciaSugerencia

    Make sure the item does not have the same name as a file that is already in the project.

    The file appears in the Projects panel within the current project folder, with an arrow superimposed over the file icon JJ169925.1cca22e6-da56-405c-a971-c52712d43334(es-es,VS.110).png. If the item you selected was a .xaml file, any corresponding code-behind file (.cs, .vb) is also added as a linked file.

    A reference to the file (or files) is added to your project file (.csproj, .vbproj), and the project file is automatically checked out to you.

  3. Check in the project file.

    For more information, see Check files in and out.

To add a folder to a project under source control

The following procedure provides steps for adding a folder to a project under source control. To add a project to source control, use the procedure in the topic Add a project to a solution under source control.

  1. In the Projects panel, right-click the project to which you want to add a folder, and then click Add New Folder.

    A folder appears with the name selected and editable.

  2. Type a name for the folder, and then press ENTER.

    A reference to the folder is added to your project file (.csproj, .vbproj), and the project file is automatically checked out to you.

  3. Check in the project file.

    For more information, see Check files in and out.

Vea también

Tareas

Get the latest copies of project files

Rename or delete a file under source control

Conceptos

Add a solution to source control