BlackWaspTM

This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

Visual Studio
VS 2003+

Visual Studio Solution Items

Visual Studio allows files to be linked to a solution without being added to an individual project. This can be useful for storing documentation, notes and shared items, and including them within source control repositories.

Solution Items

Sometimes you will have files that you wish to include within a solution but that don't belong to any single project. These are usually non-code items, such as documentation or notes. However, they can be source code files or resources that you wish to share between multiple assemblies without having the "master copy" held within a particular project.

This type of file can be added to your solution as a solution item. Solution items can be any type of file. They are linked to the solution, rather than a project. The files can be stored anywhere but it is commonplace to place them within the solution's folder structure, making it easier to add them to repositories of revision control systems.

Adding a Solution Item

To add a new file as a solution item, start by right-clicking the solution's name in the Solution Explorer pane. Choose "Add" from the context-sensitive menu that appears. You now have two options. To add a file that does not yet exist, choose "New Item" and select the type of file that you wish to create using the dialog box that appears. Solution items created in this manner are added within the solution's folder in the file system.

You can also click the "Existing Item" option. This displays a dialog box that allows you to browse for a file to add. Once you have selected and added the new item, a reference to the file is added to the solution. However, unlike when adding an existing file to a project, the file is not copied into the solution's folder.

Once added, solution items appear in the Solution Explorer pane, as shown below:

Visual Studio Solution Item

NB: If you wish to use a solution item in one or more projects, you can add it to those projects as a linked file.

Removing a Solution Item

If you have a solution item that you no longer require, you can remove it easily. Locate it in the Solution Explorer, right-click it and choose the "Remove" option. You can also select it and press the Delete key.

NB: Removing a solution item simply removes the reference. The file itself is not deleted from the file system.

23 January 2016