WindowsAppSDK: AnyCPU Class libraries are broken again
Describe the bug
Internal bug https://microsoft.visualstudio.com/OS/_workitems/edit/36498869
When building an AnyCPU class library, the build is broken again. Since it’s not an application, the architecture runtime limitation shouldn’t be in effect.
The issue appears to be due to an incorrect condition in microsoft.windowsappsdk.foundation\1.0.0-experimental1\build\Microsoft.WindowsAppSDK.Bootstrap.targets
:
<Target Name="BinPlaceBootstrapDll" Condition="'$(AppxPackage)' != 'true'" AfterTargets="Build">
<Copy SourceFiles="$(MSBuildThisFileDirectory)..\runtimes\lib\native\$(_WindowsAppSDKFoundationPlatform)\Microsoft.WindowsAppSDK.Bootstrap.dll" DestinationFolder="$(OutDir)" OverwriteReadOnlyFiles="true" ContinueOnError="false"/>
</Target>
A class library isn’t an AppxPackage, but it isn’t a running application either.
Steps to reproduce the bug
Compile a class lib using reunion:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows10.0.18362.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0-experimental1" />
</ItemGroup>
</Project>
Observe the error:
1>C:\Users\mn.nuget\packages\microsoft.windowsappsdk.foundation\1.0.0-experimental1\build\Microsoft.WindowsAppSDK.Bootstrap.targets(11,5): error MSB3030: Could not copy the file “C:\Users\mn.nuget\packages\microsoft.windowsappsdk.foundation\1.0.0-experimental1\build..\runtimes\lib\native\AnyCPU\Microsoft.WindowsAppSDK.Bootstrap.dll” because it was not found.
I managed to fix it locally by editing the above condition in the nuget package to this:
Condition="'$(AppxPackage)' != 'true' AND !('$(_WindowsAppSDKFoundationPlatform)' == 'AnyCPU' AND '$(OutputType)'=='Library') "
Expected behavior Application compiles without error
Version Info
NuGet package version: 1.0.0-experimental1
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
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 7
- Comments: 22 (9 by maintainers)
Commits related to this issue
- Moved Bootstrap dll to fix task https://task.ms/33477857 #1217 and maybe #893 — committed to microsoft/WindowsAppSDK by DrusTheAxe 3 years ago
- Moved Bootstrap dll to fix VS/AnyCPU projects (#1282) * Moved Bootstrap dll to fix task https://task.ms/33477857 #1217 and maybe #893 * Fixed typo — committed to microsoft/WindowsAppSDK by DrusTheAxe 3 years ago
I’ve came up with a workaround. Not sure if it will work on all cases, but it is working for the WCT.
You also need to add the
GeneratePathProperty="true"
to yourPackageReference
to the Microsoft.WindowsAppSDK nuget, like this:This is blocking: https://github.com/CommunityToolkit/WindowsCommunityToolkit/issues/4171
Temporary workaround I found:
Confirmed!
AnyCPU isn’t fixed yet. Here’s the set of events to address that https://github.com/microsoft/WindowsAppSDK/pull/1498#discussion_r719735938