1

Specifically, using Visual Studio Community 2019, on a WPF .NET Core 3.1 app, how can I use the exe file from the bin/debug folder without the app.dll and app.runtimeconfig.json.

Basically I only want to pass the app.exe file only from the debug folder to someone also on Windows 10 and Windows Server 2012 R2(AWS EC2 windows) and have the app run.

The reason I want to use the debug app.exe is because it is <200kb vs the publish as single trimmed file which gives me a ~180mb file... which for some reason wouldn't run anyways?

Following How to build App without App.runtimeconfig.json? gave me the single 180mb file on publish that wouldn't run. Following .Net whole application as a single .exe file? made my app.dll go up 20kb and I still needed it.

Is it possible to be able to do this even? If so how can I get to be able to distribute the <200kb app.exe only without any other files from the debug folder?

EDIT: The app isn't actually done and all it has is basically an empty cs file with an xaml that has a few components on it (textblocks, textboxes, buttons, stacks, a datagrid, etc) How does this result in a 180mb published file I have no idea. Also I am new to WPF, just coming from Winforms where I can easily distribute the debug exe file and have it run everywhere.

ouflak
  • 2,458
  • 10
  • 44
  • 49
Ranald Fong
  • 401
  • 3
  • 12

2 Answers2

2

You have created self-contained build which contains all the .NET library. That's why your resulting build is 180MB.

Check this: One Click

ouflak
  • 2,458
  • 10
  • 44
  • 49
  • I looked around at the publish settings and I did indeed have the Deployment Option as self-Contained. When I set it to framework-Dependent it gave me a 200kb file that actually worked instead of a 180mb file that didnt. Also that one exe file could be run and worked without any dll or config file. But do you have an answer for if a similar thing can be done with the debug exe file? – Ranald Fong Dec 06 '21 at 08:34
1

The main difference between a framework-dependent deploy and a self-contained one is that the former requires you to pre-install the .NET Core runtime before you can run your app.

In a self-contained deploy, your app includes the runtime which is why the file is a lot larger.

Please refer to the docs for more information about the differences and advantages and disadvantages of the two publishing modes.

To publish an app that targets .NET Core 3.1 and is created using the WPF Application template in Visual Studio, you right-click on the app in the solution explorer and choose "Publish..." and select "Folder" as the target.

You can then change the deployment mode setting depending on whether you want a framework-dependant (smaller) or self-contained (larger) output.

If you choose self-contained, there is an additional "Produce single file" option that you can tick to end up with a single .exe file that can be x-copy deployed to another machine. Make sure that you copy the contents of the publish folder (and not the contents of the build folder).

mm8
  • 163,881
  • 10
  • 57
  • 88
  • Is there no way to have a similar thing happen for the exe file in the debug folder? The 2 answers I got here so far seem to gloss over that question and go straight to explaining or pointing to what happened with publish. Without really explaining publish either... (And also glossing over why the self-contained exe doesn't even work, but I don't mind as I am not going to deal with a 180mb file whether it works or not for a hello world app). – Ranald Fong Dec 07 '21 at 04:36
  • The exe file in the debug folder is not an artifact that can/should be deployed to another machine. As I mentioned, it's the contents of the publish folder that counts. What exactly is your question then? – mm8 Dec 07 '21 at 18:36
  • You're right, I guess my actual question is the title which was answered. Thank you. I will do my research on Debug vs Release vs Publish. – Ranald Fong Dec 09 '21 at 05:29