How to: Prepare and Manage Builds

Visual Studio offers a variety of ways to help you organize what files are included in a build of a solution or project and which set of project properties is in effect while building. This section contains topics that explain various procedures for preparing and managing builds.

The following are common Visual Studio procedures for preparing and managing builds.

Note

The options available in dialog boxes, and the names and locations of menu commands you see, might differ from what is described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Working with Settings.

To build, rebuild, or clean an entire solution

  1. In Solution Explorer, select or open the desired solution.

  2. On the Build menu, choose Build Solution, Rebuild Solution, or Clean Solution.

    • Choose Build or Build Solution to compile only those project files and components that have changed since the last build.

      Note

      The Build command becomes Build Solution when a solution includes more than one project.

    • Choose Rebuild Solution to "clean" the solution first, and then build all project files and components.

    • Choose Clean Solution to delete any intermediate and output files, leaving only the project and component files, from which new instances of the intermediate and output files can then be built.

To build or rebuild a single project

  1. In Solution Explorer, select or open the desired project.

  2. On the Build menu, choose Build [Project Name] or Rebuild [Project Name].

    • Choose Build [Project Name] to build only those project components that have changed since the last build.

    • Choose Rebuild [Project Name] to "clean" the project first, and then build the project files and all project components.

To build only the startup project and its dependencies

  1. On the Tools menu, choose Options.

  2. In the Options dialog box, expand the Projects and Solutions folder, and choose Build and Run.

    The Build and Run, Projects and Solutions, Options Dialog Box opens.

  3. Select the option to Only build startup projects and dependencies on Run.

    When this option is selected, only the current startup project and its dependencies are built when you:

    • choose Start (F5) from the Debug menu.

      -or-

    • choose Build Solution (CTRL+SHIFT+B) from the Build menu.

    When this option is cleared, either of the preceding command builds all projects, their dependencies, and the solution files. By default, this option is not selected.

To build only the selected Visual C++ project

  • For Visual C++ projects only, a Project Only submenu of the Build menu displays three project-specific commands:

    • Build Only <projname>

    • Rebuild Only <projname>

    • Clean Only <projname>

    • Link Only <projname>

    These commands build, rebuild, clean, or link the Visual C++ project currently selected in Solution Explorer, without building, rebuilding, cleaning, or linking any project dependencies or solution files. Depending on the version of Visual Studio you have installed, you may have additional commands available on the Project Only submenu.

To compile multiple C++ project items

  1. Selection files that have a valid compile action in Solution Explorer.

  2. Right click one of the selected items to open a context menu.

  3. Choose Compile from the context menu. The files will be compiled in dependency order, if the files selected have dependencies. The compile will fail if the files require a precompiled header that is not available at the time of the build. The compile uses the current active configuration.

To batch build multiple project configurations

  1. Use the Batch Build command to build selected project configurations all at once. Only the projects selected will be built.

  2. On the Build menu, choose Batch Build.

  3. Select the check boxes for the project configurations you wish to build.

  4. Choose Build or Rebuild.

To set save options for build commands

  1. The save options for projects and solutions determine whether unsaved changes will be included as you build projects and solutions while you are editing them.

  2. On the Tools menu, choose Options.

  3. In the Options dialog box, expand the Projects and Solutions folder, and choose Build and Run.

    The Build and Run, Projects and Solutions, Options Dialog Box opens.

  4. Select an option in the Before building list.

To show feedback about builds

  1. The show options for projects and solutions determine what information will be displayed as you build projects and solutions.

  2. On the Tools menu, choose Options.

  3. In the Options dialog box, expand the Projects and Solutions folder, and choose General.

    The General, Projects and Solutions, Options Dialog Box opens.

  4. If you would like the Output window to come to the top and show progress of builds, select Show Output window when build starts.

  5. If you want to see all the errors from a build in the Task List when the build is done, select Always show Error List if build finishes with errors.

See Also

Reference

Configuration Manager Dialog Box

Devenv Command Line Switches

Concepts

Build Configurations

Projects as Containers

Other Resources

Building in Visual Studio

Building in Visual Studio

C/C++ Building Reference