What's the anatomy of a .NET 5 WPF application project?

AxD 661 Reputation points
2021-01-18T00:30:19.217+00:00

From Windows Forms and .NET Console applications I'm used that a single .exe file is enough to run the application.

Now, after I created and built a WPF application using Visual Studio 2019 I realize that XCopying the .exe file alone doesn't suffice.

After consecutively deleting the bin folder's files it looks like three files are the bare minimum:

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---          18.01.2021    01:10       11429376 Test.dll
-a---          18.01.2021    01:10         142848 Test.exe
-a---          18.01.2021    01:10            154 Test.runtimeconfig.json

Why is the main part of the application phased out into a .dll file? What is the runtimeconfig.json file necessary for? Is there an option available to have everything compile into a single .exe file I can share?

PS: Added ".NET 5" to title, so other users may find this question's answers valuable.

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,670 questions
0 comments No comments
{count} votes

Accepted answer
  1. DaisyTian-1203 11,616 Reputation points
    2021-01-18T03:25:37.233+00:00

    You app should be higher than Net Core 3.0, right? If it is, below is my answers for your questions:
    Answer 1: Unlike .NET Framework where the mscoree.dll was used as the COM server, .NET Core will add a native launcher dll to the bin directory when you build your COM component. You can get more info in here.
    Answer 2: When a project is built, an [appname].runtimeconfig.json file is generated in the output directory. Specify run-time configuration options in the configProperties section of the runtimeconfig.json files. For more details, please refer to .NET Core run-time configuration settings.
    Answer 3: You can refer to Publish a single file app - Visual Studio to implement your project into a single file.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Ken Tucker 5,846 Reputation points
    2021-01-18T00:52:37.39+00:00

    I am assuming you are using .net 5 for the app. If follow the steps in this blog post you can compile the app into a self contained file

    https://www.hanselman.com/blog/how-to-make-a-winforms-app-with-net-5-entirely-from-the-command-line-and-publish-as-one-selfcontained-file

    1 person found this answer helpful.
    0 comments No comments