Share via


Project Element (MSBuild)

Required root element of an MSBuild project file.

<Project InitialTargets="TargetA;TargetB"
         DefaultTargets="TargetC;TargetD"
         xmlns="https://schemas.microsoft.com/developer/msbuild/2003">
    <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 DefaultTargets attribute or the MSBuild command line, the engine will execute 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 DefaultTargets attribute or on the command line. Multiple targets are semi-colon (;) delimited.

xmlns

Required attribute.

The xmlns attribute must have the value of "https://schemas.microsoft.com/developer/msbuild/2003".

Child Elements

Element Description

Choose

Optional element.

Evaluates child elements to select one set of ItemGroup elements and/or PropertyGroup elements to evaluate.

Import

Optional element.

Allows a project file to import another project file. There may be zero or more Import elements in a project.

ItemGroup

Optional element.

A grouping element for individual items. Items are specified using the Item element. There may be zero or more ItemGroup elements in a project.

ProjectExtensions

Optional element.

Provides a way to persist non-MSBuild information within an MSBuild project file. There may be zero or one ProjectExtensions elements in a project.

PropertyGroup

Optional element.

A grouping element for individual properties. Properties are specified using the Property element. There may be zero or more PropertyGroup elements in a project.

Target

Optional element.

Contains a set of tasks for MSBuild to sequentially execute. Tasks are specified using the Task element. There may be zero or more Target elements in a project.

UsingTask

Optional element.

Provides a way to register tasks within MSBuild. There may be zero or more UsingTask elements in a project.

Parent Elements

None.

See Also

Tasks

How To: Specify Which Target to Build First

Reference

MSBuild Command Line Reference

Concepts

MSBuild Project File Schema Reference
MSBuild Overview