Categories
Online Marketing

Modernizing .NET Desktop Applications with .NET Core

Thank you for reading this session. My name is olya garish, I’m program manager on dotnet team working on desktop, and today we will talk about modernizing your dotnet desktop applications with dotnet core 3, but first there are many different ways you can modernize or upgrade your applications. It’s not only about how your application looks. It’s also about how it works. How performant it is, what device or platform API is.

It is using. How do you do dev ops? How do you deploy and distribute your application, and this year has been truly amazing year for dotnet desktop, because we got innovations in all of those areas and we don’t talk about all new features available for your desk desktop applications throughout the old dotnet conference. In this talk, we will focus on how you can update your apps with dotnet query 3.

0 and on the day 3. You will have another session by my Cruise’s about more advanced scenarios on porting to dotnet core your WPF applications. How to make your application look modern. How to integrate your application with devices and platform, everything about some old tools and zamel islands will be covered by Dimitri in his talk tomorrow and everything related to dev ops, MSI, X, up Center, so how to capture analytics and diagnostics, how to deploy and distribute your Application you will learn from the talk by daniel and make right after this session so keep tuned, and let’s move to the agenda of this talk first, I would like to start with.

Why should you care about dotnet court for desktop and what to choose that net core or does net framework for your desktop applications? Then I will talk about how you can port your framework application to dotnet core. If you decide so and how to fix porting issues, and then I would like to show you the dotnet desktop tooling, it’s zamel and WinForms designers. So, let’s start, why should you care about the net coiffeur desktop? Well, there are many good reasons, but the most important is because dotnet core is the future of dotnet.

As you probably heard from the keynote dotnet core is a platform that will receive feature updates in the future and in the next year we will release dotnet 5 in November 2020, which will be the next iteration on dotnet court. So by porting, your application to dotnet queer now you’re preparing your app for dotnet 5 to switch from dotnet core to dotnet 5 will be as easy as upgrading it to the next version of the platform.

And if you want your application to incorporate all the new things that will come in future, you want to be on that net core. That is what you should keep in mind when you think about future, but even today there are many great donate core specific things available that are not possible for dotnet framework application. We also talked about it at keynote, so I’ll, just briefly wisdom. Here, it’s a side-by-side deployment of different versions, of.

Net core on the same machine for dotnet framework. You could have only one version and every time you want to switch to the later version of the net framework you had to update it, an application that will run on that machine will have a dependency of that update for developers developers. It usually means that you have to make a company-wide decision run by IT, department which results in delays with dotnet core.

You can update at your own pace because you can have many different versions: of.Net core on the same machine, and you can specify in your application Beach version of.Net core. You would like to target. You can go even further and you can package your dotnet core application with dotnet core platform itself, so you can distribute to your client self-contained application, which will be completely independent on the environment.

It will run on. Another great feature is a single file executable where you can package your application and dotnet core framework in just one big, zip file and a new feature of dotnet core 3 will allow you to trim out assemblies from the network that are not required for your application. So that way, your single exe file will have much smaller size and there are many other great features that you can read about and in future we will receive any moment even more.

So usually I get the question ok. Does that mean I need to port all my existing dotnet framework applications to dotnet core or how do I decide and our advice is usually starting new applications on dotnet core, but if you have a completed apps that are in maintenance mode, only all development is finished. You don’t want to touch that code again, it’s completely fine to leave it on dotnet framework.

In fact we are leaving one of our applications on dotnet framework ourselves. Maybe you have heard of Visual Studio, so doesn” t framework will be fully supported. It will receive all required and security updates. It’s totally fine to leave your apps under the framework. But if your application is an active development and you keep changing the code and you want to benefit from new features that are available on the in.

Net core, you can consider port in your app from dotnet framework to dotnet core, so evaluate how much work. That is what are benefits you will get from dotnet core that are important for your particular case and make the call next question that usually comes up tin. Might how much work is it to port from the core to.Net standard or in other words, how compatible is my app with dotnet core well to find out use pert ability, analyzer? This tool will tell you about all api’s in your code that are not supported with dotnet core 3.

If you have any of those, and it will help you to refactor to find areas that you will need to refactor it to be dotnet core compatible with that. Let me go ahead and show you that pert ability analyzer in action, but first let me show you the application, I’m going to be porting today. So this is a WPF application that it’s called Photo Store. It will allow you to make online purchases of printing goods.

Alright and let’s put this application, run portability analyzer and see if this app is compatible with dotnet cord. So I’m going to specify the path to my project and I will run I will click button analyze. What this analyzer does. It looks at the references in your assemblies and it checks if all api’s that you are using from dotnet framework are present in dotnet core. So, as a result, we will get a pert ability report where, in the first column, you have assembly names, then target framework that they are targeting right now and then how compared compatible.

They are with dotnet court, so hundred-percent compatibility means you’re good to go. If you have less than 100, it means that those assemblies have some api’s that are not fully supported in dotnet core and to learn more details. You can go to details tab and here you will see target type target member assembly where this API is used and so on, but before diving into details tab. I would encourage you to take a closer look at the first tab and actually see what assemblies are not compatible, so, in my case, the lines that have less than 100 % compatibility.

These are not actually my code. This are Newtons of JSON nougat packages that I’m using in my code, so I don’t need to update their api’s right. All that I need to do is to check that the author of the package provides the version that supports dotnet, core or dotnet standard. To do that, you can go on you, get dot, work and just see if it supports dotnet core. I know for sure that Newton solo, JSON supports, does not standard at one point.

