Repository navigation
Description
Current behavior 🐛
Since #25836, a project using Uno.Sdk that sets WindowsSdkPackageVersion (in the csproj or as an environment variable) no longer builds for the Windows target:
error NETSDK1230: The WindowsSdkPackageVersion and WindowsSdkPackageMinimumRevision properties cannot both be specified. Remove one or the other.
#25836 added this to Uno.Common.WinAppSdk.targets:
<WindowsSdkPackageMinimumRevision Condition=" '$(WindowsSdkPackageMinimumRevision)' == '' ">87</WindowsSdkPackageMinimumRevision>It doesn't check whether the app already set WindowsSdkPackageVersion, and the .NET SDK rejects having both.
The unoapp template's csproj also has a commented-out <WindowsSdkPackageVersion>10.0.22621.28</WindowsSdkPackageVersion> line suggesting this setting, so uncommenting it hits the error too.
Expected behavior 🎯
An explicit WindowsSdkPackageVersion keeps working, as it did before #25836. The default minimum revision should only apply when the app didn't pick a version.
How to reproduce it (as minimally and precisely as possible) 🔬
- Create a Windows-targeting project with
Uno.Sdk7.1.0-dev.78 or later (a library is enough), for example<TargetFramework>net10.0-windows10.0.26100</TargetFramework>. - Add
<WindowsSdkPackageVersion>10.0.26100.87</WindowsSdkPackageVersion>to the csproj (or set theWindowsSdkPackageVersionenvironment variable). - Run
dotnet build. - The build fails with NETSDK1230.
Results from builds of a Windows-only library:
| Uno.Sdk | WindowsSdkPackageVersion |
Result |
|---|---|---|
| 7.1.0-dev.78 | env 10.0.19041.57 (net10, net11) |
NETSDK1230 |
| 7.1.0-dev.78 | csproj 10.0.26100.87 (net10) |
NETSDK1230 |
| 7.1.0-dev.78 | not set (net10, net11) | builds, uses 10.0.26100.87 |
| 7.1.0-dev.21 | not set | builds |
I also hit it in a real app on 7.1.0-dev.85 with a csproj-level 10.0.26100.86; removing the property clears it. It reproduced on .NET SDK 10.0.100, 10.0.400, and 11.0.100-rc.1 / rc.3. Public Uno.Sdk 7.0.0-dev.173 doesn't have the change.
The cause is confirmed both by these builds and by reading the targets file on current master (permalink below). The release/stable/7.0 branch has the same line, so the #25836 backport carries the problem too.
Workaround 🛠️
Remove WindowsSdkPackageVersion from the project. Setting WindowsSdkPackageMinimumRevision to an empty value should also work (not tested).
Works on UWP/WinUI
N/A (Uno.Sdk build logic).
Affected platforms 📱💻🖥️
Windows (WinAppSDK head) only.
Uno.Sdk version (and other relevant versions) 📦
Uno.Sdk 7.1.0-dev.78 and 7.1.0-dev.85, current master (6aaf325), .NET SDK 10.0.100 / 10.0.400 / 11.0.100-rc.3.
IDE version 🧑💻
CLI (dotnet build).
Anything else we need to know? 💬
Root cause:
uno/src/Uno.Sdk/targets/Uno.Common.WinAppSdk.targets
Lines 22 to 24 in 6aaf325
| <!-- Uno's Windows assemblies are built against the .87 Windows SDK projection (WinRT.Runtime 2.3). The .NET 10 SDK | |
| defaults to .57 (WinRT.Runtime 2.2), which fails with CS1705. A minimum never lowers a newer SDK's default. --> | |
| <WindowsSdkPackageMinimumRevision Condition=" '$(WindowsSdkPackageMinimumRevision)' == '' ">87</WindowsSdkPackageMinimumRevision> |
Suggested fix (not tested): add and '$(WindowsSdkPackageVersion)' == '' to the condition, so an explicit version wins. A version older than .87 would then likely fail with CS1705, per the comment on that line, which is at least the app's own choice.
Seen first in unoplatform/uno.templates CI (unolib_Windows, net10 and net11 groups).
Activity
fix(build): Let Uno.Sdk pick the Windows SDK projection
fix(build): Drop the last two WindowsSdkPackageVersion settings
docs: Remove WindowsSdkPackageVersion when migrating to Uno 7