Skip to content

Commit cc0476d

Browse files
authored
Merge pull request MicrosoftDocs#2706 from corob-msft/cr-1564-fixes
Fix 1564: update MSBuild internals for 2019
2 parents d2fdf69 + bb27b0f commit cc0476d

1 file changed

Lines changed: 85 additions & 47 deletions

File tree

Lines changed: 85 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,136 @@
11
---
22
title: "MSBuild internals for C++ projects in Visual Studio"
3-
ms.date: "05/16/2019"
3+
ms.date: "02/26/2020"
44
helpviewer_keywords: ["MSBuild overview"]
55
ms.assetid: dd258f6f-ab51-48d9-b274-f7ba911d05ca
66
---
7-
87
# MSBuild internals for C++ projects
98

10-
When you set project properties in the IDE and then save the project, Visual Studio writes the project settings to your project file. The project file contains settings that are unique to your project, but it does not contain all the settings that are required to build your project. The project file contains `Import` elements that include a network of additional *support files.* The support files contain the remaining properties, targets, and settings that are required to build the project.
9+
When you set project properties in the IDE and then save the project, Visual Studio writes the project settings to your project file. The project file contains settings that are unique to your project. However, it doesn't contain all the settings required to build your project. The project file contains `Import` elements that include a network of additional *support files.* The support files contain the remaining properties, targets, and settings required to build the project.
1110

12-
Most targets and properties in the support files exist solely to implement the build system. The following section discusses some useful targets and properties that you can specify on the MSBuild command line. To discover more targets and properties, explore the files in the support file directories.
11+
Most targets and properties in the support files exist solely to implement the build system. This article discusses useful targets and properties you can specify on the MSBuild command line. To discover more targets and properties, explore the files in the support file directories.
1312

1413
## Support File Directories
1514

16-
By default, the primary Visual Studio support files are located in the following directories. The directories under Microsoft Visual Studio are used by Visual Studio 2017 and later versions, while the directories under MSBuild are used by Visual Studio 2015 and earlier versions.
15+
By default, the primary Visual Studio support files are located in the following directories. This information is version-specific.
16+
17+
### Visual Studio 2019
18+
19+
- %VSINSTALLDIR%MSBuild\\Microsoft\\VC\\*version*\\VCTargets\\
20+
21+
Contains the primary target files (.targets) and property files (.props) that are used by the targets. By default, the $(VCTargetsPath) macro references this directory. The *version* placeholder refers to the Visual Studio version: v160 for Visual Studio 2019, v150 for Visual Studio 2017.
22+
23+
- %VSINSTALLDIR%MSBuild\\Microsoft\\VC\\*version*\\VCTargets\\Platforms\\*platform*\\
24+
25+
Contains platform-specific target and property files that override targets and properties in its parent directory. This directory also contains a DLL that defines the tasks that are used by the targets in this directory. The *platform* placeholder represents the ARM, Win32, or x64 subdirectory.
26+
27+
- %VSINSTALLDIR%MSBuild\\Microsoft\\VC\\*version*\\VCTargets\\Platforms\\*platform*\\PlatformToolsets\\*toolset*\\
28+
29+
Contains the directories that enable the build to generate C++ applications by using the specified *toolset*. The *platform* placeholder represents the ARM, Win32, or x64 subdirectory. The *toolset* placeholder represents the toolset subdirectory.
30+
31+
### Visual Studio 2017
32+
33+
- %VSINSTALLDIR%Common7\\IDE\\VC\\VCTargets\\
34+
35+
Contains the primary target files (.targets) and property files (.props) that are used by the targets. By default, the $(VCTargetsPath) macro references this directory.
36+
37+
- %VSINSTALLDIR%Common7\\IDE\\VC\\VCTargets\\Platforms\\*platform*\\
38+
39+
Contains platform-specific target and property files that override targets and properties in its parent directory. This directory also contains a DLL that defines the tasks that are used by the targets in this directory. The *platform* placeholder represents the ARM, Win32, or x64 subdirectory.
40+
41+
- %VSINSTALLDIR%Common7\\IDE\\VC\\VCTargets\\Platforms\\*platform*\\PlatformToolsets\\*toolset*\\
42+
43+
Contains the directories that enable the build to generate C++ applications by using the specified *toolset*. The *platform* placeholder represents the ARM, Win32, or x64 subdirectory. The *toolset* placeholder represents the toolset subdirectory.
44+
45+
### Visual Studio 2015 and earlier
46+
47+
- *drive*:\\Program Files *(x86)*\\MSBuild\\Microsoft.Cpp (x86)\\v4.0\\*version*\\
48+
49+
Contains the primary target files (.targets) and property files (.props) that are used by the targets. By default, the $(VCTargetsPath) macro references this directory.
50+
51+
- *drive*:\\Program Files *(x86)*\\MSBuild\\Microsoft.Cpp\\v4.0\\*version*\\Platforms\\*platform*\\
52+
53+
Contains platform-specific target and property files that override targets and properties in its parent directory. This directory also contains a DLL that defines the tasks that are used by the targets in this directory. The *platform* placeholder represents the ARM, Win32, or x64 subdirectory.
54+
55+
- *drive*:\\Program Files *(x86)*\\MSBuild\\Microsoft.Cpp\\v4.0\\*version*\\Platforms\\*platform*\\PlatformToolsets\\*toolset*\\
56+
57+
Contains the directories that enable the build to generate C++ applications by using the specified *toolset*. The *version* placeholder is V110 for Visual Studio 2012, V120 for Visual Studio 2013, and V140 for Visual Studio 2015. The *platform* placeholder represents the ARM, Win32, or x64 subdirectory. The *toolset* placeholder represents the toolset subdirectory. For example, it's v140 for building Windows apps by using the Visual Studio 2015 toolset. Or, v120_xp to build for Windows XP using the Visual Studio 2013 toolset.
58+
59+
- *drive*:\\Program Files *(x86)*\\MSBuild\\Microsoft.Cpp\\v4.0\\Platforms\\*platform*\\PlatformToolsets\\*toolset*\\
1760

