Build and clean projects and solutions in Visual Studio
Applies to: Visual Studio Visual Studio for Mac
This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
By using the procedures in this topic, you can build, rebuild, or clean all or some of the projects or project items in a solution. For a step-by-step tutorial, see Walkthrough: Building an application.
This topic applies to Visual Studio on Windows. For Visual Studio for Mac, see Build and clean projects and solutions in Visual Studio for Mac.
The UI in your edition of Visual Studio might differ from what this topic describes, depending on your active settings. To change your settings, for example to General or Visual C++ settings, choose Tools > Import and Export Settings, and then choose Reset all settings.
To build, rebuild, or clean an entire solution
In Solution Explorer, choose or open the solution.
On the menu bar, choose Build, and then choose one of the following commands:
Choose Build or Build Solution, or press Ctrl+Shift+B, to compile only those project files and components that have changed since the most recent build.
The Build command becomes Build Solution when a solution includes more than one project.
Choose Rebuild Solution to "clean" the solution and then build all project files and components.
Choose Clean Solution to delete any intermediate and output files. With only the project and component files left, new instances of the intermediate and output files can then be built.
To build or rebuild a single project
In Solution Explorer, choose or open the project.
On the menu bar, choose Build, and then choose either Build ProjectName or Rebuild ProjectName.
Choose Build ProjectName to build only those project components that have changed since the most recent build.
Choose Rebuild ProjectName to "clean" the project and then build the project files and all project components.
To build only the startup project and its dependencies
On the menu bar, choose Tools > Options.
In the Options dialog box, expand the Projects and Solutions node, and then choose the Build and Run page.
The Build and Run > Projects and Solutions > Options dialog box opens.
Select the Only build startup projects and dependencies on Run check box.
When this check box is selected, only the current startup project and its dependencies are built when you perform either of the following steps:
On the menu bar, choose Debug > Start (F5).
On the menu bar, choose Build > Build Solution (Ctrl+Shift+B).
When this check box is cleared, all projects, their dependencies, and the solution files are built when you run either of the preceding commands.
To build only the selected Visual C++ project
Choose a C++ project, and then, on the menu bar, choose Build > Project Only, and one of the following commands:
Build Only ProjectName
Rebuild Only ProjectName
Clean Only ProjectName
Link Only ProjectName
These commands apply only to the C++ project that you chose, without building, rebuilding, cleaning, or linking any project dependencies or solution files. Depending on your version of Visual Studio, the Project Only submenu might contain more commands.
To compile multiple C++ project items
In Solution Explorer, choose multiple files that have can be compiled actions, open the shortcut menu for one of those files, and then choose Compile, or press Ctrl+F7.
If the files have dependencies, the files will be compiled in dependency order. The compile operation will fail if the files require a precompiled header that isn't available when you compile. The compile operation uses the current active solution configuration.
To stop a build
Perform either of the following steps:
On the menu bar, select Build > Cancel.
- How to: View, save, and configure build log files
- Obtaining build logs
- Compiling and building
- Understanding build configurations
- How to: Set debug and release configurations
- C/C++ building reference
- Devenv command line switches
- Solutions and projects
- Build and clean projects and solutions (Visual Studio for Mac)