Partager via


Add a new or existing project to a solution

A solution can include multiple projects. In Blend for Visual Studio 2012, you can add a new or existing project to a solution. This is useful to keep functionality separated into reusable projects that you can update in a single instance of Blend and build at the same time.

To add a new project to a solution

  1. With a project open in Blend, use one of the following methods:

    • In the Projects panel, right-click the name of your solution, and then click Add New Project.

    • On the Project menu, click Add New Project.

    The Add New Project dialog box appears.

  2. Select an Application project to create another application or select a Control Library project to create a set of user controls.

    The new project folder is added to your solution folder, and you can browse the project files in the Projects panel.

  3. To be able to use controls from the new project in the original project, right-click the name of the original project in the Projects panel, click Add Project Reference, and then select the name of your new project.

  4. Build your solution by right-clicking the name of your solution in the Projects panel, and then clicking Build Project. This makes sure that any user controls that are contained in the new project are available from the Project category of the Assets panel in the original project.

  5. Every time that you update the new project, build your solution. This makes sure that updates to the new project are reflected on the artboard in the original project.

To add an existing project to a solution

  1. With a project open in Blend, use one of the following methods:

    • In the Projects panel, right-click the name of your solution, and then click Add Existing Project.

    • On the Project menu, click Add Existing Project.

    The Add Existing Project dialog box appears.

  2. Browse to the project file (.csproj or .vbproj) that you want to add, and then click Open.

    The project is added to your solution. The added project is not copied to your solution folder, but you can open the files in the added project by double-clicking them in the Projects panel.

  3. If the added project builds a DLL that you want to use in your original project, right-click the name of the original project in the Projects panel, click Add Reference, locate the DLL file, and then click Open.

  4. If the added project includes user controls that you want to use in your original project, right-click the name of the original project in the Projects panel, click Add Project Reference, and then select the name of your new project.

  5. Build your solution by right-clicking the name of your solution in the Projects panel and then clicking Build Project. This makes sure that any user controls that are contained in the added project are available from the Project category of the Assets panel in the original project.

  6. Every time that you update the added project, build your solution. This makes sure that updates to the added project are reflected on the artboard in the original project.

    [!REMARQUE]

    When you right-click the name of your solution in the Projects panel, you can also select Rebuild Project to rebuild everything, including components that are built from files that have not been changed. Alternatively, you can select Clean Project to delete all intermediate files that are generated by the build. If you select Run Project, the solution will be built, and then your application will run, showing the startup page of the original project.