title | description | ms.date | ms.subservice | ms.topic | f1_keywords | helpviewer_keywords | author | ms.author | manager | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Build and clean projects and solutions |
Build, rebuild, or clean some of your projects or project items, or all of your projects, in your Visual Studio project solution. |
10/17/2023 |
compile-build |
conceptual |
|
|
ghogen |
ghogen |
mijacobs |
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.
Note
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.
Note
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.
-
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.
[!NOTE] 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.
-
-
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.
-
-
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 choose Debug > Start (F5) or Debug > Start Without Debugging (Ctrl+F5).
When you choose Build > Build Solution (Ctrl+Shift+B), the entire solution is built.
When this check box is cleared, all projects, their dependencies, and the solution files are built when you run any of the preceding commands.
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.
In Solution Explorer, choose multiple files that can be compiled, 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.
Perform either of the following steps:
-
On the menu bar, select Build > Cancel.
-
Press Ctrl+Break.
- 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)