Skip to main content

Search 436 pages — tools, formats, elements, namespaces, directory, comparisons, XPath, datatypes, glossary, parse errors, schema errors, use cases, guides, blog and product.

XML format

MSBuild project

A .NET project file: a build script in XML where element names are targets and item groups, and evaluation order decides what a property means.

A .csproj is the .NET equivalent of a POM, and like a POM it is a build program rather than a manifest. PropertyGroup sets variables, ItemGroup collects files and package references, and Target defines work — all of it evaluated in document order, which is the part that surprises people coming from declarative formats.

The SDK-style project introduced in .NET Core dropped the namespace and most of the boilerplate: a modern .csproj is a dozen lines because <Project Sdk="…"> imports the rest. Older projects still carry the 2003 MSBuild namespace, and tools that match on element names without accounting for both shapes see one and not the other.

Constraints that bite

  • SDK-style projects declare no namespace; legacy ones use http://schemas.microsoft.com/developer/msbuild/2003. An XPath that assumes either will miss the other.
  • Properties are evaluated in order, so a later PropertyGroup overrides an earlier one — and an imported .props file lands where the Import sits.
  • Condition attributes are evaluated as MSBuild expressions, not XPath, and a typo in one silently evaluates false.
  • Globbing is implicit in SDK-style projects; listing a .cs file explicitly usually produces a duplicate-item error.
  • Directory.Build.props applies to every project beneath it without being referenced, so the effective build is not visible in this file alone.
Root element
<Project>
Media type
application/xml
Extensions
.csproj, .fsproj, .vbproj, .props, .targets
Namespaces
None — unqualified elements
XMLDir label

Specification: MSBuild project file schema

A minimal valid document

Every example on this site is checked against the same parser the workspace uses, so what you see below is known to be well-formed.

msbuild-project.xml
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="System.Text.Json" Version="8.0.4"/>
  </ItemGroup>
  <Target Name="Stamp" AfterTargets="Build">
    <Message Importance="high" Text="Built $(AssemblyName)"/>
  </Target>
</Project>

Get started

Bring order to the XML your team can't afford to ignore.

Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.