Describe the bug
WAP project will place all referenced project into separate output directory if WindowsAppSDKSelfContained set to false
WAP_Output_Directory
├── CsWinRTProject // for example: IBackgroundTask
│ ├── ......
└── WinRTCOMServer
├── ......
Things changed if WindowsAppSDKSelfContained set to true. WAP project will place all referenced project into same output directory.
WAP_Output_Directory
├── ...... (CsWinRTProject)
└── ...... (WinRTCOMServer)
Consider a scenario:
CsWinRTProject
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsTrimmable>true</IsTrimmable>
<RootNamespace>CsWinRTProject</RootNamespace>
</PropertyGroup>
<PropertyGroup Label="CsWinRTInformation">
<CsWinRTComponent>true</CsWinRTComponent>
<CsWinRTWindowsMetadata>$(TargetWindowsVersion)</CsWinRTWindowsMetadata>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
WinRTCOMServer
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<SelfContained>true</SelfContained>
<IsAotCompatible>true</IsAotCompatible>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TrimmerSingleWarn>false</TrimmerSingleWarn>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<RootNamespace>WinRTCOMServer</RootNamespace>
<CsWin32RunAsBuildTask>true</CsWin32RunAsBuildTask>
<DisableRuntimeMarshalling>true</DisableRuntimeMarshalling>
</PropertyGroup>
<PropertyGroup Label="CsWinRTInformation">
<CsWinRTComponent>true</CsWinRTComponent>
<CsWinRTWindowsMetadata>$(TargetWindowsVersion)</CsWinRTWindowsMetadata>
</PropertyGroup>
<PropertyGroup Label="Optimization" Condition="'$(Configuration)' == 'Release'">
<PublishAot>true</PublishAot>
<PublishTrimmed>true</PublishTrimmed>
<OptimizationPreference>Speed</OptimizationPreference>
</PropertyGroup>
<ItemGroup Condition="'$(PublishTrimmed)' == 'true'">
<TrimmerRootAssembly Include="WinRTCOMServer" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWin32">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.CsWinRT">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
if CsWinRTProject outputs a .dll file but WinRTCOMServer outputs an exe file. However, WinRTCOMServer build with SelfContained=true, but CsWinRTProject isn't. SettingWindowsAppSDKSelfContained=true on WAP project will force those two projects being placed on same directory instead of place them into separate directory. Which cause conflict and might override files with same name.
To run CsWinRTProject using backgroundTaskHost.exe require the CsWinRTProject must not SelfContained. Due to the conflict, I believe CsWinRTProject's WinRT.Host.dll might be overrided by the WinRTCOMServer and therefore, it was changed and will run in SelfContained mode.
backgroundtaskhost initialization for self-contained components is not supported
Workaround:
Set WindowsAppSDKSelfContained to false
Steps to reproduce the bug
Described above
Expected behavior
WAP should place all the project into separate directory in output directory even WindowsAppSDKSelfContained is true
Screenshots
No response
NuGet package version
1.8.260317003
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 24H2 (26100, June 2025 Update)
IDE
Visual Studio 2022
Additional context
No response
Describe the bug
WAP project will place all referenced project into separate output directory if
WindowsAppSDKSelfContainedset to falseThings changed if
WindowsAppSDKSelfContainedset to true. WAP project will place all referenced project into same output directory.Consider a scenario:
CsWinRTProject
WinRTCOMServer
if CsWinRTProject outputs a .dll file but WinRTCOMServer outputs an exe file. However, WinRTCOMServer build with
SelfContained=true, but CsWinRTProject isn't. SettingWindowsAppSDKSelfContained=trueon WAP project will force those two projects being placed on same directory instead of place them into separate directory. Which cause conflict and might override files with same name.To run CsWinRTProject using
backgroundTaskHost.exerequire the CsWinRTProject must not SelfContained. Due to the conflict, I believe CsWinRTProject's WinRT.Host.dll might be overrided by the WinRTCOMServer and therefore, it was changed and will run in SelfContained mode.Workaround:
Set
WindowsAppSDKSelfContainedto falseSteps to reproduce the bug
Described above
Expected behavior
WAP should place all the project into separate directory in output directory even
WindowsAppSDKSelfContainedis trueScreenshots
No response
NuGet package version
1.8.260317003
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 24H2 (26100, June 2025 Update)
IDE
Visual Studio 2022
Additional context
No response