 Hi, welcome to Visual Studio Toolbox. I'm your host Robert Green and joining me today is Stefan Wick. Hey Stefan. Hello. Thanks for coming on. My pleasure. Stefan's a program manager in Windows Land, as I like to call it. Yep, that's correct. Working on the desktop bridge, which is what we're going to talk about today. In the desktop bridge, which is originally codename known as Project Centennial, which is still how a lot of us refer to it internally to keep it straight, is the ability to take a Win32 app and take advantage of UWP as a platform and also the Windows Store. Yeah, that's correct. So thanks for the introduction. So I'm specifically working on the UWP app model team in Windows. And with the anniversary update this year, we've released the desktop bridge, which is a set of improvements in the Windows platform to really help all our developers who have existing investments in desktop technologies. And it helps them move their code forward into the universal Windows platform. And it helps them migrate their code gradually at their own pace. So we are not asking you to rewrite. We'll basically give you more options. We're giving you a door that's open to add more features and functionality while you still maintain the existing code base, have all the same functionality that you had for years, and you can continue to service your existing customers on older version of Windows as well with the same code base. Right. I think that's a great point. It's an option that you can use. You may decide to go 100 percent UWP, write only the platform, write a full blown UWP app. You may decide not to do that at all. You now have a bridge, an option of taking advantage of the UWP without necessarily having to completely rewrite the app. Yeah, that's correct. And actually, by doing the conversion as a first step on the bridge, you don't have to write any code. So we have tooling that supports you in the conversion process. And once you are converted, you immediately get a lot of the benefits that the universal Windows platform provides, such as the modern deployment stack that allows easy install, uninstall. It solves the problem of DLL hell and WinROT on the user's machine. And it gives you automatic silent updates and allows your app to be distributed with via the Windows Store or other distribution mechanisms of your choice. Right. So the Windows Store about the public store and the business store. That's correct. So for now, it's in this release, it's the public store. OK. OK. Cool. All right. Yeah, let me show you a couple of demos to kind of see how this works in practice in Visual Studio with a couple of examples. So kind of to introduce or frame the demos here, the enhancements that we've made in the in the platform are basically in two buckets. One is the installment and deployment benefits that you get right out of the box once you have done the conversion. And then the second bucket of enhancements are in the runtime. Now, when your app is converted, you actually have the full power of UWP available in your development environment so you can make more API calls. You can use all the features that UWP provides that you previously couldn't call from your MFC application or from your VB6 application. OK. And we kind of see the migration process in five steps. In the first steps, in the first step, you do the conversion. You run either our conversion tool or there are already third party conversion tools out there that help with your specific installer technology that you are using today. And with the conversion, you already get all of the deployment benefits. And from there on now, you can call UWP APIs from your desktop process. Actually, you were able to do that before the bridge, but only a small subset of APIs was available. Now, once you're on the bridge, a much larger subset is supported and you can get a lot more value out of that. And then from there, you can continue to extend your application. Not only can you call APIs, but you can also leverage other UWP features such as background tasks, app services, Cortana integration. You can add modern UI pieces to your desktop application and so on and so forth. You get live tiles, integration with this. Yes, yeah, exactly. Lifetime, that would actually be an example for kind of the first step in enhance. You can make those call and get the lifetimes. Right. And then you can continue the migration and actually move more and more of your code into the UWP app process. For example, you could think about replacing your old school UI with a modern XAML UI, but still keep some code around in your desktop process because you haven't done all the work to make all the legacy code UWP compliant. So you can keep that around. And as I said, migrate at your own pace as you see fit for your particular project. And then at the final step, once you've actually migrated all your code into the UWP app container, now your app is a pure UWP and you can deploy to any Windows 10 device. You can go to HoloLens, Xbox, Windows Phone and so on and so forth. Okay. Let me switch over to Visual Studio here and show you an example. So if you look at the Solution Explorer here, do I need to extend this? I probably just need to duplicate instead of extending. Yeah. PowerPoint loves to extend. There we go. Okay. So in the Solution Explorer here, we see I have a traditional desktop app. In my case, it's a WPF app that I choose here. But the same applies to any classic Windows application. It could be a WinForms app. It could be a C++ Win32 app. We're even seeing some VB6 apps coming across the bridge. We're seeing Delphi apps, Electron apps. So all of these apps are supported. In my case, I'm using WPF here. And so let me just launch the app normally first to kind of show you what it is. It's a very simple WPF app that has a couple of image elements that I'm using to monitor a couple of webcams around campus. So I can see, you know, before I go home, hey, what's the traffic situation? Just do a contest to see who will convert the oldest app. Oh, yeah. That would be an interesting one. Yeah. We should do that. For another demo, I've converted an MS-DOS-like ASCII-based game. So that was probably a pretty old one. I'll see if someone can top it. So this is how the app looks in the plain WPF world. Nothing super special here. Now I want to convert it to UWP and take advantage of new features in the anniversary update. So what I want to do here is I've added a UWP packaging project to my solution. What this does for me is basically it takes the output of my build process in Visual Studio and puts it in a layout that Visual Studio can then create an appx package from and provide it with an appropriate UWP manifest. And then it can be deployed just like any UWP and I have automatically all the deployment benefits without writing any code. This packaging project, we'll call out, we are currently shipping as an extension. So if you go to the marketplace, Visual Studio marketplace, you will find it here. There is the desktop to UWP packaging project. Just released an update yesterday with some bug fixes. You want to install that and then you can follow the same in Visual Studio for your project. Now let me deploy this on my machine and see. So did you have to do any configuration at this point? Yeah, there is a little bit of configuration. You basically author this package file list which basically tells Visual Studio what are all the pieces of my build output that I need to have in my package. So those are typically your EXEs and DLLs that you produce. Okay, you have to build that by hand or? Yeah, this is currently something you build by hand. Okay. So now I've deployed my app. Let's see if I can find it. Yeah, so it's in the app list. Now it's a UWP, so it gets deployed to the app list by default and I can pin it to start. I can resize my tile and I can supply it with nice tile assets if I want. And so all these benefits I get automatically. I can uninstall it right from here just like UWPs and it's a complete clean install. It's guaranteed to be clean all the time. So let's do this again because we actually want to run it. So here we are, I can launch it from the tile. And so it's the same app still, of course, I haven't changed any code, I haven't added any functionality. So at this point, you've got the benefit of it being deployable, installable, and uninstallable in a much easier fashion. Exactly, exactly. Avoiding, as you said, the DLL hell and rotten, whatnot. So you haven't touched the code, you haven't had to change the app so the exact same app, you just have a much easier install-uninstall process. Yeah, that's correct. Also, as you see. If you do nothing more than that, it's kind of interesting. It's already a great benefit. And the same app can still run on Windows 7, obviously. You're not excluding that. The binary is still the same. Now, with this packaging project, I can now create an AppX package from my app, and I've done it here. And so with this guy, you now have an installer, you can distribute this thing in your enterprise or with your friends, or you can actually put it into the Windows Store and deploy it from them. So that's another great benefit you get with just very few steps out of that. So you double-clicked on that AppX and you got a UI. Used to be, you had to use a PowerShell script? Correct. When did that change? That's another new feature. There are certain questions I'm embarrassed to answer because it was probably like three years ago. No, actually, this is another new feature that we've released with the anniversary. OK, good. So that is brand new too. OK. Cool. So going back to the project, and now I actually want to add some new functionality. So I want to call UWP APIs. If you recall on the slide that was kind of the first step after conversion, you can now call additional UWP APIs. And for that to do, you just need to add a couple of references to your project. This can be a little bit tedious. So we've provided a Nougat package that you can install. It will set up your Visual Studio project just right for calling UWP APIs. It also provides a little bit of syntax checking, which can be handy because there are some APIs that are not supported to be called directly from a desktop process and some that are. And so the syntax checking helps you avoid some of those mistakes. And so I've already added that Nougat package here. So now I can. What did it add? Show me the reference. It added all the Windows namespaces for the UWP APIs. And it also added these helper assemblies that allow you to do the async patterns and things like that. So I'm going to maybe jump ahead in the question. You can answer it later. You've got a reference to systemruntime.ui.zaml. Does that mean that I can have inside a project WPF ZAML files and UWP ZAML files existing in the same project? So that's a great question. So you can have from a converted desktop application, you can add UWP components that host ZAML UI. And I will actually show that in my demo in a few minutes. What is not supported is loading ZAML controls, like UWP ZAML controls, into a Win32 process directly. So that is not supported. But you can add a UWP component to your package, activate that package, and run UWP controls in that. And I'll have that demo in a second. So before I go to get to that demo, one thing I've added here in terms of UWP API calls is I'm using the toast notification APIs as well as the lifestyle APIs to make my WPF app a little more engaging, to keep my user more up-to-date, and also to provide info when the user is not running my application and keep them engaged. So let's see how that looks. Let me resize this again. And so now if I select one of these webcams, I get a toast notification here with the current state of the webcam. And I can actually continue to get those periodically, even when my application is not running. And so actually, let's close it. And I've also updated the tile. So hopefully that kicks in in the next few seconds on the next cycle, which should give me the current state of my app. Cool. So let's get another incremental, nice step. Again, exact same map, but you're taking advantage of the UI, live tile notifications, and a lot of this cool stuff that you don't necessarily or may not be able to completely rewrite the app as a UWP to take advantage of, but now you just put these things into your existing app. Exactly. And you have much better user engagement now. You can periodically pop up toasts and provide new information to your user, and also bring them back into your app. So I mentioned we're not only enabling you to call additional APIs. You can actually use all the features and functionality in UWP now from your desktop application. Another example here I want to point out is background tasks. So I've registered a background task here from my application. And I want to point out, and this is important, that I'm wrapping this call into a check to see if I'm actually running as a UWP currently, because I want the same code to still be able to run on Windows 8, on Windows 7, and whatever versions I support in my application. So I make this check here so only if I'm actually converted, I register the background task. Otherwise, this would fail. And so what I'm doing here to register the background task, I'm using the UWP APIs for that. And I'm defining an entry point that implements the code that can now run whenever this trigger fires. In this case, it's a 15 second time trigger. And so even if my app is not running, this code will run and can provide value to the user. So I've implemented the code here in this project. You see, it's a universal Windows project. And it's a very simple class that just implements the run method to fire up another toast every 15 seconds. So the user keeps engaged. And yeah, so this component is another one that I'm listing here in my packaging project. So it gets packaged with my AppX and deployed. Everything gets deployed together, gets serviced together. It's one unit of application. So are there tools being worked on to automate this process? Yeah, there are things on the roadmap. Not many details to share at this point in time, but this is definitely an area for improvement. OK. Is there documentation of the types of things you should be looking for and knowing that that component, one of them is in a WMD, one of them is in an XZ? How do you know? Yeah, yeah. So there is documentation on MSDN on how to use this new extension. Got it. So if we look at the components here, I've added background task. But I have another thing here that I called map UI. And this is actually a UWP UI component that I'm adding here. And this goes back to your earlier question about hosting modern UWP XAML controls in your desktop app package. And so this is exactly what I want to do here. And so let me launch my app again. And so I've added these little map buttons to the webcams. And so what this does is it pops up a XAML UI component. And this is hosting the latest map control that we have in UWP. And I can take advantage of all the features there. And I can check out, hey, what's the situation on the bridges right now? Which way should I take? And then I can switch over to my other webcams and so on and so forth. So it has to launch in a separate window? Yes, it launches in a separate window. This is running in the UWP app container. Whereas my WPF app still runs as a regular desktop app. So we're not quite at the point where you can have within the app some pages written in WPF, some pages written in UWP XAML running kind of side by side inside the app. We don't have that. Correct, those are separate windows. They're all in the same app package. They are deployed together and serviced together. But those different UI technologies will run in different ways. OK. Yeah, so that's how you add another UWP component to your package. As you can see, we can activate it. We can also communicate back and forth. So there's a communication channel that we provide so that all parts of your application can communicate together. You can also add app services to your desktop application that then can provide services to other apps on the system. And literally, you can use any UWP feature now in your desktop application package. Very cool. So that's pretty much the demo. Now, there's a lot of documentation out there on aka.ms desktop rich. Definitely recommend going there, checking out all the tools, all the documentation. There's pointers to samples as well, if you want to start with those. And we are continuously updating those samples, adding more examples, not only for WPF or .NET apps. We're also adding some more C++ samples and other technologies as well. And give us a couple examples of people who are doing this and what experiences they've had. Yeah, so we've just started onboarding the first set of customers to the Windows Store. Evernor was one of the examples. Cody is another one. So for them, it's really a great option to kind of bring forward their existing versions of the app. Yeah, Evernor, it's interesting because I actually first learned about them because they had a Windows 8 app. I didn't actually know they had a Win32 app. They had a Win8 app. So I said, oh, that looks interesting. Downloaded that, started using it. But it turns out that they have a Win32 app as well. So how do they decide what to do with their UWP app and their Win32 app? Yeah, I mean, obviously everyone's situation may be different. But having a UWP app is a great choice for you if you want to target Windows Phone and desktop and maybe HoloLens and Xbox as well. And that opens up with that choice. If you have an existing code base on desktop that you've built over years, which is very rich in functionality and takes advantage of unique desktop capabilities, you want to keep that around as well because you may have users on desktop who depend on some of those specific functionality. So they would then just offer up both versions of the app. And if you're currently using the Win32 version, you now gain some of the features we've talked about, the integration with UWP, the much better install model, the fact that you can go to the store and get it. If you might install both because potentially the UWP version is a more lightweight version, might have some different UI. Probably works a little bit better with touch, right? Yeah, that's correct. I mean, it's up to you as the app publisher to decide which app you want to deploy to what customer group. In the case of Evernote, they're actually defaulting to the Win32 app right now for users on the Windows 10 anniversary update. But other apps are making different choices in terms of what they offer to their customers. Right. But it gives you the options of deciding what you want to do, taking advantage of the platform without necessarily having to completely rewrite. I think that's the key benefit of this. Exactly, yeah. So yeah, we want to make sure you can keep your existing investments and move forward and leverage your existing customer base and your existing functionality as much as possible. That's awesome. Thanks so much. You're welcome. All right, hope you enjoyed that great stuff to play around with. It looks fairly easy to get started with and to use. All right, cool. We'll see you next time on Visual Studio Toolbox.