How to: Add and Remove Solution Items

In Visual Studio, a solution is the highest level of organization, followed by a project. A solution can contain one or more projects. A project, in turn, contains items. Many types of items are possible and the items available for a particular project vary with the type of project. Items include, but are not limited to: files, classes, datasets, forms, and reports.

Files are one type of item

Virtual Physical Items graphic

Solutions contain projects and the items that those projects contain. Solutions can also contain items that do not belong to a particular project: project-independent items. Two types of project-independent items exist in Visual Studio: solution items and miscellaneous files.

Solution items are associated with a solution and managed by the Solution Items folder in Solution Explorer.

If you want to work on files outside the context of a solution or a project, create miscellaneous files that are managed by the Miscellaneous Files folder. For more information about miscellaneous files, see Miscellaneous Files.

Project independent items

Project Solutions

Solution items are internal items. They can be referenced by projects, but are never included in solution or project builds. This topic outlines the process of adding and removing items to the Solution Items folder.

Note

If placed under Source Control, solution items must reside on the same logical or physical drive as the solution files (.sln and .suo) to maintain one root in the Source Code Control database.

Adding Solution Items

If you want to permanently associate an item with your solution, you can either create a new item or add an existing item.

To add a new solution item

  1. In Solution Explorer, select the Solution node.

  2. On the Project menu, choose Add New Item.

  3. From Add New Item - Solution Items dialog box, choose a template.

  4. Choose Open to add the item to the Solution Items folder.

To add an existing item to a solution

  1. In Solution Explorer, select the solution.

  2. On the Project menu, choose Add Existing Item.

  3. From Add New Solution Item, choose the item you want to add.

  4. Choose Open to add the item to the Solution Items folder.

For more information, see Add Existing Solution Item dialog box.

Removing Solution Items

You can remove an item from the Solution Items folder. Removing is not the same as permanently deleting an item. Removing takes away the item's association with the solution. The file that represents the former item still remains on disk.

To remove a solution item

  1. In Solution Explorer, select the item you want to remove.

  2. On the Edit menu, choose Remove.

  3. You can re-add the item as long as the file for the item still exists.

    Tip

    To permanently delete a file from storage, use Windows Explorer.

See Also

Tasks

How to: Exclude Items from a Deployment Project

How to: Add New Project Items

Concepts

Solution Items

Solutions as Containers

Using Solution Explorer

Miscellaneous Files