Self-contained deployment of WinForms always includes WPF assemblies
See original GitHub issueMoved from https://github.com/dotnet/winforms/issues/2426. Related: https://github.com/mono/linker/issues/832
- .NET Core Version: 3.0; 3.1
- Have you experienced this same bug with .NET Framework?: No
Problem description:
- Create a simple WinForms application (either through
dotnet new
or VS) - Add Publish profile, change it from “framework dependent” to “self-contained”
- Enable PublishTrimmed
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:
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Create a single file for application deployment - .NET
The size of the single file in a self-contained application is large since it includes the runtime and the framework libraries.
Read more >3 Ways to Deploy a WinForms or WPF .NET Core Application
This post will help you deploy and bring your finished app to your users. .NET Core 3 gives us three ways to deploy...
Read more >[RESOLVED] .NET 6 Winform App with Setup & ...
To deploy a Winforms app developed using .NET 6 using the Visual Studio Installer (Setup & Deployment project), you have to trick the...
Read more >c# - Possible to ship my application with a local copy of the ...
NET 7 applications (Console and WinForms) that all sit in the same folder of a product of mine, I try to find a...
Read more >Deploy .NET Applications | WPF Controls
Self-Contained Deployment. Published application includes all its dependencies and the .NET runtime. This mode allows you to deploy your application to any ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For .NET 6 and 5 When I specify
UseWinForms
to true in project it should exclude referencing the wpf assemblies entirely unless you also setUseWPF
to true as well.You can use explicit FrameworkReference to WindowsForms.
I use this technique in my project to prevent adding Windows Forms assemblies to Console application https://habr.com/ru/post/549530/