dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.75k stars 1.07k forks source link

Both options for creating .NET 6 WinForms builds have serious show stoppers #22763

Open TangibleDave opened 3 years ago

TangibleDave commented 3 years ago

I would prefer to create a single-file self-contained install for a WinForms application using .NET 6. However, the removal of trimming in .NET 6 for WinForms applications means that the size of the install is impractical (>100MB - that's just insane for our utilities). With trimming in .NET 5, the size was large, but acceptable.

The "framework-dependent" option is also not practical due to the critical error message (red 'x', etc.) that comes up if .NET 6 is not already installed. This will always scare off a certain percentage of users.

I would like either:

  1. trimming restored for WinForms applications in .NET 6 (it worked fine in .NET 5) or:
  2. the critical error message for installing .NET 6 reworked to something less scary for less sophisticated users

As it is, there is no way I can publish .NET 6 versions of our utilities.

RussKie commented 3 years ago

There're other options too, e.g. https://github.com/Tyrrrz/DotnetRuntimeBootstrapper.

The trimming is not currently supported for Windows Desktop apps due to an extensive dependence on COM and reflection, which are not trim-safe (https://github.com/dotnet/winforms/issues/4649). And if it worked it would be "accidental" (https://twitter.com/andygocke/status/1455320377387732994). I raised an issue for the docs to be updated to reflect the current state https://github.com/dotnet/docs/issues/27274.

AFAIK this is being worked on, and if all goes well desktop apps may be trimmable in .NET 7.

Moving to the SDK to consider the error message feedback.

TangibleDave commented 3 years ago

DotnetRuntimeBootstrapper looks promising, but it adds another reliance on a third party tool (with its unknown security risks and unpredictable support).

sfoslund commented 3 years ago

@baronfel do you have any thoughts on the critical error message feedback?

baronfel commented 3 years ago

For posterity, here's a snap of what the missing-runtime error looks like on Windows 11 when you run a framework-dependent winforms app (and presumably any framework-dependent app?):

image

If you click 'yes' there, you get dropped on this page:

image

I've been using .NET (Core) since it released, and I don't know what the correct answer is in that case. I'm guessing the 'desktop' runtime here, but end users who get this message box aren't going to know that. I definitely think there's room for improvement here, but I'm not sure who owns each part of that experience.

TangibleDave commented 3 years ago

I can't see how that's acceptable - if I try to install a Java application and don't have Java installed I don't think it's this ugly.

RussKie commented 3 years ago

image

IIRC (it's been a while) but if a user lacked a specific .NET Framework version (e.g. 3.5) by clicking "Yes" we'd start a download of NETFx 3.5 runtime. Perhaps we could somehow do the same - we do know what OS and bitness an app is being run on (e.g. Window 10, arm64) and what SDK the app is targeting (e.g. a Console or Windows Desktop), and we could deduce a download link from this information.

baronfel commented 3 years ago

Perhaps we could somehow do the same - we do know what OS and bitness an app is being run on (e.g. Window 10, arm64) and what SDK the app is targeting (e.g. a Console or Windows Desktop), and we could deduce a download link from this information.

That would be great to get back to that experience. This is a apphost-level thing (see the error dialog code here), so tagging @richlander for input here.

kant2002 commented 3 years ago

AFAIK this is being worked on, and if all goes well desktop apps may be trimmable in .NET 7.

@RussKie who is this lovely person whom I should send infinite hugs? Just want to track progress if possible.

nicko88 commented 2 years ago

AFAIK this is being worked on, and if all goes well desktop apps may be trimmable in .NET 7.

Any progress on this with .NET 7 Preview 1 released recently?

I am also still using .NET 5 because it works to trim my WinForms app and is way smaller (like 3x smaller) than compiled with .NET 6.