Skip to content

.Net Core 3.0 – What’s new

Microsoft released with .net core 3.0 the next major version of .net core which brings improvements to the deployment, .net core WPF and WinForms applications and much more. Today, I want to showcase some of these new features.

Build and Deployment Improvements

.net core used to create a dll as an output, even for a console application. Starting with .net core 3.0, an exe file is created by default. The downside of the default behavior is that it copies all dependencies into the output folder which can be hundreds of files in a bigger application.

Single File Executables

A pretty neat feature of .net core is that you can create a single file executable that contains all dependencies. This makes the output way clearer. To create a single file executable, you only have to add the RuntimeIdentifier and PublishSingleFile in your csproj file.

Configure your application to publish as a single file

The RuntimeIdentifier tells the compiler for what operating system it should create the executable. This could be, for example, win10-x64 or win10-x86. Creating a single file will make the executable way bigger since all the dependencies are packed into the file.

Everything got packed into the executable
Everything got packed into the executable

Trim the publish output

To reduce the size of your published output, you can trim it. Trimming removes not needed dependencies.

To configure ready to run, you only have to add the PublishedTrim tag to your csproj and set it to true.

Remove not needed dependencies before the publish
Remove not needed dependencies before the publish

Be careful though because if you work with reflections, dependencies might get removed although you need them. You have to test your application before using it.

The executable is much smaller after the trim
The executable is much smaller after the trim

Ready to run publish

With .net core 3.0, you can create ready to run executables. This uses ahead of time compilation, to have better startup time because it contains the native code and .net intermediate code. The additional .net intermediate code might make the executable bigger.

To configure ready to run, you only have to add the PublishReadyToRun tag to your csproj and set it to true.

Publish your .net core 3.0 application ready to run
Publish ready to run

.Net Core 3.0 removes JSON.Net

.Net Core 3.0 introduces the new Namespace System.Text.Json. Until now JSON.Net was the standard JSON library for .net applications and also .net core depends on it. With .net core 3.0, the namespace System.Text.Json was introduced to remove this dependency. The classes in this namespace are super fast and need only a low amount of ram. The downside is that they are not feature-rich yet. This should change in future versions. You don’t have to use them but you can.

.Net Core 3.0 goes Desktop

With .net core 3.0, you can now create WPF and WinForms applications. Currently, they are Windows only and the tooling needs a bit more work but new desktop applications can and should use .net core. Visual Studio provides a template for the .net core WPF application.

Create a WPF .Net Core 3.0 Application
Create a WPF .Net Core Application

After the application is created, you can see in the csproj file that it is a WPF application and used .net core 3.0

csproj file of the .Net Core 3.0 WPF project
csproj file of the .Net Core WPF project

The tooling is not perfect yet but if you need additional UI controls you can use the Microsoft.Toolkit.Wpf.UI.Controls namespace for WinUI features. With this namespace you can, for example, draw in a canvas in your application.

The .net core application can be built as an MSIX package which will contain most of the needed references and can be distributed via the Microsoft Store. You can find the demo .net core WPF application on GitHub.

Additional Features in .Net Core 3.0

There are many more new features in .net core 3.0 like:

  • Platform-dependent Intrinsics: provide access to hardware-specific instructions and can improve performance
  • Cryptography improvements: The new ciphers AES-GCM and AES CCM were added.
  • HTTP/2 support: Note HTTP/2 is not enabled by default.
  • Serial Port support for Linux
  • Improved Garbage Collector

Conclusion

.net core is great and with the new version, it got even better. My favorite new features are the features around the improved deployment. Also, the new namespace for JSON is nice, although not production-ready yet if you have complex requirements. I am not a desktop developer but I guess that .net core 3.0 is a major game-changer for desktop developers.

You can find the code of today’s demo on Github.

Published inProgramming

One Comment

  1. ExoRank ExoRank

    Awesome post! Keep up the great work! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *