How to Deploy a .NET Core WPF App

WPF Team Blog
11 November 2019

OTHER RELATED ARTICLES:

  1. WPF - Visual Studio Integration and Designer Support in .NET Core 3.0
  2. Getting Started with DevExpress WPF Controls for .NET Core
  3. Migrate WPF Apps to .NET Core
  4. THIS POST: How to Deploy a .NET Core 3 WPF App

In this blog post, we'll describe how you can publish an application using Visual Studio tools.

The Process

.NET Core 3 allows you to publish WPF applications in the following ways:

  • Framework-Dependent Executable

    In this mode, your application is published with its dependencies. The .NET Core runtime is not included. The deployed application is dependent upon the .NET Core runtime installed on the target machine.

    Use this approach if you wish to deploy your application to workstations with the .NET Core 3 runtime already installed.

  • Self-Contained Deployment

    In this mode, your application does not depend on the .NET Core runtime installed on the target machine. .NET Core runtime and all application dependencies are included into the distribution.

Publish in Visual Studio

To publish an application, right-click the project file and select Publish.

At the first run, create a new publish profile:

Click Edit Configuration:

In the Profile Settings window, select the required Deployment Mode and click Save:

Click Publish to publish your app to the specified folder.

Publish via the Command Line

# <RID> - Runtime Identifier: win-x86, win-x64, etc.
# Framework-dependent executable:
dotnet publish -c Release

# Self-contained deployment:
dotnet publish -c Release -r <RID> --self-contained true

Deployment Options

Single Executable

You can pack your application and all its dependencies (including .NET Core 3 runtime) into a single executable.

To do this, add the following options to your project file:

<PropertyGroup>
  <RuntimeIdentifier>win10-x64</RuntimeIdentifier>
  <PublishSingleFile>true</PublishSingleFile>
</PropertyGroup>

Once you publish the app, you'll see a single executable and a *.pdb for debugging.

Ready to Run Images

Many .NET Framework developers use Ngen.exe to reduce application launch time.

Ngen.exe does not work for .NET Core. But .NET Core 3 allows you to speed up application startup time by compiling your application in a ReadyToRun (R2R) format.

R2R binaries contain native code (similar to what the just-in-time (JIT) compiler produces). This native code reduces the JIT compiler workload during application startup.

To publish an app in the R2R format, set the <PublishReadyToRun> option to true in your project file:

<PropertyGroup>
  <PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>

R2R binaries are larger because they contain both native and IL code.

R2R format is only available for self-contained apps that target specific runtime environments (RID) - such as Windows x86 or Windows x64.

We'd Love to Hear From You

We want to hear from those of you targeting .NET Core 3. Please tell us how you plan on porting your existing projects and how we can better serve your needs during the conversion process.  Feel free to comment below or email us at wpfteam@devexpress.com.

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.