Sessions is temporarily moving to YouTube, check out all our new videos here.

Bring Existing Desktop Apps to the Universal Windows Platform

Pete Vickers speaking at Dot Net North in May, 2017
36Views
 
Great talks, fired to your inbox 👌
No junk, no spam, just great talks. Unsubscribe any time.

About this talk

In this talk we'll learn how to: convert desktop solutions to use modern deployment technology, distribute through the Windows Store or other/existing distribution channel, reach 350+ million users on Windows 10 and monetize globally through the Windows Store.


Transcript


Right, so I'm gonna talk about bringing existing desktops apps to the Universal Windows Platform using the desktop app converter. This used to be known as Project Centennial, till they released it. Anybody heard of Project Centennial, or the Windows Bridge? Anybody used it? So, as we know there's millions of desktop Windows solutions out there. This gives you the opportunity to take your desktop application and put it in the Windows store. So the user experience challenges, these are things that affect our end users. Same product can be available from loads of websites, so which one do you choose? Chain installers, so you run the installer, you click next, next, next, finish, and you start your browser, and you've got five extra toolbars and things like that. Difficult to stay up-to-date with auto-update, patching et cetera. For example, my wife never would update any software that she gets prompted to update. And it's difficult to do a clean uninstall. So it's almost never done cleanly, you always get registry entries left around, temp files, things like that. Things that affect us as developers. First of all, maintaining installers. So you write a setup process, and then something changes in your programme or you need a DLL or you change the setup process, et cetera. Trustworthy distribution. So monetization, piracy, licencing, et cetera. How do you sell it? I used to sell software through a third-party site that used to distribute and obviously take their chunk out of it. I'm not saying Microsoft do it for free, but you can distribute your software that way. Providing auto-updates, again, linked in with building installers and setups, just making sure you can get it to update. Monetization and licencing, we just said. DLL hell, which was supposed to disappear with .NET about 10 years ago, but you still don't know if the user's got the right version of .NET on that you've compiled against, and everything like that. So you've got everything like that to worry about. And modernization. So don't just port an app for the sake of porting it, you can take the example of, take advantage of UWP and you can add new things to your application. So Universal Windows Platform. This touches on stuff from the previous slide. So configuration, security, management et cetera. We can add things, we can access Windows Hello APIs, Windows Pen & Ink, et cetera. There's one SDK, got one store and dev centre, so it all goes in the store. And you can use Cortana. And obviously you may want to expand to other devices, so as you move along, you can move onto to Windows 4 while it's still with us, or Xbox, Hollow Lens. As you move along, you can gradually move to more platforms. So I say, it used to be called Project Centennial, it exists today as Desktop Bridge, and it's a fully supported release. There's two sections, deployment and distribution. It uses modern distribution techniques to the Windows Store for Business, which helps you with licencing and monetization. So you can reach all Windows users, and as I said before, you can migrate gradually. So you can take your application, run it through the Bridge, get an installer, and you can add UWP facilities, and then you can add more and more, and gradually move it over to a UWP app. So on the conversion, the first steps, taking the existing installer, and bringing it up to modern technology, so that you don't have to author a setup programme using InstallShield, although we'll talk about that later. After conversion, you can put the app in the Windows Store. And only trusted apps are allowed to be installed in the Windows Store, so you get a certificate, you make your app trusted, and that can go in the Windows Store. So to repeat, you don't have to write complex setups, only trusted apps are let into the Store. You get optimised updates, so the store will push down, if you've got a multi-language application, and the files aren't on your user's PC, when the setup runs it'll look at that and it'll download any language files it needs. Similarly, any DLLs or versions of .NET that aren't on the PC, it'll automatically download, it takes care of that for you. If you do a new update and want DLL changes, it'll just download that DLL, it won't reinstall everything, it'll just intelligently bring down what it needs to bring down. So it'll just bring the APPX files down. Mobile device management. You don't have to use the Windows Store, you can side-load applications, you can distribute line-of-business applications within your own company, you don't have to go through the Windows Store, but you get a proper installer. So as I was saying, you can migrate at your own pace. So the first step, is you just take Windows app package, you might get the desktop application, and you can add a couple of UWP APIs to it. So you can do live tiles, push messaging, which we'll go into. Second phase, you can extend your application. So you've got a desktop application, you could write a UWP application, you can get the two applications talking to each other through App Services, again we've got a demo of that. So you start with the desktop, you could then put your UWP front-end to it, it'll talk to your desktop application. Third phase, you can move more and more code to UWP at your own pace. And at the end, you'll probably finish up with a full UWP application replacing the desktop app. As I said before, don't just migrate for the sake of migrating. Use the opportunity to improve your application. So our next phase, conversion, deployment and distribution. I'm gonna start with a Windows app and convert it. So we start with an existing desktop app, which is all Win32/.Net code base. You've got an InstallShield installer for it built, or something like that, and it runs as a desktop process. What we can do, is convert this, we can use modern deployment techniques. So we get seamless updates, clean uninstall, the app still runs using the existing code, we've not changed any code, and usually, you may need to change a small amount of code. So InstallShield also supports Desktop Bridge. So if you use InstallShield, you can actually run it against your application and it tests your apps for compatibility. So it'll warn you things that will work, won't work, so they'll get in the Windows Store. You can't use COM, you can't use various things, so InstallShield you can run against it and it will produce a report telling you what you can and can't do. Again, using InstallShield you can create app packages and MSIs from an InstallShield project, so you can still target both. Store is a single-file instal, but you can use multiple packages and InstallShield will merge them into one APPX. So you can add other dependencies there and it'll automatically drag them in. And you can create side-loads, so you'll download packages on demand during instal. So we got a demo, first of all. Before doing some demo work, we have to do some preparation on the PC to get it to work. So first of all, when you instal the Desktop App Converter from the Store, we'll look at that in a second, we can go to the Store, just download it. You need to download a Windows 10 Base Image file, and that depends on your OS build, again we'll go to the webpage. There's a different build for each release of Windows 10, so there's a build for the Creator's update, the previous release and everything like that. You need to match it to your operating system. Run the Desktop Converter setup, and instal a certificate to a trusted certificate store. As I say, the App Converter is one way to do the conversion, other methods are available. So InstallShield, WiX and Advanced Installer all support creating APPX packages. The goal of conversion is just simplify the installation for the developer, optimise installation and make it easier for the consumer at the end, so they just get your app from the store. After conversion, your app package can be distributed through the Windows Store or existing distribution channels. As I say, you can side-load it onto devices, you can distribute it within your own company. So. Yeah, so if you go to the Windows Store, you can download this onto your laptop. And as I said, there is an installer that you can download at the same time. So hopefully this will load. So if we run that as administrator. So what we're gonna convert is Live Writer, which I should have on my desktop somewhere. Yeah, so we've got Live Writer there, so we'll convert that using the Desktop Application Converter. So. You can see, it's a nice simple command line. So you tell it the file that you wanna convert. Slash S means it's gonna be silent. This is where we're gonna put it. We can put a package name, which we'll see when we run it, OpenLiveWriter, publish a unique GUI, version number, tell it to make an APPX, X86, package name, so you can set a package name up, and set a publisher, display name. So we shall run that, but first of all I will pause my protection, otherwise this will take a while. So this is taking that Live Writer executable and producing an installer package. It's the executable it's looking at, producing the setup from that, so we'll get an APPX as an output. And various log files, which we can take a look at. If I leave my virus checker on this takes about 10 minutes to run. Yeah. Yeah. So you got the WiM Image, when you run that you do the installer, it puts it on in the background, generally you've gotta do a reboot and everything like that. The WiM Image, as I say, has got to match your release of operating system. So it's finished with those Yeah the Image file is just a small 3.3 gig, so you download that, run a utility against it to register it on your system, and it uses that from then on. So our converter, we've got an OpenLiveWriter folder that's just been created. Got logs, so we've got a converter log that tells us everything that we've just been doing, various logs, so if you get any errors, obviously you can look at those. And what we've finished up with is an APPX. So an OpenLiveWriter APPX. So if we now run this. So we got publisher.north, .NET north demo, which we supplied as one of the parameters, the version number, everything like that. So we can click on instal, and it will fail, because it's not been signed with a trusted certificate. So what we can do, is within Visual Studio, we can use a certificate that we downloaded. We downloaded a certificate earlier. We're taking that and applying it to our APPX that we just created, supplying that certificate. So we close. Go back to here. Run this again. So we've now got a normal installer, we launch it. So you got the desktop app that you had before but you've got a trusted installer that you can put in the Store, it'll handle auto-updates and everything like that. Yeah, so I say, this self-signed certificate we downloaded earlier. Once we've signed it we can use the installer. And we'll go back, hopefully, to the presentation. Right, so we've run the Application Converter, so we've now got a new installation deployment tool. Activation tiles, file types. We've got an app identity. It says it opens opportunities for taking all your desktop users, putting them in the Store, reach 350+ million users on Windows 10 today. You can use the well-trusted model of monetization, so you can set your own prices, you licencing models, everything like that. We've got some links at the end that tells you how to get stuff in the Windows Store. There's quite a few apps that are in the Windows Store today that are there using the Desktop Application Converter. Evernote used it to get their application to the Windows Store quickly. So we've done a conversion, so we can now take a desktop app, and we can expand it by using UWP features. So we can take a desktop app, and in this case we're going to add live tiles, push notification, and roaming configurations. So if we switch back again. So this is an application, we've got the source code all behind. Health Clinic, so it's a desktop app that's been run through. So this is a demo application written by Microsoft, as was this presentation. Goes to an Azure backend, picks up doctor's appointments et cetera. All the pictures are in Azure. So we can say a new appointment. Tomorrow. And we should've been able to create a new appointment. Let's try again. I would've put our photographs on, but ... Right. So it has made it for tomorrow. And again, we can click on those and get details. So what we're gonna do to this is add live tiles, and push notifications. So if we look at the structure of the project. So we've got the desktop app, which is a normal Windows desktop application, and we've added UWP portable application into this. We've also added, in the references, we've got a metadata file there in the SDK. The metadata file allows us to use UWP APIs, which we'll show shortly. Because we're going to be using push notifications. So by adding that reference, it allows us to define push notifications. And also live tiles. So live tiles that you've possibly used in applications of your own, or Windows Phone applications, you can get live tiles so we can get the icon for it, we can get the text, and we can get the appointments, room numbers, et cetera. And again, because we've added that reference to Windows, we get a push notification channel manager. So this is again, as I say, allowing us to use UWP APIs in the portable app and talk to our desktop app. So we're now adding that component. So we've got a desktop application which all it does is write to the registry. So it writes statuses of appointments to the registry. UWP apps can't access the registry, so we can't use that to do that. So you write a XAML UI front end, we write an app service, we've got background tasks, we launch the UI, it talks to the desktop process which updates the registry, which in turn updates the UI front end. So we'll see if this demo works better. So again we've got a Visual Studio project, so we've got a desktop app. A desktop app that effectively is just writing to the registry, which as I say we can't do from a Universal app. We've got a background task, as a Universal app, and we've got a front-end Universal application. So all the desktop app does is store information into the registry. It is yes, it's not doing anything flashy. yeah, it's just showing that we can get applications talking to each other. So again, because we've used the Windows extension kit, we're using an app service, which is a UWP service. We're connecting to the UWP front end, that's changing the status, telling the back end which will then update the registry. So. In a Universal app, we just got a background task starting. So when we start up, we start up the background task that will talk to the front end. And we've got a main page. You've just got a bit of flashy stuff on. We've got a dropdown that will change our status. When the status changes. If we've not got a connection, we start the service. We've got a live tile so we can update that at the same time and we send a notification to the other application. So we pin that to the start. And if I run the app. Change that to do not disturb. So again, we've got the live tile being updated on the fly. So the UWP app, which is now this front end, using App Service to talk to the desktop app which updates the registry, talks back to the UWP app, which then changes the live tile. So that's step three in extending the demo. So the App Service that we've written was UWP. It was desktop process, app container process, the UWP service in the middle that was talking to them. These can be written as global services, if you like, so you can write a UWP service that does a log in. So it can go off to an Azure database, validate the user and password, and you can then call that from any app that you wanted to. So we've seen how we can use Desktop App Converter to take a normal exe, build a Windows Store installer. We've seen how we can then take a desktop app, add some UWP functionality to it, and the demo failed, and then we've seen that we can use UWP app as a front end talking to a back end that's talking to the registry, etc. So we're extending the functionality gradually, from doing nothing, adding an API, adding an App Service that talks between processes etc. And you can then move on, and the idea is that you would gradually migrate your UI to XAML. So you start with a desktop app, and you gradually add UWP bits and pieces, and then you finish up with a UWP app that you can put in the store, theoretically running on all devices. There, so you can, until you migrate it all, it will still only run on PCs, but when you get it to a true WP app, you can target anything, as I say if Windows Phone still exists. Getting started, so as I say, InstallShield do their installer where you can build an APPX, or you can build an MSI or you can build both. Go to Flexera's website, get all the details from that. I think you can get a free trial and try that out, so there's not only the Desktop Application Converter, you can use InstallShield. There's a Desktop Bridge site. So this tells you all about the benefits of using it, how to use it, et cetera. I'll put all these links up afterwards. Gives you all the conversion options, everything like that. Submission form. So when you've converted it to an APPX, you've got a submission form so you can submit it to the Store, so just what it does, company name, et cetera. Certificate, and you can submit it to the Store. There's a full documentation site. Giving all the benefits of doing it. UWP extensions. So that's showing the exact extensions, you can do, as we said, live tiles, everything like that, everything that's in that metadata file, it tells you how to use those. And a section on how to run your app and how to debug it. So the Desktop Bridge, you can do a conversion, you finish up with an APPX file, package, you can test, update and distribute it, you can get it in the Store. And as I say you can then gradually migrate the app to UWP and use all the features within that. That's all the additional resources there, I'll put them on the site.