18-
|Directory|Description|
19-
|---------------|-----------------|
20-
|*drive*:\Program Files *(x86)*\Microsoft Visual Studio\\*year*\\*edition*\Common7\IDE\VC\VCTargets\ <br /><br />*drive*:\Program Files *(x86)*\MSBuild\Microsoft.Cpp (x86)\v4.0\\*version*\ |Contains the primary target files (.targets) and property files (.props) that are used by the targets. By default, the $(VCTargetsPath) macro references this directory.|
21-
|*drive*:\Program Files *(x86)*\Microsoft Visual Studio\\*year*\\*edition*\Common7\IDE\VC\VCTargets\Platforms\\*platform*\ <br /><br />*drive*:\Program Files *(x86)*\MSBuild\Microsoft.Cpp\v4.0\\*version*\Platforms\\*platform*\ |Contains platform-specific target and property files that override targets and properties in its parent directory. This directory also contains a DLL that defines the tasks that are used by the targets in this directory.<br /><br /> The *platform* placeholder represents the ARM, Win32, or x64 subdirectory.|
22-
|*drive*:\Program Files *(x86)*\Microsoft Visual Studio\\*year*\\*edition*\Common7\IDE\VC\VCTargets\Platforms\\*platform*\PlatformToolsets\\*toolset*\ <br /><br />*drive*:\Program Files *(x86)*\MSBuild\Microsoft.Cpp\v4.0\\*version*\Platforms\\*platform*\PlatformToolsets\\*toolset*\ <br /><br />*drive*:\Program Files *(x86)*\MSBuild\Microsoft.Cpp\v4.0\Platforms\\*platform*\PlatformToolsets\\*toolset*\ |Contains the directories that enable the build to generate C++ applications by using the specified *toolset*.<br /><br /> The *year* and *edition* placeholders are used by Visual Studio 2017 and later editions. The *version* placeholder is V110 for Visual Studio 2012, V120 for Visual Studio 2013, V140 for Visual Studio 2015, v141 for Visual Studio 2017 and v142 for Visual Studio 2019. The *platform* placeholder represents the ARM, Win32, or x64 subdirectory. The *toolset* placeholder represents the toolset subdirectory, for example, v140 for building Windows apps by using the Visual Studio 2015 toolset, v120_xp to build for Windows XP using the Visual Studio 2013 toolset.<br /><br />The path that contains the directories that enable the build to generate either Visual Studio 2008 or Visual Studio 2010 applications doesn't include the *version*, and the *platform* placeholder represents the Itanium, Win32, or x64 subdirectory. The *toolset* placeholder represents the v90 or v100 toolset subdirectory.|
61+
The paths that enable the build to generate either Visual Studio 2008 or Visual Studio 2010 applications don't include the *version*. In those versions, the *platform* placeholder represents the Itanium, Win32, or x64 subdirectory. The *toolset* placeholder represents the v90 or v100 toolset subdirectory.
2362

2463
## Support Files
2564

2665
The support file directories contain files with these extensions:
2766

28-
|Extension|Description|
29-
|---------------|-----------------|
30-
|.targets|Contains `Target` XML elements that specify the tasks that are executed by the target. May also contain `PropertyGroup`, `ItemGroup`, `ItemDefinitionGroup`, and user-defined `Item` elements that are used to assign files and command-line options to task parameters.<br /><br /> For more information, see [Target Element (MSBuild)](/visualstudio/msbuild/target-element-msbuild).|
31-
|.props|Contains `Property Group` and user-defined `Property` XML elements that specify file and parameter settings that are used during a build.<br /><br /> May also contain `ItemDefinitionGroup` and user-defined `Item` XML elements that specify additional settings. Items defined in an item definition group resemble properties, but cannot be accessed from the command line. Visual Studio project files frequently use items instead of properties to represent settings.<br /><br /> For more information, see [ItemGroup Element (MSBuild)](/visualstudio/msbuild/itemgroup-element-msbuild),
32-
[ItemDefinitionGroup Element (MSBuild)](/visualstudio/msbuild/itemdefinitiongroup-element-msbuild), and [Item Element (MSBuild)](/visualstudio/msbuild/item-element-msbuild).|
33-
|.xml|Contains XML elements that declare and initialize IDE user interface elements such as property sheets and property pages, and text box and list box controls.<br /><br /> The .xml files directly support the IDE, not MSBuild. However, the values of IDE properties are assigned to build properties and items.<br /><br /> Most .xml files are in a locale-specific subdirectory. For example, files for the English-US region are in $(VCTargetsPath)\1033\\.|
67+
| Extension | Description |
68+
| --------- | ----------- |
69+
| .targets | Contains `Target` XML elements that specify the tasks that are executed by the target. May also contain `PropertyGroup`, `ItemGroup`, `ItemDefinitionGroup`, and user-defined `Item` elements that are used to assign files and command-line options to task parameters.<br /><br /> For more information, see [Target Element (MSBuild)](/visualstudio/msbuild/target-element-msbuild). |
70+
| .props | Contains `Property Group` and user-defined `Property` XML elements that specify file and parameter settings that are used during a build.<br /><br /> May also contain `ItemDefinitionGroup` and user-defined `Item` XML elements that specify additional settings. Items defined in an item definition group resemble properties, but can't be accessed from the command line. Visual Studio project files frequently use items instead of properties to represent settings.<br /><br /> For more information, see [ItemGroup Element (MSBuild)](/visualstudio/msbuild/itemgroup-element-msbuild), [ItemDefinitionGroup Element (MSBuild)](/visualstudio/msbuild/itemdefinitiongroup-element-msbuild), and [Item Element (MSBuild)](/visualstudio/msbuild/item-element-msbuild). |
71+
| .xml | Contains XML elements that declare and initialize IDE user interface elements. For example, property sheets, property pages, textbox controls, and listbox controls.<br /><br /> The .xml files directly support the IDE, not MSBuild. However, the values of IDE properties are assigned to build properties and items.<br /><br /> Most .xml files are in a locale-specific subdirectory. For example, files for the English-US region are in $(VCTargetsPath)\\1033\\. |
3472

3573
## User targets and properties
3674

37-
To use MSBuild most effectively on the command line, it helps to know which properties and targets are useful and relevant. Most properties and targets help implement the Visual Studio build system, and consequently are not relevant to the user. This section describes some worthwhile user-oriented properties and targets.
75+
To use MSBuild effectively, it helps to know which properties and targets are useful and relevant. Most properties and targets help implement the Visual Studio build system, and consequently aren't relevant to the user. This section describes user-oriented properties and targets worth knowing about.
3876

3977
### PlatformToolset property
4078

41-
The `PlatformToolset` property determines which MSVC toolset is used in the build. By default, the current toolset is used. When this property is set, the value of the property is concatenated with literal strings to form the path of a directory that contains the property and target files that are required to build a project for a particular platform. The platform toolset must be installed to build by using that platform toolset version.
79+
The `PlatformToolset` property determines which MSVC toolset is used in the build. By default, the current toolset is used. When this property is set, its value gets concatenated with literal strings to form the path. It's the directory that contains the property and target files required to build a project for a particular platform. The platform toolset must be installed to build by using that platform toolset version.
4280

4381
For example, set the `PlatformToolset` property to `v140` to use Visual Studio 2015 tools and libraries to build your application:
4482

4583
`msbuild myProject.vcxproj /p:PlatformToolset=v140`
4684

4785
### PreferredToolArchitecture property
4886

49-
The `PreferredToolArchitecture` property determines whether the 32-bit or 64-bit compiler and tools are used in the build. This property does not affect the output platform architecture or configuration. By default, MSBuild uses the x86 version of the compiler and tools if this property is not set.
87+
The `PreferredToolArchitecture` property determines whether the 32-bit or 64-bit compiler and tools are used in the build. This property doesn't affect the output platform architecture or configuration. By default, MSBuild uses the x86 version of the compiler and tools if this property isn't set.
5088

5189
For example, set the `PreferredToolArchitecture` property to `x64` to use the 64-bit compiler and tools to build your application:
5290

5391
`msbuild myProject.vcxproj /p:PreferredToolArchitecture=x64`
5492

5593
### UseEnv property
5694

57-
By default, the platform-specific settings for the current project override the PATH, INCLUDE, LIB, LIBPATH, CONFIGURATION, and PLATFORM environment variables. Set the `UseEnv` property to **true** to guarantee that the environment variables are not overridden.
95+
By default, the platform-specific settings for the current project override the PATH, INCLUDE, LIB, LIBPATH, CONFIGURATION, and PLATFORM environment variables. Set the `UseEnv` property to **true** to guarantee that the environment variables don't get overridden.
5896

5997
`msbuild myProject.vcxproj /p:UseEnv=true`
6098

6199
### Targets
62100

63-
There are hundreds of targets in the Visual Studio support files. However, most are system-oriented targets that the user can ignore. Most system targets are prefixed by an underscore (_), or have a name that starts with "PrepareFor", "Compute", "Before", "After", "Pre", or "Post".
101+
There are hundreds of targets in the Visual Studio support files. However, most are system-oriented targets that the user can ignore. Most system targets are prefixed by an underscore (`_`), or have a name that starts with "PrepareFor", "Compute", "Before", "After", "Pre", or "Post".
64102

65103
The following table lists several useful user-oriented targets.
66104

