Share via


How to: Create Solutions and Projects

When 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 a message that offers 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 message from being displayed when script is run by clearing the anti-virus software setting for blocking script. However, changing this setting disables all script blocking, not just for Visual Studio.

Note

The descriptions in this topic are based on the Visual Studio Professional edition. The dialog boxes and menu commands you see might differ from those described here, depending on your settings or Visual Studio edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Working with Settings.

Projects and Templates

Visual Studio uses project templates to generate new projects based on user input. Each template represents a different project type. Individual files that users add to projects are generated from item templates.

You can locate installed project templates in the New Project dialog box by navigating the expanding list in the left pane under Installed Templates. You can also navigate under Recent Templates for project types you have created recently, or Online Templates for templates available on the Visual Studio Gallery Web site.

You can also use the search box in the upper right corner of the dialog to search for project templates. The search will populate the middle pane with results from the recent, installed, or online list, depending on which category is selected.

Creating Projects

When a project is created, a solution is automatically generated unless the project is already part of a solution.

To create a project and a solution to contain it

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

    This opens the New Project dialog box.

  2. In the left pane, select Installed Templates, and select a category of project types from the expanded list.

    If you have recently created a project of the same type, select Recent Projects instead for faster navigation.

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

    A description of the selected template appears in the right pane.

  4. in the Name box, type 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, a Web application or an XML Web service is located on a Web server and derives its name from the virtual directory specified on that server.

  5. In the Location box, select a save location.

    Note

    The Location box may be unavailable if you are creating a temporary project. For more information, see Temporary Projects.

  6. In the Solution drop down, select whether to create a new solution or add the project to an existing solution.

  7. In the Solution Name box, type a name for the solution.

    Visual Studio will use this name for the namespace of the finished project if applicable. The solution name will match the product name by default.

  8. Make sure the Create directory for solution Checkbox is checked.

  9. Click OK.

    Note

    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.

You can create a project to target earlier versions of the .NET Framework by using the .NET Framework version drop-down menu at the top of the New Project Dialog Box. Set this value before selecting a project template, as only templates compatible with that .NET Framework version will appear in the list. If you choose .NET Framework 4 when creating a project, some of the templates displayed use the Client Profile by default. For more information, see .NET Framework Client Profile.

You must have .NET Framework 3.5 installed on your system to access framework versions earlier than 4.0.

Creating Solutions

Although a project must reside in a solution, you can create a solution that has no projects.

To create a empty solution

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

  2. In the left pane, select Installed Templates, and select Other Project Types, then Visual Studio Solutions from the expanded list.

  3. In the middle pane, select Blank Solution.

  4. Set the Name and Location values for your solution, then click OK.

After you create an empty solution, you can add new or existing projects or items to it by clicking Add New Item or Add Existing Item on the Project menu.

Deleting Solutions

You can delete a 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 use Windows Explorer to delete the directory that contains the .sln and .suo solution files.

Note

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

To delete a solution

  1. In Solution Explorer, right-click the solution to delete, and select Open folder in Windows Explorer.

  2. In Windows Explorer, navigate up one level.

  3. Select the directory containing the solution and press Delete.

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