Adding and Removing Solution Items

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 .NET: 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.

Files are one type of item

In Visual Studio .NET, 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.

Not all items are contained within a project, however; an item can be project-independent. There are two types of project-independent items in Visual Studio .NET: solution items and miscellaneous files. How project-independent items are managed depends on whether or not they are associated with a solution.

Miscellaneous files are external items; they are non-deployable, project-independent files that are never included in solution builds. Although they are solution-independent, you can configure Visual Studio to track the most recently used and closed miscellaneous files. For more information about external files, see Miscellaneous Files.

Project independent items

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 create a new one or add an existing one.

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 Solution Item, 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

Solution Items | Solutions as Containers | Using Solution Explorer | Excluding Items from a Deployment Project | Miscellaneous Files | Adding New Project Items