67-
|Target|Description|
68-
|------------|-----------------|
69-
|BscMake|Executes the Microsoft Browse Information Maintenance Utility tool, bscmake.exe.|
70-
|Build|Builds the project.<br /><br /> This is the default target for a project.|
71-
|ClCompile|Executes the MSVC compiler tool, cl.exe.|
72-
|Clean|Deletes temporary and intermediate build files.|
73-
|Lib|Executes the Microsoft 32-Bit Library Manager tool, lib.exe.|
74-
|Link|Executes the MSVC linker tool, link.exe.|
75-
|ManifestResourceCompile|Extracts a list of resources from a manifest and then executes the Microsoft Windows Resource Compiler tool, rc.exe.|
76-
|Midl|Executes the Microsoft Interface Definition Language (MIDL) compiler tool, midl.exe.|
77-
|Rebuild|Cleans and then builds your project.|
78-
|ResourceCompile|Executes the Microsoft Windows Resource Compiler tool, rc.exe.|
79-
|XdcMake|Executes the XML Documentation tool, xdcmake.exe.|
80-
|Xsd|Executes the XML Schema Definition tool, xsd.exe. *See note below.*|
105+
| Target | Description |
106+
| ------ | ----------- |
107+
| BscMake | Executes the Microsoft Browse Information Maintenance Utility tool, bscmake.exe. |
108+
| Build | Builds the project.<br /><br /> This target is the default for a project. |
109+
| ClCompile | Executes the MSVC compiler tool, cl.exe. |
110+
| Clean | Deletes temporary and intermediate build files. |
111+
| Lib | Executes the Microsoft 32-Bit Library Manager tool, lib.exe. |
112+
| Link | Executes the MSVC linker tool, link.exe. |
113+
| ManifestResourceCompile | Extracts a list of resources from a manifest and then executes the Microsoft Windows Resource Compiler tool, rc.exe. |
114+
| Midl | Executes the Microsoft Interface Definition Language (MIDL) compiler tool, midl.exe. |
115+
| Rebuild | Cleans and then builds your project. |
116+
| ResourceCompile | Executes the Microsoft Windows Resource Compiler tool, rc.exe. |
117+
| XdcMake | Executes the XML Documentation tool, xdcmake.exe. |
118+
| Xsd | Executes the XML Schema Definition tool, xsd.exe. *See note below.* |
81119

82120
> [!NOTE]
83121
> In Visual Studio 2017 and later, C++ project support for **xsd** files is deprecated. You can still use **Microsoft.VisualC.CppCodeProvider** by adding **CppCodeProvider.dll** manually to the GAC.
84122
85123
## See also
86124

87-
[MSBuild Task Reference](/visualstudio/msbuild/msbuild-task-reference)<br/>
88-
[BscMake Task](/visualstudio/msbuild/bscmake-task)<br/>
89-
[CL Task](/visualstudio/msbuild/cl-task)<br/>
90-
[CPPClean Task](/visualstudio/msbuild/cppclean-task)<br/>
91-
[LIB Task](/visualstudio/msbuild/lib-task)<br/>
92-
[Link Task](/visualstudio/msbuild/link-task)<br/>
93-
[MIDL Task](/visualstudio/msbuild/midl-task)<br/>
94-
[MT Task](/visualstudio/msbuild/mt-task)<br/>
95-
[RC Task](/visualstudio/msbuild/rc-task)<br/>
96-
[SetEnv Task](/visualstudio/msbuild/setenv-task)<br/>
97-
[VCMessage Task](/visualstudio/msbuild/vcmessage-task)<br/>
98-
[XDCMake Task](/visualstudio/msbuild/xdcmake-task)<br/>
125+
[MSBuild Task Reference](/visualstudio/msbuild/msbuild-task-reference)\
126+
[BscMake Task](/visualstudio/msbuild/bscmake-task)\
127+
[CL Task](/visualstudio/msbuild/cl-task)\
128+
[CPPClean Task](/visualstudio/msbuild/cppclean-task)\
129+
[LIB Task](/visualstudio/msbuild/lib-task)\
130+
[Link Task](/visualstudio/msbuild/link-task)\
131+
[MIDL Task](/visualstudio/msbuild/midl-task)\
132+
[MT Task](/visualstudio/msbuild/mt-task)\
133+
[RC Task](/visualstudio/msbuild/rc-task)\
134+
[SetEnv Task](/visualstudio/msbuild/setenv-task)\
135+
[VCMessage Task](/visualstudio/msbuild/vcmessage-task)\
136+
[XDCMake Task](/visualstudio/msbuild/xdcmake-task)

0 commit comments

Comments
 (0)