Skip to content

Commit 920f195

Browse files
authored
Merge pull request #3888 from GitHubber17/from-public-2364
[PUBLIC_MOVE] commits from public #2364
2 parents f40c6ea + fc4e288 commit 920f195

File tree

1 file changed

+61
-62
lines changed

1 file changed

+61
-62
lines changed

docs/msbuild/item-element-msbuild.md

Lines changed: 61 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,39 @@
22
title: "Item Element (MSBuild) | Microsoft Docs"
33
ms.date: "03/13/2017"
44
ms.topic: "reference"
5-
dev_langs:
5+
dev_langs:
66
- "VB"
77
- "CSharp"
88
- "C++"
99
- "jsharp"
10-
helpviewer_keywords:
10+
helpviewer_keywords:
1111
- "Item Element [MSBuild]"
1212
- "<Item> Element [MSBuild]"
1313
ms.assetid: dcef5f91-0613-4bfc-8ee9-d7004bb6d3a9
1414
author: mikejo5000
1515
ms.author: mikejo
1616
manager: jillfra
17-
ms.workload:
17+
ms.workload:
1818
- "multiple"
1919
---
2020
# Item element (MSBuild)
21-
Contains a user-defined item and its metadata. Every item that is used in a [!INCLUDE[vstecmsbuild](../extensibility/internals/includes/vstecmsbuild_md.md)] project must be specified as a child of an `ItemGroup` element.
21+
Contains a user-defined item and its metadata. Every item that is used in a [!INCLUDE[vstecmsbuild](../extensibility/internals/includes/vstecmsbuild_md.md)] project must be specified as a child of an `ItemGroup` element.
2222

23-
\<Project>
24-
\<ItemGroup>
25-
\<Item>
23+
\<Project>
24+
\<ItemGroup>
25+
\<Item>
2626

27-
## Syntax
27+
## Syntax
2828

29-
```xml
30-
<Item Include="*.cs"
31-
Exclude="MyFile.cs"
32-
Remove="RemoveFile.cs"
33-
Condition="'String A'=='String B'" >
34-
<ItemMetadata1>...</ItemMetadata1>
35-
<ItemMetadata2>...</ItemMetadata2>
36-
</Item>
37-
```
29+
```xml
30+
<Item Include="*.cs"
31+
Exclude="MyFile.cs"
32+
Remove="RemoveFile.cs"
33+
Condition="'String A'=='String B'" >
34+
<ItemMetadata1>...</ItemMetadata1>
35+
<ItemMetadata2>...</ItemMetadata2>
36+
</Item>
37+
```
3838

3939
## Specify metadata as attributes
4040
In MSBuild 15.1 or later, any metadata with a name that doesn't conflict with the current list of attributes can optionally be expressed as an attribute.
@@ -53,69 +53,68 @@ Now, however, you can pass the `Version` metadata as an attribute, such as in th
5353

5454
```xml
5555
<ItemGroup>
56-
<PackageReference Include="Newtonsoft.Json" Version="9.0.1-beta1" />
56+
<PackageReference Include="Newtonsoft.Json" Version="9.0.1-beta1" />
5757
</ItemGroup>
5858
```
5959

60-
## Attributes and elements
61-
The following sections describe attributes, child elements, and parent elements.
60+
## Attributes and elements
61+
The following sections describe attributes, child elements, and parent elements.
6262

63-
### Attributes
63+
### Attributes
6464

