Describe the bug
When publishing a WinUI application using dotnet publish, the process fails if the executable project references another WinUI class library project and WindowsAppSDKSelfContained is set to true.
During publishing, the build system appears to propagate or evaluate the WindowsAppSDKSelfContained setting for the referenced class library as well, which leads to the following error:
WindowsAppSDKSelfContained should not be applied to a class library
This results in the publish operation failing, even though the setting is only intended for the executable project.
Steps to reproduce the bug
- Create two projects WinUI App + WinUI lib
- Add a reference to WinUI lib to WinUI App
- Run command for the WinUI App
dotnet publish --self-contained true -p:RuntimeIdentifier=win-x64 -p:WindowsAppSDKSelfContained=true
Error:
C:\temp\winui\exe>dotnet publish --self-contained true -p:RuntimeIdentifier=win-x64 -p:WindowsAppSDKSelfContained=true
Restore complete (0.7s)
lib net10.0-windows10.0.19041.0 win-x64 failed with 1 error(s) (0.6s) → C:\temp\winui\lib\bin\Release\net10.0-windows10.0.19041.0\win-x64\lib.dll
C:\Users\xy\.nuget\packages\microsoft.windowsappsdk.base\2.0.2-preview\buildTransitive\Microsoft.WindowsAppSDK.Base.targets(20,9): **error WindowsAppSDKSelfContained should not be applied to a class library.**
Expected behavior
The build should pass and the WindowsAppSDKSelfContained shouldn't be applied for the lib projects.
Screenshots
No response
NuGet package version
2.0.0-prev1
Packaging type
No response
Windows version
No response
IDE
No response
Additional context
If I publish it through a profile file then it works:
<?xml version="1.0" encoding="UTF-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Platform>x64</Platform>
<RuntimeIdentifier Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) >= 8">win-x64</RuntimeIdentifier>
<RuntimeIdentifier Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) < 8">win10-x64</RuntimeIdentifier>
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishReadyToRun>True</PublishReadyToRun>
<PublishTrimmed>True</PublishTrimmed>
<TrimmMode>partial</TrimmMode>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
</PropertyGroup>
</Project>
Describe the bug
When publishing a WinUI application using dotnet publish, the process fails if the executable project references another WinUI class library project and WindowsAppSDKSelfContained is set to true.
During publishing, the build system appears to propagate or evaluate the WindowsAppSDKSelfContained setting for the referenced class library as well, which leads to the following error:
WindowsAppSDKSelfContained should not be applied to a class library
This results in the publish operation failing, even though the setting is only intended for the executable project.
Steps to reproduce the bug
dotnet publish --self-contained true -p:RuntimeIdentifier=win-x64 -p:WindowsAppSDKSelfContained=trueError:
Expected behavior
The build should pass and the WindowsAppSDKSelfContained shouldn't be applied for the lib projects.
Screenshots
No response
NuGet package version
2.0.0-prev1
Packaging type
No response
Windows version
No response
IDE
No response
Additional context
If I publish it through a profile file then it works: