Headless.NET.Sdk.Test 0.3.0

<Sdk Name="Headless.NET.Sdk.Test" Version="0.3.0" />
                    
For projects that support Sdk, copy this XML node into the project file to reference the package.
#:sdk Headless.NET.Sdk.Test@0.3.0
                    
#:sdk directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.

Headless.NET.Sdk.Test

The Microsoft Testing Platform wrapper: Microsoft.NET.Sdk plus the complete Headless build baseline and test classification. It is available to any compatible .NET project and is not specific to Headless Framework.

Use

Headless does not restrict TargetFramework; the Microsoft SDK, Microsoft Testing Platform, and the consumer-selected test framework determine compatibility.

The SDK supplies the MTP host extensions; the consumer chooses its test framework:

<Project Sdk="Headless.NET.Sdk.Test/x.y.z">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="xunit.v3.mtp-v2" Version="3.2.2" />
  </ItemGroup>
</Project>

Direct PackageReference consumption uses Microsoft.NET.Sdk:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Headless.NET.Sdk.Test" Version="x.y.z" PrivateAssets="all" />
    <PackageReference Include="xunit.v3.mtp-v2" Version="3.2.2" />
  </ItemGroup>
</Project>

When dotnet test runs under the .NET 10 SDK, the repository must select Microsoft Testing Platform in global.json. Add this top-level entry alongside the existing sdk configuration:

{
  "test": {
    "runner": "Microsoft.Testing.Platform"
  }
}

Without it, .NET 10 routes dotnet test through VSTest and the MTP project rejects the command. This is a command-host requirement, not a restriction on the test project's TargetFramework.

Additional-SDK, global.json MSBuild SDK resolution, and .NET 10 #:sdk Headless.NET.Sdk.Test@x.y.z consumption are also supported. See the family consumption reference.

Coverage settings

The package owns the coverage denominator policy in configurations/default.runsettings. HeadlessCoverageSettingsPath evaluates to the absolute path of that packaged file. When a project-evaluated test run sets EnableCodeCoverage=true, the SDK adds --coverage and exactly one --coverage-settings argument using that property.

Microsoft Testing Platform's --test-modules mode runs prebuilt assemblies without project evaluation, so it cannot receive SDK-injected TestingPlatformCommandLineArguments. External build tooling should query the project, capture the single-line result, and pass the value explicitly:

dotnet msbuild tests/MyProject.Tests/MyProject.Tests.csproj -getProperty:HeadlessCoverageSettingsPath -nologo -v:quiet
dotnet test --test-modules 'tests/**/bin/Release/**/*.Tests.dll' --root-directory <repository-root> --minimum-expected-tests 1 --coverage --coverage-settings "<value-from-the-command-above>"

Resolve the property from one representative test project after restore. Treat the result as a fully qualified path and verify that it exists before invoking the module runner; do not copy or maintain a consumer-owned runsettings file.

Test contract

  • Executable MTP host by default, with IsTestProject=true, IsPackable=false, and IsPublishable=false.
  • Microsoft Testing Platform only; VSTest and Microsoft.NET.Test.Sdk are not injected.
  • Restore-visible crash dump, hang dump, hot reload, retry, TRX, and coverage extensions.
  • Default TRX output, crash and hang dumps, and a minimum expected test count.
  • Coverage enabled on CI, with HeadlessCoverageSettingsPath exposing the packaged denominator policy, and analyzer work skipped during the test-build phase unless explicitly retained.
  • Mandatory Headless analyzer infrastructure, configurable banned-API policy, and mandatory audit and CI policies with narrow test-code severity relaxations.

The package is self-contained and ships no buildTransitive assets. Shared harness libraries can instead use IsTestHarnessProject=true with the base SDK to receive test analysis defaults without becoming executable test hosts.

The SDK owns the versions of its six implicit MTP extensions. Central Package Management consumers must not declare PackageVersion entries for those extension IDs; test-framework versions remain consumer-owned and centrally manageable.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.0 30 8/9/2026
0.2.1 60 8/3/2026
0.2.0 81 8/2/2026