Description
What's wrong
Sdk/Sdk.props:556 clears TargetFramework unconditionally:
<TargetFramework></TargetFramework>
<TargetFramework Condition="$(IsTestProject) == 'true'">net10.0</TargetFramework>Directory.Build.props is imported by Microsoft.Common.props (via Microsoft.NET.Sdk's props) before ktsu.Sdk's Sdk.props runs. So a repository that writes <TargetFramework>net10.0</TargetFramework> in its Directory.Build.props, to make every project single-target, loses that value when this line clears it. The project then multi-targets the default TargetFrameworks (net10.0;net9.0;net8.0;netstandard2.0;netstandard2.1). There is no warning. Only a TargetFramework written in the csproj body, which is evaluated after Sdk.props, has any effect. The extension SDKs' Sdk.props set TargetFramework without a condition too, so adding an "only if empty" guard there would do nothing: the core has already cleared the value by then.
This is not tracked anywhere yet. #91 covers package metadata properties overwritten from Directory.Build.props, and #55 / #72 cover test projects. None of them covers TargetFramework for libraries and apps.
Plan reference
The .NET 11 readiness spec deferred this on purpose and said it needs its own change.
docs/plans/dotnet-11-readiness.md L207-L222 @ 96df23f:
Sdk/Sdk.props's unconditional<TargetFramework></TargetFramework>clear … setsTargetFrameworkto an empty value. … a consumer settingTargetFrameworkinDirectory.Build.propsis silently overwritten, and only a setting in the csproj body survives. … Fixing it properly means stopping the core from clearing, which is a behavior change … That deserves its own change, not a ride along with a version bump.
What exists today: the unconditional clear at Sdk/Sdk.props:556 and the unconditional TargetFramework assignments in the extension SDKs' Sdk.props. Nothing detects or reports an overwritten value.
What's missing: a way for a value set in Directory.Build.props to survive, or at minimum a diagnostic when it is discarded.
Why it matters
A maintainer who wants a repository on one framework, for example an app repo or an experiment on net11.0 previews, puts TargetFramework in Directory.Build.props the usual MSBuild way. The build then quietly produces five framework assets, takes several times as long, and can fail on APIs the lower targets lack. Nothing points to the cause.
Suggested fix / acceptance criteria
Choose one of these approaches:
- Honour it. Make the core clear conditional on
TargetFrameworknot having been set beforeSdk.props. Capture the incoming value first, the waySdk.propsalready records defaults forSdk.targetsto compare against. The extension SDKs then respect a pre-set value too. - Diagnose it. Keep clearing the value, but record it first, and raise a KTSU warning or error naming
Directory.Build.propswhen it was non-empty.
Either way:
- There is a regression test in
test/Sdk.Examples.Testsfor aDirectory.Build.propsthat setsTargetFramework, on the core SDK and on at least one extension SDK. It asserts option 1's single-target result, or option 2's diagnostic. - README and CHANGELOG call out the behaviour change. With option 1, any repository that has
TargetFrameworkin aDirectory.Build.propstoday switches from multi-targeting to single-targeting.
Dependencies: none. This fits with #91, the same "Directory.Build.props value is overwritten" family. It is independent of the .NET 11 flip (#57).
Activity
matt-edmondson commentedon Nov 5, 2026
Triage
TargetFrameworkin the csproj body works around it.Sdk.propstarget-framework defaults, core and extension SDKs<TargetFrameworks>still builds only net10.0 unless<TargetFramework></TargetFramework>is also cleared (#51 follow-up) #55 / IsTestProject=true from Microsoft.NET.Test.Sdk or Directory.Build.props is overwritten, so a test project not named <TestProjectName> multi-targets netstandard and fails to build #72 (test projects). Fixing it with PackageProjectUrl, PackageDescription, PackageTags and ContinuousIntegrationBuild set in Directory.Build.props are silently overwritten by Sdk.props #91 would let one behaviour-change note cover both. It is independent of .NET 11 flip (due 2026-11-10): the Task 6 checklist misses Sdk.Web, Sdk.Godot and validate-platform-sdks.sh, so following it leaves net10.0 pins behind #57.TargetFrameworkinDirectory.Build.propstoday, so the release needs a minor bump or higher and a CHANGELOG callout.Generated by Claude Code