

To emit an item, the Task element must have a child Output element that has an ItemName attribute. During the subsequent execution phase, items can be created or modified in the following ways:Īny task can emit an item. Items that are outside Target elements are assigned values during the evaluation phase of a build. The Include attribute is a path that is interpreted relative to the project file's folder, $(MSBuildProjectPath), even if the item is in an imported file such as a. Notice that the file names are separated by a semicolon. The following XML creates the same item type by declaring both files in one Include attribute. The item file2.cs doesn't replace the item file1.cs instead, the file name is appended to the list of values for the Compile item type. For example, the following XML creates an item type that's named Compile, which includes two files. The Include attribute of the element specifies the items (files) to be included with that item type.

The name of the child element is the type of the item. Valid item names begin with an uppercase or lowercase letter or underscore ( _) valid subsequent characters include alphanumeric characters (letters or digits), underscore, and hyphen ( -). You declare items in the project file as child elements of an ItemGroup element. The tasks use the item values to perform the steps of the build process.īecause items are named by the item type to which they belong, the terms "item" and "item value" can be used interchangeably. Item types are named lists of items that can be used as parameters for tasks. Items are grouped into item types based on their element names. MSBuild items are inputs into the build system, and they typically represent files (the files are specified in the Include attribute).
