Udostępnij za pośrednictwem


How to: Create Solutions and Projects

At the time you create a project, Visual Studio creates a solution to contain it. If you plan to create a multi-project solution, see How to: Create Multi-Project Solutions. If you want to create a project from existing code files, see How to: Create a Project from Existing Code Files.

Note

If your anti-virus software displays an alert offering to block script that the project template or wizard is running, choose not to block script; otherwise, Visual Studio shuts down. You can prevent this alert from showing when script is run by clearing the anti-virus software's setting for blocking script; however, changing this setting disables all script blocking, not just for Visual Studio.

Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

Creating Projects

When creating a new project, a solution is automatically generated unless that project is already part of a solution.

To create a new project and a solution to contain it

  1. On the File menu, select New and then click Project.

  2. In the New Project dialog box, select one of the Project types from the left pane.

  3. Select one of the project Templates from the right pane.

  4. Enter a Name for the new project.

    Note

    For some project types, the Name box is unavailable because specifying the location sets the project name. For example, Web applications and XML Web services are located on a Web server and derive their name from the virtual directory specified on that server.

  5. Select a save Location.

    Note

    The Location box may be unavailable because you have enabled temporary projects in your Visual Studio settings. This allows you to create temporary projects that you can save to disk later or discard. If you are creating a temporary project, click OK now. For more information, see Temporary Projects.

  6. Select Create directory for solution.

    Note

    This option is not available for directory-based projects. For more information, see Item Management in Projects.

  7. Type a Name for the solution that differs from the project name.

  8. Select Add to Source Control if you want to add the solution to a source control database.

  9. Click OK.

    Tip

    You can also use this dialog box to add a new project to an open solution by selecting Add to Solution in the Solution list. This option appears only when a solution is open in Solution Explorer.

Click ? in the New Project dialog box for more information about specific project templates.

Creating Solutions

While a project must reside in a solution, you can create a blank solution with no projects.

To create a blank solution

  1. On the File menu, select New and then click Project.

  2. In the Project types pane, select Other Project Types and then select Visual Studio Solutions.

  3. In the Templates pane, select Blank Solution.

  4. Enter a name for the project.

  5. To change the location of the solution directory, choose Browse and specify a new location.

  6. Select Add to Source Control if you want to add the solution to a source control database or repository.

  7. Click OK.

After creating an empty solution, you can add new or existing projects and items to the empty solution by using the Add New Item or Add Existing Item command from the Project menu.

Deleting Solutions

You can delete an entire solution permanently, but not by using Visual Studio. Before you delete a solution, move any projects that you might want to use again in another solution. Then, instead, use Windows Explorer to delete the directory that contains the two solution files: .sln and .suo.

Note

The .suo file is a hidden file that is not displayed with the default Windows Explorer settings.

See Also

Tasks

How to: Add and Remove Solution Items

How to: Create Multi-Project Solutions

Concepts

Using Solution Explorer

Other Resources

Managing Solutions, Projects, and Files

Source Control for Visual Studio

Change History

Date

History

Reason

July 2008

Re-ordered procedures and updated procedure text.

Information enhancement.