All Projection.dll in the Windows App SDK are not actively trimmed when a project is partially trimmed
Describe the bug
当设置项目为部分裁剪时,Windows App SDK 所有的Projection.dll 不会主动裁剪。 All Projection.dll in the Windows App SDK are not actively trimmed when a project is partially trimmed.
Steps to reproduce the bug
1.创建一个空白项目模板 2.打开属性,在PropertyGroup中添加 <PublishTrimmed>True</PublishTrimmed>和<TrimMode>partial</TrimMode> 这两个属性。 3.发布项目 4.在MSIX分发下看到,.NET BCL已经被裁剪,而Windows App SDK 的 Projection.dll 没有被主动裁剪,即使Projection.dll 所属的程序集未在项目中使用。
- Create a blank project template
- Open properties and add <PublishTrimmed>True</PublishTrimmed> and <TrimMode>partial</TrimMode> properties to the PropertyGroup.
- Publish the project
- Under the MSIX distribution,.NET BCL has been trimmed, while the Windows App SDK's Projection.dll is not actively trimmed, even if the assembly to which Projection.dll belongs is not used in the project.
Expected behavior
当设置项目为部分裁剪时,Windows App SDK 所有的Projection.dll 会主动裁剪。 All Projection.dll in the Windows App SDK are actively trimmed when a project is partially trimmed.
Windows App SDK 发布时的配置文件,当设置裁剪,裁剪模式为Partial时应该包括以下内容
<TrimmableAssembly Include="Microsoft.InteractiveExperiences.Projection" />
<TrimmableAssembly Include="Microsoft.Management.Deployment.Projection" />
<TrimmableAssembly Include="Microsoft.Windows.ApplicationModel.DynamicDependency.Projection" />
<TrimmableAssembly Include="Microsoft.Windows.ApplicationModel.Resources.Projection" />
<TrimmableAssembly Include="Microsoft.Windows.ApplicationModel.WindowsAppRuntime.Projection" />
<TrimmableAssembly Include="Microsoft.Windows.AppLifecycle.Projection" />
<TrimmableAssembly Include="Microsoft.Windows.AppNotifications.Builder.Projection" />
<TrimmableAssembly Include="Microsoft.Windows.AppNotifications.Projection" />
<TrimmableAssembly Include="Microsoft.Windows.Management.Deployment.Projection" />
<TrimmableAssembly Include="Microsoft.Windows.PushNotifications.Projection" />
<TrimmableAssembly Include="Microsoft.Windows.Security.AccessControl.Projection" />
<TrimmableAssembly Include="Microsoft.Windows.System.Power.Projection" />
<TrimmableAssembly Include="Microsoft.Windows.System.Projection" />
<TrimmableAssembly Include="Microsoft.Windows.Widgets.Projection" />
<TrimmableAssembly Include="Microsoft.WindowsAppRuntime.Bootstrap.Net" />
<TrimmableAssembly Include="WinRT.Host.Shim" />
<TrimmableAssembly Include="WinRT.Runtime" />
When the Windows App SDK is released, the configuration file should include the following contents when trim mode is set to Partial
Screenshots
Project property
White project
Contents of the MSIX installation package after release
.NET BCL has been trimmed, while the Windows App SDK's Projection.dll is not actively trimmed, even if the assembly to which Projection.dll belongs is not used in the project.
NuGet package version
Windows App SDK 1.5.0: 1.5.240227000
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 22H2 (22621, 2022 Update)
IDE
Visual Studio 2022
Additional context
None
The changes to PublishTrimmed are already in the project templates. The issue is that these project templates haven't been made available in Visual Studio yet.
The new template updates are on the way. Scott can help make sure if that is sufficient or if there is more here.
With Windows App SDK 1.6 (currently in experimental release), all projection assemblies are now marked with: [assembly: AssemblyMetadata("IsTrimmable", "True")]
So they will participate in TrimMode partial trimming.