Skip to content

Commit 078fc11

Browse files
author
mikeblome
committed
updates per tech review
1 parent bef53a1 commit 078fc11

File tree

2 files changed

+128
-67
lines changed

2 files changed

+128
-67
lines changed

docs/ide/property-page-xml-files.md

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Property Page XML Files | Microsoft Docs"
2+
title: "Property Page XML rule files | Microsoft Docs"
33
ms.custom: ""
44
ms.date: "04/27/2017"
55
ms.reviewer: ""
@@ -33,7 +33,7 @@ translation.priority.ht:
3333
- "zh-tw"
3434
---
3535

36-
# Property Page XML Files
36+
# Property Page XML rule files
3737
The project property pages in the IDE are configured by XML files in the VCTargets folder. The exact path depends on which edition(s) of Visual Studio are installed, and the product language. For Visual Studio 2017 Enterprise Edition, in English, the path is `%ProgramFiles%\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\1033`. The XML files describe the names of the rules, the categories, and the individual properties, their data type, default values, and how they are to be displayed. When you set a property in the IDE, the new value is stored in the project file.
3838

3939
The only scenarios in which you need to understand the internal workings of these files and the Visual Studio IDE are (a) you want to create a custom property page, or (b) you want to customize your project properties by some means other than through the Visual Studio IDE.
@@ -48,7 +48,7 @@ As shown above, each Rule has a set of properties which are organized into categ
4848

4949
You can open cl.xml in notepad or any XML editor (see snapshot below). You will see a root node called Rule that has the same list of properties defined under it as is displayed in the UI, along with additional metadata.
5050

51-
```xaml
51+
```xml
5252
<?xml version="1.0" encoding="utf-8"?>
5353
<!--Copyright, Microsoft Corporation, All rights reserved.-->
5454
<Rule Name="CL" PageTemplate="tool" DisplayName="C/C++" SwitchPrefix="/" Order="10" xmlns="http://schemas.microsoft.com/build/2009/properties" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib">
@@ -70,12 +70,12 @@ You can open cl.xml in notepad or any XML editor (see snapshot below). You will
7070

7171
There is one XML file corresponding to every node under Configuration Properties in the property pages UI. You can add or remove rules in the UI by including or removing locations to corresponding XML files in the project. For example, this is how Microsoft.CppBuild.targets (one level up from the 1033 folder) includes cl.xml:
7272

73-
```xaml
73+
```xml
7474
<PropertyPageSchema Condition="'$(ConfigurationType)' != 'Utility'" Include="$(VCTargetsPath)$(LangID)\cl.xml"/>
7575

7676
```
7777
If you strip cl.xml of all data, you will end up with the following skeleton:
78-
```xaml
78+
```xml
7979
<?xml version="1.0" encoding="utf-8"?>
8080
<Rule>
8181
<Rule.DataSource />
@@ -95,7 +95,7 @@ The following section describes each major elements and some of the metadata tha
9595

9696
1. **Rule:** Rule is generally the root node in the xml file; it can have many attributes:
9797

98-
```xaml
98+
```xml
9999
<Rule Name="CL" PageTemplate="tool" SwitchPrefix="/" Order="10"
100100
xmlns="http://schemas.microsoft.com/build/2009/properties"
101101
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@@ -107,7 +107,7 @@ The following section describes each major elements and some of the metadata tha
107107

108108
a. **Name:** The Name attribute is an id for the Rule. It needs to be unique among all the property page xml files for a project.
109109

110-
b. **PageTemplate:** The value of this attribute is used by the UI to choose from a collection of UI templates. The "tool" template renders the properties in a standard grid format. Other in-built values for this attribute are "debugger" and "generic". See the Debugging node and General node, respectively, to see the UI format resulting from specifying these values. The UI for "debugger" page template uses a drop-down box to switch between the properties of different debuggers whereas the "generic" template displays different property categories all in one page as opposed to having multiple category sub-nodes under the Rule node. This attribute is just a suggestion to the UI; the xml file is designed to be UI independent. So, a different UI could use this attribute for different purposes.
110+
b. **PageTemplate:** The value of this attribute is used by the UI to choose from a collection of UI templates. The "tool" template renders the properties in a standard grid format. Other in-built values for this attribute are "debugger" and "generic". See the Debugging node and General node, respectively, to see the UI format resulting from specifying these values. The UI for "debugger" page template uses a drop-down box to switch between the properties of different debuggers whereas the "generic" template displays different property categories all in one page as opposed to having multiple category sub-nodes under the Rule node. This attribute is just a suggestion to the UI; the xml file is designed to be UI independent. A different UI might use this attribute for different purposes.
111111

112112
c. **SwitchPrefix:** This is the prefix used in the command line for the switches. A value of "/" would result in switches that look like /ZI, /nologo, /W3, etc.
113113

@@ -119,32 +119,32 @@ The following section describes each major elements and some of the metadata tha
119119

120120
g. **DataSource:** This is a very important property that tells the project system the location from which the property value should read from and written to, and its grouping (explained below). For cl.xml, these values are:
121121

122-
```xaml
122+
```xml
123123
<DataSource Persistence="ProjectFile" ItemType="ClCompile" Label="" HasConfigurationCondition="true" />
124124
```
125-
- Persistence="ProjectFile" tells the project system that all properties for the Rule should be written to the project file or the property sheet file (depending on which node was used to spawn the property pages). The other possible value is "UserFile" which will write the value to the .user file.
125+
- `Persistence="ProjectFile` tells the project system that all properties for the Rule should be written to the project file or the property sheet file (depending on which node was used to spawn the property pages). The other possible value is "UserFile" which will write the value to the .user file.
126126

