Export (0) Print
Expand All

Removing, Deleting, and Excluding Items

The procedure for taking items out of solutions, projects, and folders in Solution Explorer is straightforward. However, the project type determines whether you are deleting the file, keeping the file but removing it as an item in the project, or temporarily excluding it from the project or solution.

Removing, deleting, and excluding each describe a different degree of disassociation from the project or solution.

If you want to Then use
Disassociate an item from a solution, project, or folder but not remove its physical file Remove
Permanently erase files from physical storage as well as the file item in solution, project, or folder Delete
Temporarily disassociate an item from a project Exclude
Temporarily disassociate a project from a solution build Unload

Selecting the project or item determines which menus and commands are available. As with other commands, the actual outcome depends on the project template you used to create the project. You can look in help for more information about the specific project template you have selected. For more general information about how projects manage files, see Item Management in Projects.

Removing

For projects that manage items as links, you can remove an item from your project. The link is removed from Solution Explorer; the item's file is disassociated from the project, but not permanently removed from storage. Projects that manage the items as files instead of links do not support the Remove command.

To remove an item or project

  1. In Solution Explorer, select the item you want to remove.
  2. On the Edit menu, select Remove.

Deleting

For projects that manage items as files or either files or links, you can delete an item from your project. The link is removed from Solution Explorer; the item's file is permanently removed from storage. Projects that manage the items as links do not support the Delete command.

To permanently delete an item

  1. In Solution Explorer, select the item you want to delete.
  2. On the Edit menu, select Delete.

Excluding

Using the Exclude command, you can temporarily remove an item from the project build. After excluding the file, you can subsequently re-introduce it with Show All Files. For projects that manage items as file or either files or links, you can exclude an item from your project.

Including and excluding files is one way to customize the output of your applications for specific target audiences. For example, if you are developing both English and Chinese versions of an e-commerce application, you can exclude the English components of your user interface while building the Chinese version and vice versa.

Not all projects allow you to exclude project items from builds. References in Visual C++, other reference-based projects and links to files in Visual Basic and Visual C# projects can be excluded from the project build using slightly different methods.

Additionally, you can remove an entire project, and all of its contents from the solution build using the Unload command. For more information, see Unloading and Reloading Projects

Excluding Items that Represent Files

Physical project items in Visual Basic or Visual C# Web and other directory-based projects and physical project items in Visual Basic, Visual C# and other mixed-model projects can be temporarily removed from a project using the Exclude Project Item command.

To temporarily exclude an item that represents a file

  1. In Solution Explorer, select the item you want to exclude.
  2. On the Project menu, select Exclude From Project.

You can include the excluded file in your project by using the Include Project Item command.

To include an item that represents a file

  1. In Solution Explorer, select Show All Files .
  2. Select the item.
  3. On the Project menu, select Include in Project.

Excluding Items that Represent Links

In Visual Basic and Visual C#, the project items that represent links are indicated by a small arrow. Although, the Exclude from Project command is not available for these items, you can remove such items from project builds using the item's properties.

To temporarily exclude an item that represents a link

  1. Select the item you want to exclude in Solution Explorer.
  2. On the Project menu, select Properties.
  3. Set the BuildAction property to None.

To exclude an item from a Visual C++ .NET project

  1. In Solution Explorer, right-click the file you want to exclude.
  2. Choose Properties.
  3. Open the General page of Configuration Properties in the Property Pages dialog box.
  4. Set the Excluded From Build property to Yes.

To include the item in the project build, set the BuildAction property to another value. For a description of the alternative values, see File Properties.

Excluding Items from Visual C++ Project Builds

Even though the Exclude from Project command is not available for items represented as links, you can exclude such items from the project build by using the item's properties.

To exclude an item from a Visual C++ .NET project

  1. In Solution Explorer, right-click the file you want to exclude.
  2. Choose Properties.
  3. Open the General page of Configuration Properties in the Property Pages dialog box.
  4. Set the Excluded From Build property to Yes.

To include the item, set the Excluded From Build property to No.

Excluding Items from Deployment Projects

To exclude an item from a Deployment project

  1. In Solution Explorer, select the file you want to exclude.
  2. On the Solution Explorer toolbar, select Properties.
  3. In the Properties window, set the Exclude property to True.

See Excluding Items from a Deployment Project for alternative steps.

Note   Adding a file to a project directory in Windows Explorer does not automatically add that file to the project; the file will appear in Solution Explorer in the Show All Files view but it is not part of the project until you select Include in Project from the Project menu.

Unloading

To temporarily unload a project from a solution

  1. In Solution Explorer, select the project you want to unload.
  2. On the Project menu, select Unload Project.

See Also

Using Solution Explorer | Item Management in Projects | Unloading and Reloading Projects | Excluding Files from a Project Output Group

Show:
© 2015 Microsoft