65-
|Attribute|Description|
66-
|---------------|-----------------|
67-
|`Include`|Optional attribute.<br /><br /> The file or wildcard to include in the list of items.|
68-
|`Exclude`|Optional attribute.<br /><br /> The file or wildcard to exclude from the list of items.|
69-
|`Condition`|Optional attribute.<br /><br /> The condition to be evaluated. For more information, see [Conditions](../msbuild/msbuild-conditions.md).|
70-
|`Remove`|Optional attribute.<br /><br /> The file or wildcard to remove from the list of items.<br /><br />|
71-
|`KeepDuplicates`|Optional attribute.<br /><br /> Specifies whether an item should be added to the target group if it's an exact duplicate of an existing item. If the source and target item have the same `Include` value but different metadata, the item is added even if `KeepDuplicates` is set to `false`. For more information, see [Items](../msbuild/msbuild-items.md).<br /><br /> This attribute is valid only if it's specified for an item in an `ItemGroup` that's in a `Target`.|
72-
|`KeepMetadata`|Optional attribute.<br /><br /> The metadata for the source items to add to the target items. Only the metadata whose names are specified in the semicolon-delimited list are transferred from a source item to a target item. For more information, see [Items](../msbuild/msbuild-items.md).<br /><br /> This attribute is valid only if it's specified for an item in an `ItemGroup` that's in a `Target`.|
73-
|`RemoveMetadata`|Optional attribute.<br /><br /> The metadata for the source items to not transfer to the target items. All metadata is transferred from a source item to a target item except metadata whose names are contained in the semicolon-delimited list of names. For more information, see [Items](../msbuild/msbuild-items.md).<br /><br /> This attribute is valid only if it's specified for an item in an `ItemGroup` that's in a `Target`.|
74-
|`Update`|Optional attribute. (Available only for .NET Core projects in Visual Studio 2017 or later.)<br /><br /> Enables you to modify metadata of a file that was included by using a glob.<br /><br /> This attribute is valid only if it's specified for an item in an `ItemGroup` that is not in a `Target`.|
65+
|Attribute|Description|
66+
|---------------|-----------------|
67+
|`Include`|Optional attribute.<br /><br /> The file or wildcard to include in the list of items.|
68+
|`Exclude`|Optional attribute.<br /><br /> The file or wildcard to exclude from the list of items.|
69+
|`Condition`|Optional attribute.<br /><br /> The condition to be evaluated. For more information, see [Conditions](../msbuild/msbuild-conditions.md).|
70+
|`Remove`|Optional attribute.<br /><br /> The file or wildcard to remove from the list of items.<br /><br />|
71+
|`KeepDuplicates`|Optional attribute.<br /><br /> Specifies whether an item should be added to the target group if it's an exact duplicate of an existing item. If the source and target item have the same `Include` value but different metadata, the item is added even if `KeepDuplicates` is set to `false`. For more information, see [Items](../msbuild/msbuild-items.md).<br /><br /> This attribute is valid only if it's specified for an item in an `ItemGroup` that's in a `Target`.|
72+
|`KeepMetadata`|Optional attribute.<br /><br /> The metadata for the source items to add to the target items. Only the metadata whose names are specified in the semicolon-delimited list are transferred from a source item to a target item. For more information, see [Items](../msbuild/msbuild-items.md).<br /><br /> This attribute is valid only if it's specified for an item in an `ItemGroup` that's in a `Target`.|
73+
|`RemoveMetadata`|Optional attribute.<br /><br /> The metadata for the source items to not transfer to the target items. All metadata is transferred from a source item to a target item except metadata whose names are contained in the semicolon-delimited list of names. For more information, see [Items](../msbuild/msbuild-items.md).<br /><br /> This attribute is valid only if it's specified for an item in an `ItemGroup` that's in a `Target`.|
74+
|`Update`|Optional attribute. (Available only for .NET Core projects in Visual Studio 2017 or later.)<br /><br /> Enables you to modify metadata of a file that was included by using a glob.<br /><br /> This attribute is valid only if it's specified for an item in an `ItemGroup` that is not in a `Target`.|
7575

76-
### Child elements
76+
### Child elements
7777

78-
|Element|Description|
79-
|-------------|-----------------|
80-
|[ItemMetadata](../msbuild/itemmetadata-element-msbuild.md)|A user-defined item metadata key, which contains the item metadata value. There may be zero or more `ItemMetadata` elements in an item.|
78+
|Element|Description|
79+
|-------------|-----------------|
80+
|[ItemMetadata](../msbuild/itemmetadata-element-msbuild.md)|A user-defined item metadata key, which contains the item metadata value. There may be zero or more `ItemMetadata` elements in an item.|
8181

82-
### Parent elements
82+
### Parent elements
8383

84-
|Element|Description|
85-
|-------------|-----------------|
86-
|[ItemGroup](../msbuild/itemgroup-element-msbuild.md)|Grouping element for items.|
84+
|Element|Description|
85+
|-------------|-----------------|
86+
|[ItemGroup](../msbuild/itemgroup-element-msbuild.md)|Grouping element for items.|
8787