127127
- `ItemType="ClCompile"` says that the properties will be stored as ItemDefinition metadata or item metadata (the latter only if the property pages were spawned from a file node in solution explorer) of this item type. If this field is not set, then the property is written as a common property in a PropertyGroup.
128128

129-
- `Label=""` indicates that when the properties are written as ItemDefinition metadata, the label of the parent ItemDefinitionGroup will be empty (every MSBuild element can have a Label). Visual Studio 2017 uses labeled groups to navigate the .vcxproj project file. Note that the groups that contain most Rule properties have an empty string as a label.
129+
- `Label=""` indicates that when the properties are written as `ItemDefinition` metadata, the label of the parent ItemDefinitionGroup will be empty (every MSBuild element can have a Label). Visual Studio 2017 uses labeled groups to navigate the .vcxproj project file. Note that the groups that contain most Rule properties have an empty string as a label.
130130

131131
- `HasConfigurationCondition="true"` tells the project system to affix a configuration condition to the value so that it takes effect only for the current project configuration (the condition could be affixed to the parent group or the value itself). For example, open the property pages off the project node and set the value of the property **Treat Warnings As Error** under **Configuration Properties > C/C++ General** to "Yes". The following value is written to the project file. Notice the configuration condition attached to the parent ItemDefinitionGroup.
132132

133-
```xaml
133+
```xml
134134
<ItemDefinitionGroup Condition="‘$(Configuration)|$(Platform)’==’Debug|Win32’">
135135
<ClCompile>
136136
<TreatWarningAsError>true</TreatWarningAsError>
137137
</ClCompile>
138138
</ItemDefinitionGroup>
139139
```
140-
If this value were set in the property page for a specific file, say stdafx.cpp, then the property value would be written under the stdafx.cpp item in the project file as shown below. Notice how the configuration condition is directly attached to the metadata itself.
141-
142-
```xaml
143-
<ItemGroup>
144-
<ClCompile Include="stdafx.cpp">
145-
<TreatWarningAsError Condition="‘$(Configuration)|$(Platform)’==’Debug|Win32’">true</TreatWarningAsError>
146-
</ClCompile>
147-
</ItemGroup>
140+
If this value were set in the property page for a specific file, such as stdafx.cpp, then the property value would be written under the stdafx.cpp item in the project file as shown below. Notice how the configuration condition is directly attached to the metadata itself.
141+
142+
```xml
143+
<ItemGroup>
144+
<ClCompile Include="stdafx.cpp">
145+
<TreatWarningAsError Condition="‘$(Configuration)|$(Platform)’==’Debug|Win32’">true</TreatWarningAsError>
146+
</ClCompile>
147+
</ItemGroup>
148148
```
149149
Another attribute of **DataSource** not listed above is **PersistedName**. You can use this attribute to represent a property in the project file using a different name. By default this attribute is set to the property’s **Name**.
150150

@@ -156,26 +156,26 @@ The following section describes each major elements and some of the metadata tha
156156

157157
2. **Category:** A Rule can have multiple Categories. The order in which the categories are listed in the xml file is a suggestion to the UI to display the categories in the same order. For example, the order of the categories under the C/C++ node as seen in the UI –General, Optimization, Preprocessor, … – is the same as that in cl.xml. A sample category looks like this:
158158

159-
```xaml
160-
<Category Name="Optimization">
161-
<Category.DisplayName>
159+
```xml
160+
<Category Name="Optimization">
161+
<Category.DisplayName>
162162
<sys:String>Optimization</sys:String>
163-
</Category.DisplayName>
164-
</Category>
163+
</Category.DisplayName>
164+
</Category>
165165
```
166166
The above snippet shows the **Name** and **DisplayName** attributes that have been described before. Once again, there are other attributes a **Category** can have that are not used above. You can know about them by reading the documentation or by examining the assemblies using ildasm.exe.
167167

168168
3. **Properties:** This is the meat of the xml file and contains the list of all properties in this Rule. Each property can be one of five possible types shown in the XAML skeleton above. Of course, you could have only a few of those types in your file. A property has a number of attributes that allow it to be described richly. I’ll explain only the **StringProperty** here. The rest are very similar.
169169

170-
```xaml
170+
```xml
171171
<StringProperty Subtype="file" Name="ObjectFileName" Category="Output Files" Switch="Fo">
172-
<StringProperty.DisplayName>
173-
<sys:String>Object File Name</sys:String>
174-
</StringProperty.DisplayName>
175-
<StringProperty.Description>
176-
<sys:String>Specifies a name to override the default object file name; can be file or directory name.(/Fo[name])</sys:String>
177-
</StringProperty.Description>
178-
</StringProperty>
172+
<StringProperty.DisplayName>
173+
<sys:String>Object File Name</sys:String>
174+
</StringProperty.DisplayName>
175+
<StringProperty.Description>
176+
<sys:String>Specifies a name to override the default object file name; can be file or directory name.(/Fo[name])</sys:String>
177+
</StringProperty.Description>
178+
</StringProperty>
179179
```
180180
Most of the attributes in the snippet have been described before. The new ones are Subtype, Category and Switch.
181181

@@ -192,3 +192,5 @@ Most of the attributes in the snippet have been described before. The new ones a
192192
e. **ReadOnly:** If you want to provide a read-only view of this property’s value in the property pages, set this attribute to true.
193193

194194
f. **IncludeInCommandLine:** Some properties may not need to be passed to a tool during build time. Setting this attribute to false will prevent it from being passed.
195+
196+

0 commit comments

Comments
 (0)