Anteckning
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Required root element of an MSBuild project file.
Syntax
<Project InitialTargets="TargetA;TargetB"
         DefaultTargets="TargetC;TargetD"
         TreatAsLocalProperty="PropertyA;PropertyB"
         ToolsVersion="<version number>"
         Sdk="name[/version]">
    <Sdk... />
    <Choose>... </Choose>
    <PropertyGroup>... </PropertyGroup>
    <ItemGroup>... </ItemGroup>
    <Target>... </Target>
    <UsingTask.../>
    <ProjectExtensions>... </ProjectExtensions>
    <Import... />
</Project>
Attributes and elements
The following sections describe attributes, child elements, and parent elements.
Attributes
| Attribute | Description | 
|---|---|
| DefaultTargets | Optional attribute. The default target or targets to be the entry point of the build if no target has been specified. Multiple targets are semi-colon (;) delimited. If no default target is specified in either the DefaultTargetsattribute or the MSBuild command line, the engine executes the first target in the project file after the Import elements have been evaluated. | 
| InitialTargets | Optional attribute. The initial target or targets to be run before the targets specified in the DefaultTargetsattribute or on the command line. Multiple targets are semi-colon (;) delimited. If multiple imported files defineInitialTargets, all targets mentioned will be run, in the order the imports are encountered. | 
| Sdk | Optional attribute. The SDK name and optional version to use to create implicit Import statements that are added to the .proj file. If no version is specified, MSBuild will attempt to resolve a default version. For example, <Project Sdk="Microsoft.NET.Sdk" />or<Project Sdk="My.Custom.Sdk/1.0.0" />. | 
| ToolsVersion | Optional attribute. The version of the Toolset MSBuild uses to determine the values for $(MSBuildBinPath) and $(MSBuildToolsPath). | 
| TreatAsLocalProperty | Optional attribute. Property names that won't be considered to be global. This attribute prevents specific command-line properties from overriding property values that are set in a project or targets file and all subsequent imports. Multiple properties are semi-colon (;) delimited. Normally, global properties override property values that are set in the project or targets file. If the property is listed in the TreatAsLocalPropertyvalue, the global property value doesn't override property values that are set in that file and any subsequent imports. For more information, see How to: Build the same source files with different options. Note:  You set global properties  at a command prompt by using the -property (or -p) switch. You can also set or modify global properties for child projects in a multi-project build by using thePropertiesattribute of the MSBuild task. For more information, see MSBuild task. | 
| xmlns | Optional attribute. When specified, the xmlnsattribute must have the value ofhttp://schemas.microsoft.com/developer/msbuild/2003. | 
Child elements
| Element | Description | 
|---|---|
| Choose | Optional element. Evaluates child elements to select one set of ItemGroupelements and/orPropertyGroupelements to evaluate. | 
| Import | Optional element. Enables a project file to import another project file. There may be zero or more Importelements in a project. | 
| ImportGroup | Optional element. Contains a collection of Importelements that are grouped under an optional condition. | 
| ItemGroup | Optional element. A grouping element for individual items. Items are specified by using the Item element. There may be zero or more ItemGroupelements in a project. | 
| ItemDefinitionGroup | Optional element. Lets you define a set of Item Definitions, which are metadata values that are applied to all items in the project, by default. ItemDefinitionGroup supersedes the need to use the CreateItemtask and theCreatePropertytask. | 
| ProjectExtensions | Optional element. Provides a way to persist non-MSBuild information in an MSBuild project file. There may be zero or one ProjectExtensionselements in a project. | 
| PropertyGroup | Optional element. A grouping element for individual properties. Properties are specified by using the Property element. There may be zero or more PropertyGroupelements in a project. | 
| Sdk | Optional element. References an MSBuild project SDK. This element can be used as an alternative to the Sdk attribute. | 
| Target | Optional element. Contains a set of tasks for MSBuild to sequentially execute. Tasks are specified by using the Task element. There may be zero or more Targetelements in a project. | 
| UsingTask | Optional element. Provides a way to register tasks in MSBuild. There may be zero or more UsingTaskelements in a project. | 
Parent elements
None.