MSBuild well-known item metadata
Item metadata are values attached to items. Some are assigned by MSBuild to items when items are created, but you can also define any metadata you need. Some user-defined metadata values have meaning to MSBuild, specific tasks, or SDKs such as the .NET SDK.
The first table in this article describes the metadata assigned to every item upon creation. The next table shows some optional metadata that has meaning for MSBuild, which you can define to control build behavior. In each example, the following item declaration was used to include the file C:\MyProject\Source\Program.cs in the project.
<ItemGroup> <MyItem Include="Source\Program.cs" /> </ItemGroup>
|%(FullPath)||Contains the full path of the item. For example:
|%(RootDir)||Contains the root directory of the item. For example:
|%(Filename)||Contains the file name of the item, without the extension. For example:
|%(Extension)||Contains the file name extension of the item. For example:
|%(RelativeDir)||Contains the path specified in the
|%(Directory)||Contains the directory of the item, without the root directory. For example:
If the folder C:\MySolution\MyProject\Source\ contains the file Program.cs, and if the project file contains this item:
then the value of
|%(Identity)||The item specified in the
|%(ModifiedTime)||Contains the timestamp from the last time the item was modified. For example:
|%(CreatedTime)||Contains the timestamp from when the item was created. For example:
|%(AccessedTime)||Contains the timestamp from the last time the item was accessed.
Submit and view feedback for