Home > Enterprise >  How do I run a WPF .NET3.1 app without app.dll and app.runtimeconfig.json
How do I run a WPF .NET3.1 app without app.dll and app.runtimeconfig.json

Time:12-06

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.

CodePudding user response:

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

Check this: One Click

CodePudding user response:

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).

  • Related