That means it automatically support dotnet course. So I’m good to go so again. I don’t need to worry about any of this and everything else is 100 % compatible, so I can go ahead and port my application to dotnet core. Let’s talk about porting, no porting from framework to core is simply updating the value of the target framework parameter in your project file. But if you created your application on dotnet framework – and you did not touch your project file since then, it will have the old-style project file so before updating this value, you first need to migrate to the new, so called is the key style project file.

Let me show you what is old project file? Let’s go back to visual studio and I’m going to unload my project. Then I will click Edit Photo Store, and here we can see a very large XML file right and this, oh, my gosh, so big, and this XML file also has parameters like project GUI like project types, good and etc. That all tells me that this is old project file and before a port in to.Net Court, I will need to update my project file to the latest SDK style, and there are ways how you can pour it to dotnet core manually.

These are the steps how you do it first thing: you search for package, dot config in your solution. If you have this file, you will need to right click and choose migrate packages that config to package reference. Let me show that in Visual Studio I will reload the project, and here I see packages that config. That is where we used to store references to the packages for the old-style project file for the new one they are stored in the project file itself.

So to not lose them, you will need to do right. Click migrate package that config to package reference. Then next step is update. Content of your project file with the new SD key format and the easiest way to do it is to create a blank application target in dotnet core. If you are porting VIN forms of then creative informs targeting dotnet core. If you’re porting WP up then WPF open the project file copy everything from it and paste it in your current project file, but make sure you have the copy of the old project file, because you will need that as well.

It will need that you get all references and resources from your old project file to the new one, so everything related to package reference project, reference, content, resources and so on should be moved to the new project file. Well, it seems like a lot of work and we’ve been constantly asked to please try and automate at least some common steps for all API. So, of course, every application is different and it’s almost impossible to create a silver bullet that will work for everything, but at least we can try to automate most cases and we did that and we created a tool called try can work so what it will do It will try to convert your old project file to the new SDK style project file and it will update the version to the net core 3.

0 to use it. I’r going to just type in the console, try converting Z and as a parameter, I will send the path to my project file. Let’s see okay conversion complete, let’s go back to visual studio, I’m going to reload the files and now, if I right click on properties and go here, I can see that target framework is dotnet core 3. So the tool worked and we successfully converted our dotnet framework application to dotnet core in just a few clicks.

Let’s now run our application and see how that looks so it is low. It looks and feels the same, but right now it’s Runyon on top of dotnet core, instead of doesn’t framework, which means that we can benefit from all the dotnet core features. Okay, I’m going to go back to my slides and this is try convert if you got any pretty bility errors. So if, after porting to donate core, you are getting an error that some assembler is missing, but your part ability report was 100 % compatible was completely green.

That means you can easily fix those errors by just 18. You get package, Microsoft, Windows, dot, compatibility. That package has 21,000 api’s; some of them are Windows only and some of them are cross-platform, and these are areas that those api’s are related to. So with that, I would like to talk about tooling for desktop and let’s go back to my application as you remember that it’s WPF application and we just ported it to doesn’t course.

So if I open Windows, main windows, the demo, you can see the designer and this demo designer it looks very similar to the traditional dotnet framework designer. In fact, you barely can see any differences, but it runs outside of the process. It means that the surface of the designer talks to visual studio, it’s they communicate between two different processes, and it was not very easy for us to implement that so zamel designer is already available in Visual Studio and you can use it.

You can go ahead and port your applications to dotnet quark and try that amazing. As for WinForms designer, we started working on WinForms later than ensemble designer, and it was a huge technical effort for us to really tag the way. How designers surface will talk to the visual studio process so we’re in very early days and today I’m very happy to announce that we are releasing the first preview version of windows forms designer it’s available at this link.

It’s a via visix package and it’s not included in Visual Studio just yet, because it’s still very early days for it and what this first version has. It has a coverage for common controls and base operations, and we will be adding functionality. We will be released. Releasing you preview versions every month. Next one is coming early November and just to let you know, this version is our first start.

So it’s not yet ideal to port your existing applications. It will be good for prototyping and write in hello world with basic common controls. Basically, to see the progress and to give us early feedback, but for your production applications wait till the designer gets more mature and we will definitely let you know when it’s a good time to port your apps to.Net core. So please give us feedback. We’re visual studio blog and let me show you how they win forms designer look, so I’m going to close this and I will create a new VIN forms, application targeting dotnet core search for event forms here and when I click on form one dot CS.

I can see the new VIN forms designer, so when we look at the toolbox, these are the controls that are supported in the first preview version, of course, by the GA of WinForms designer. We will be at functional parity with the traditional framework designer. So all controls will be there and you will have a seamless experience of port in your apps to.Net core right now, it’s just those guys. So we have button check, box, check, clicks, etc.

We can add the controls the same way. We can interact with properties. We can change name and so on. I know that I’m not showing you guys anything new, but because you’ve seen that designer for many many years. But the amazing thing about this designer is that it runs outside of the process and it allows you to build dotnet core applications. So let me run that you, you and we visit the regular VIN forms form right, so that was everything I had for today.

Thank you very much for reading. Please give us your feedback, it’s very important for us to know that we’re developing the right thing for you and you can reach me out on Twitter. Thank you for reading.


 

By Jimmy Dagger

Find out my interests on my awesome blog!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.