WindowsAppSDK: AnyCPU Class Libraries no longer supported
Describe the bug Since 0.8.0-preview (and RC as well), we’re blocked from building .NET class libraries, because the AnyCPU check is not only applied to applications, but also against class libraries. Class libraries has no problem being Any CPU - this limitation should not be enforced here, as this is a runtime limitation, not a compile time limitation.
Steps to reproduce the bug
- Create the following project:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ProjectReunion" Version="0.8.0-rc" />
<PackageReference Include="Microsoft.ProjectReunion.Foundation" Version="0.8.0-rc" />
<PackageReference Include="Microsoft.ProjectReunion.WinUI" Version="0.8.0-rc" />
</ItemGroup>
</Project>
- Compile
- Observe the following error:
Error This version of WinUI does not support AnyCPU. Either set Platform or PlatformTarget to one of the following: x86, x64, or arm64. MyClassLib C:\Users\mn.nuget\packages\microsoft.projectreunion.winui\0.8.0-rc\buildTransitive\Microsoft.WinUI.targets 15
This is the culprit in that targets file:
<Target Name="ValidateWinUIPlatform"
Condition="'$(_WinUIPlatformTarget)' == 'ARM' or '$(_WinUIPlatformTarget)'=='AnyCPU'"
BeforeTargets="PrepareForBuild">
<Error Text="This version of WinUI does not support $(_WinUIPlatformTarget). Either set Platform or PlatformTarget to one of the following: x86, x64, or arm64." />
</Target>
The condition should be updated to exclude library:
Condition="'$(_WinUIPlatformTarget)' == 'ARM' or '$(_WinUIPlatformTarget)'=='AnyCPU' AND '$(OutputType)'!='Library' "
Otherwise this is a showstopper for .NET components.
Expected behavior Compiles just fine. AnyCPU only prevented for applications.
NuGet package version: 0.8.0-preview and 0.8.0-rc
Windows 10 version | Saw the problem? |
---|---|
Insider Build (xxxxx) | |
May 2020 Update (19041) | |
November 2019 Update (18363) | |
May 2019 Update (18362) | |
October 2018 Update (17763) |
Additional context
This is somewhat related to #893 but that one pertains to runtime support of apps, this is just compile time of components.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (10 by maintainers)
If you are willing to modify your local nuget cache and you are using 0.8-preview or 0.8-rc, you can remove the reference to Microsoft.ProjectReunion.Bootstrap.dll in Microsoft.ProjectReunion.Bootstrap.targets in Microsoft.ProjectReunion.Foundation package. In addition, remove the check of AnyCPU in ValidateWinUIPlatform task in Microsoft.WinUI.targets in Microsoft.ProjectReunion.WinUI package.
@gmurray81 that change was supposed to be a quick workaround for 0.8-rc, and was abandoned. There are different fixes in internal repo for 0.8 GA.