Open filipnavara opened 4 years ago
/cc @swaroop-sridhar @jeffschwMSFT
@sbomer
I'm running into the same issue, is there any plan to fix this in the .NET 5.0 time frame?
You can use explicit FrameworkReference to WindowsForms.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<!-- Use explicit -->
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
</PropertyGroup>
<ItemGroup>
<!-- .NET Runtime -->
<FrameworkReference Include="Microsoft.NETCore.App" />
<!-- Windows Forms -->
<FrameworkReference Include="Microsoft.WindowsDesktop.WindowsForms” />
</ItemGroup>
</Project>
I use this technique in my project to prevent adding Windows Forms assemblies to Console application https://habr.com/ru/post/549530/
For .NET 6 and 5 When I specify UseWinForms
to true in project it should exclude referencing the wpf assemblies entirely unless you also set UseWPF
to true as well.
Moved from https://github.com/dotnet/winforms/issues/2426. Related: https://github.com/mono/linker/issues/832
Problem description:
dotnet new
or VS)Actual behavior:
Published output contains large part of WPF stack (eg. PresentationCore.dll, PresentationUI.dll, PresentationFramework*.dll, etc.) which amounts to over 30 Mb (> 10 Mb compressed) of unused assemblies. The files are pulled from the "runtimepack.Microsoft.WindowsDesktop.App.Runtime.win-x86/3.0.0" NuGet package.
Expected behavior:
No WPF assemblies in the output. They should either not be included or they should get trimmed out.
Minimal repro:
WindowsFormsApp1.zip