88-
## Remarks
89-
`Item` elements define inputs into the build system, and are grouped into item collections based on their user-defined collection names. These item collections can be used as parameters for [tasks](../msbuild/msbuild-tasks.md), which use the individual items in the collections to perform the steps of the build process. For more information, see [Items](../msbuild/msbuild-items.md).
88+
## Remarks
89+
`Item` elements define inputs into the build system, and are grouped into item collections based on their user-defined collection names. These item collections can be used as parameters for [tasks](../msbuild/msbuild-tasks.md), which use the individual items in the collections to perform the steps of the build process. For more information, see [Items](../msbuild/msbuild-items.md).
9090

91-
Using the notation @(\<myType>) enables a collection of items of type \<myType> to be expanded into a semicolon-delimited list of strings, and passed to a parameter. If the parameter is of type `string`, then the value of the parameter is the list of elements, separated by semicolons. If the parameter is an array of strings (`string[]`), then each element is inserted into the array based on the location of the semicolons. If the task parameter is of type <xref:Microsoft.Build.Framework.ITaskItem>`[]`, then the value is the contents of the item collection together with any metadata attached. To delimit each item by using a character other than a semicolon, use the syntax @(<myType>, '<separator>').
91+
Using the notation @(\<myType>) enables a collection of items of type \<myType> to be expanded into a semicolon-delimited list of strings, and passed to a parameter. If the parameter is of type `string`, then the value of the parameter is the list of elements, separated by semicolons. If the parameter is an array of strings (`string[]`), then each element is inserted into the array based on the location of the semicolons. If the task parameter is of type <xref:Microsoft.Build.Framework.ITaskItem>`[]`, then the value is the contents of the item collection together with any metadata attached. To delimit each item by using a character other than a semicolon, use the syntax @(\<myType>, '\<separator>').
9292

93-
The [!INCLUDE[vstecmsbuild](../extensibility/internals/includes/vstecmsbuild_md.md)] engine can evaluate wildcards such as `*` and `?` and recursive wildcards such as */\*\*/\*.cs*. For more information, see [Items](../msbuild/msbuild-items.md).
93+
The [!INCLUDE[vstecmsbuild](../extensibility/internals/includes/vstecmsbuild_md.md)] engine can evaluate wildcards such as `*` and `?` and recursive wildcards such as */\*\*/\*.cs*. For more information, see [Items](../msbuild/msbuild-items.md).
9494

95-
## Examples
96-
The following code example shows how to declare two items of type `CSFile`. The second declared item contains metadata that has `MyMetadata` set to `HelloWorld`.
95+
## Examples
96+
The following code example shows how to declare two items of type `CSFile`. The second declared item contains metadata that has `MyMetadata` set to `HelloWorld`.
9797

98-
```xml
99-
<ItemGroup>
100-
<CSFile Include="engine.cs; form.cs" />
101-
<CSFile Include="main.cs" >
102-
<MyMetadata>HelloWorld</MyMetadata>
103-
</CSFile>
104-
</ItemGroup>
105-
```
98+
```xml
99+
<ItemGroup>
100+
<CSFile Include="engine.cs; form.cs" />
101+
<CSFile Include="main.cs" >
102+
<MyMetadata>HelloWorld</MyMetadata>
103+
</CSFile>
104+
</ItemGroup>
105+
```
106106
The following code example shows how to use the `Update` attribute to modify the metadata in a file called *somefile.cs* that was included via a glob. (Available only for .NET Core projects in Visual Studio 2017 or later.)
107107

108-
```xml
108+
```xml
109109
<ItemGroup>
110110
<Compile Update="somefile.cs"> // or Update="*.designer.cs"
111111
<MetadataKey>MetadataValue</MetadataKey>
112112
</Compile>
113-
</ItemGroup>
114-
```
115-
113+
</ItemGroup>
114+
```
116115

117-
## See also
118-
[Items](../msbuild/msbuild-items.md)
119-
[Common MSBuild project items](../msbuild/common-msbuild-project-items.md)
120-
[MSBuild properties](../msbuild/msbuild-properties.md)
121-
[Project file schema reference](../msbuild/msbuild-project-file-schema-reference.md)
116+
## See also
117+
[Items](../msbuild/msbuild-items.md)
118+
[Common MSBuild project items](../msbuild/common-msbuild-project-items.md)
119+
[MSBuild properties](../msbuild/msbuild-properties.md)
120+
[Project file schema reference](../msbuild/msbuild-project-file-schema-reference.md)

0 commit comments

Comments
 (0)