Bala P
Bala P

Reputation: 91

WPF Application as Portable Exe or Single Exe file

We developed an application based on WPF. We are able to successfully deploy an application using installer.

Is there any way can we avoid the installation? Is it possible to use the application as Single Executable file without installation?

Upvotes: 8

Views: 17572

Answers (4)

Noman_1
Noman_1

Reputation: 530

Just publish your app and to create a single exe file:

  • Right click your Startup project and select "Publish".
  • On the publish view, unfold the "File publish options" and select "Produce a single file".

This will produce a single exe but will still be dependant on having Runtime of .Net Core on the client (Can be downloaded from here: .Net downloads page).

If you want it fully non dependant, you can select on "Deployment mode" dropdown "Self contained". This option will add ~150MB on your .exe file but the client doesn't need the .Net Core anymore as far as I know.

In such case I'm unaware of XP compatibility as .Net Core is supported from Win7 forward. I would appreciate any info about that if anyone tests it.

Furthermore, I have not tested this with Resources or any other kind of dependencies other than dll files.

Tested on Visual Studio Community 2019, project created as "WPF App (.Net Core)" and having as a dependency a project created as "Class library (.Net Standard)"

Upvotes: 4

Felice Pollano
Felice Pollano

Reputation: 33272

If you have the framework installed with a compatible version on the target machine, the answer is yes, but you have to care about dependencies. If you don't depend on something in the GAC, xcopy your bin directory on the target would work. If you really want a single .exe file, use ILMerge to pack all the assembly in a single one.

Upvotes: 1

Ujjwal
Ujjwal

Reputation: 496

You can use ILMerge to merge dependencies to your executable or main assembly. It will be merge all dependent assemblies and create single assembly file which you can deploy.

There are various links available on how to use it (like this)

Update : With WPF application, there is one issue while loading assmblies runtime. this link provides resolutions for it.

Upvotes: 2

Sheridan
Sheridan

Reputation: 69985

If your WPF Application consists of a single project, then you can just distribute the .exe file from your project's bin folder that is generated when you build the project. Clicking on it will start your application.

If it is just for private use, then this may be acceptable, but it would be very unprofessional to do that for any other project. Either way, what you do is up to you and you can find the executable DLL in one of the following locations, depending on your current Solution Configuration:

AppName > ProjectName > bin > Debug
AppName > ProjectName > bin > Release

AppName > ProjectName > bin > x86 > Debug
AppName > ProjectName > bin > x86 > Release

... or similar.

Upvotes: 1

Related Questions