Now Reading
What’s Really the Common Home windows Platform and what’s WinUI, MSIX, and Challenge Reunion / Home windows App SDK? – Thomas Claudius Huber

What’s Really the Common Home windows Platform and what’s WinUI, MSIX, and Challenge Reunion / Home windows App SDK? – Thomas Claudius Huber

2024-02-26 14:01:43

This morning I obtained an exquisite message from a really good and nice one that watched my newest Pluralsight course, Fundamentals of Building .NET Desktop Applications. The course explains the .NET UI frameworks Windows Forms, WPF, UWP, WinUI (together with Uno platform), and .NET MAUI in an outline and reveals construct your first .NET Desktop Apps for Home windows with WinUI, WPF, and Home windows Types. The construction of the course is like this:

  • Figuring out the UI frameworks for .NET Desktop Apps
  • Creating Your First WinUI App
  • Constructing Your First WPF App
  • Writing Your First Home windows Types App

The message that I obtained this morning mentioned the next:

You appeared to be utilizing UWP to refer to 2 various things, a “framework” and an “app mannequin”

From a extremely revered developer

So, it was complicated that I used the time period Common Home windows Platform (UWP) to refer not solely to a UI framework, but additionally to an app mannequin. That’s right, I did this, and I can perceive the confusion very nicely, as a result of I’ve been there too. I attempted to clarify issues as clear as attainable, and with as much less ballast for brand spanking new .NET desktop builders as attainable.

The aim of the “Figuring out the UI frameworks for .NET Desktop Apps” course module was and is that builders know why WinUI 2.x and WinUI 3.x have been launched and the way WinUI is expounded to UWP. And after watching the course they need to have the ability to construct a WinUI app and likewise make the choice whether or not they use the UWP app mannequin or the Win32 (Desktop) app mannequin for his or her utility. The aim was not meant to do a deep dive into the Common Home windows Platform, as that is far more than simply WinUI.

However now, we’re already utilizing some phrases like app mannequin earlier than now we have clarified the large image. Let’s dive deeper into the subject on this weblog submit, in order that all of us, you and I, have a transparent understanding of what UWP truly is. As well as, let’s additionally look a bit at different components like MSIX and Challenge Reunion (which known as Home windows App SDK since 24 June 2021, when Home windows 11 was introduced) which might be additionally associated to this complete UWP and WinUI story.

Earlier than we begin, I wish to make one level very clear: The multi-dimensional use of the time period UWP is an issue, it’s one thing many builders battle with, newcomers and professionals with years of expertise. I’ve seen builders speaking to one another (typically I used to be one in every of them), and everybody used the time period UWP to consult with a distinct factor.

This downside exists, as a result of the time period UWP is definitely used for a lot of various things. So, as soon as for all, let’s get this sorted out my buddies. 😎

First, I wish to let you know from my expertise crucial issues that come to my thoughts after I hear the time period UWP.

What’s the Common Home windows Platform?

The Common Home windows Platform was launched with Home windows 10. It’s out there on all gadgets that run Home windows 10 and Home windows 11: PC, HoloLens, Xbox, Floor Hub, or IoT gadgets. In Visible Studio there’s a undertaking template known as “Clean App (Common Home windows)” that permits you to construct a UWP utility that may run on any of those gadgets. You may construct the appliance with .NET/C# or with C++. To create consumer interfaces, you utilize the Extensible Utility Markup Language (XAML), which is an XML-based language that was launched initially with the Home windows Presentation Basis (WPF) within the yr 2006. WPF is one other UI framework, and UWP makes use of many ideas that you simply discover in WPF, like XAML, knowledge binding, kinds and so on. That signifies that a WPF developer will get in control with UWP fairly quick, and vice versa. However WPF isn’t a UI framework that C++ builders can use, for WPF you need to develop with .NET/C#, C++ isn’t supported there. Meaning C++ builders have been left behind. With UWP, C++ builders are once more a part of the sport.

An necessary a part of UWP functions is that they run in a sandbox, system entry is restricted. This makes a number of sense when you concentrate on the truth that you’ll be able to distribute UWP apps through the Microsoft Retailer. The UWP app has to declare capabilities to have the ability to use particular assets of your system. You may know this from cell functions, when you’ll be able to see messages like “This app desires to entry your footage, your paperwork and your contacts”. A UWP app additionally has to declare these capabilities, in order that they’ll give you the results you want as a developer and {that a} consumer can see what an app desires to do. One other factor about UWP apps is that they’re packaged within the type of an .appx file (which relies on .zip format), which makes it attainable to put in and uninstall UWP apps in a really clear method in your Home windows 10/11 machine. One other necessary a part of UWP apps is the activation and lifecycle management. Win32 apps hold working when the consumer minimizes them or switches to a different app. That’s not good for gadgets that run on battery like tablets and plenty of different moveable gadgets. UWP apps remedy this downside with an activation and lifecycle administration. A UWP app can get suspended when it’s within the background, in order that the system can save assets and battery.
However now you see already that UWP apps have some totally different options, like XAML, packaging, sandbox, lifecycle administration and so on. So, UWP appears to be greater than only a UI framework. What is definitely UWP?

The Common Home windows Platform isn’t just one factor, that’s why the time period is utilized in a number of dimensions, and that’s why it could get complicated. Here’s a checklist that comes straight out of my mind, so as to see what I feel what UWP truly is, with out assure of completeness:

  1. UWP app – that is an app that you simply’ve constructed with C# or C++, and the app makes use of all the opposite factors talked about on this checklist. There’s a undertaking template for this app in Visible Studio known as “Clean App (Common Home windows)” (Accessible provided that you’ve put in the Univeral Home windows Platform growth workload with Visible Studio).
  2. UWP XAML framework – that is the a part of Home windows 10/11 that you simply use to construct your UWP apps with, it comprises XAML and the visible layer that’s essential to render your app, together with consumer enter performance.
  3. UWP XAML controls – the controls that you simply use in your UWP apps, they’re additionally a part of Home windows 10/11.
  4. WinRT – the Home windows Runtime is a contemporary Home windows API that makes use of .NET metadata to explain its contents. It’s a part of Home windows 10/11 and exists in your PC beside the basic Win32 API of Home windows.
  5. UWP packaging – UWP apps are put in as a package deal (.appx file, based mostly on .zip), which makes it attainable to put in and likewise uninstall them in a really clear method, with out leaving some registry muddle or folders left in your machine.
  6. UWP app mannequin – UWP apps run in a sandbox. They should declare capabilities to get entry to totally different system assets, like for instance your web connection. To help this restricted sandbox, Home windows has to host your utility in a particular method, and that internet hosting mannequin can be sometimes called the UWP app mannequin. The opposite conventional internet hosting mannequin on Home windows is the Win32 internet hosting mannequin, which can be known as the desktop internet hosting mannequin. Additionally a part of the UWP app mannequin is the activation and lifecycle administration, which is particularly necessary for moveable gadgets that run on battery.

Facet notice: We glance right here at UWP from the angle of a XAML and C# developer. Utilizing the UWP XAML framework could be the commonest method for .NET builders to create a UWP utility, however it’s not the one method. The UWP XAML framework layer sits on high of a visual layer that sits itself on high of DirectX to render your UI. As a substitute of utilizing XAML and C#, you would for instance additionally use DirectX straight, or you would use HTML and JavaScript with React Native for Windows.

Now, when builders speak about UWP, they’ll consult with any of those factors in that checklist. Essential to know is that every one these factors can be found on any Home windows 10/11 system, like PC, HoloLens, Xbox, Floor Hub, or IoT gadgets. That’s as a result of all these factors are part of the Home windows 10/11 core. And precisely that causes a dependency downside.

The Dependency Downside with the UWP XAML Controls

The UWP XAML controls are a part of Home windows. It is a robust dependency to the working system. It signifies that the customers of your UWP utility have to make use of the most recent Home windows model, so as to use the most recent UWP XAML controls and management options. Microsoft has damaged up this dependency by offering the UWP XAML controls as a NuGet package deal which you can reference out of your UWP utility. That NuGet package deal known as WinUI 2.x. WinUI stands for Home windows UI library. This implies the dependency between your app and the working system concerning UWP XAML controls is eliminated. Now your UWP app can rely on the WinUI 2.x NuGet package deal, and also you and your customers can benefit from the newest UWP XAML controls with out having to replace your computer systems to the most recent Home windows model.

This implies, you realize now what occurred with level 3 of the checklist above:

1. UWP app
2. UWP XAML framework
3. UWP XAML controls => a part of WinUI 2.x NuGet package deal
4. WinRT
5. UWP packaging
6. UWP app mannequin

The UWP XAML controls are nonetheless a part of Home windows for current functions, however they have been copied to the WinUI 2.x NuGet package deal, and new options and new growth are executed in that WinUI 2.x NuGet package deal which you can reference out of your UWP utility.

Facet notice: That all XAML controls are copied to the WinUI 2.x NuGet package deal is a simplification on this weblog submit. The fact is a little more complicated. Solely WinUI 3.0 that’s described within the subsequent part consists of all of the XAML controls and likewise the XAML framework. To dive deeper into WinUI 2.x, scroll all the way down to the feedback and browse the one from Marcel Alexander Wagner (a C# dev and WinUI contributor).

Now let’s take a look at the subsequent dependency, the UWP XAML framework

The Dependency Downside with the UWP XAML Framework

The UWP XAML framework is a part of Home windows since Home windows 10, and that’s truly the identical type of dependency between your UWP app and the Home windows working system like we had it within the earlier part with the controls. It means which you can solely use the most recent framework options for those who run the most recent Home windows model. Microsoft has additionally decoupled this dependency from Home windows, and it’s a part of WinUI 3.0. WinUI 3.0 is a NuGet package deal that comprises level 2 and three from our checklist:

1. UWP app
2. UWP XAML framework => a part of WinUI 3.0 NuGet package deal
3. UWP XAML controls => a part of WinUI 3.0 NuGet package deal

4. WinRT
5. UWP packaging
6. UWP app mannequin

Now, shifting additionally the UWP XAML framework to WinUI makes WinUI 3.0 a full-blown UI framework like WPF or Home windows Types. You discover the repository of WinUI on GitHub: https://github.com/microsoft/microsoft-ui-xaml. Try additionally the problems there, they comprise bulletins for WinUI group calls, that are reside periods on youtube with the WinUI crew and the group which you can be a part of. The WinUI group calls are maintain on a month-to-month foundation.

Now, again to the WinUI 3.0 NuGet package deal. This NuGet package deal isn’t meant for use in a basic UWP app that you simply create in Visible Studio with the “Clean App (Common WIndows)” undertaking template, as a result of these apps level to the unique model of the UWP XAML framework that’s a part of Home windows, and to not the decoupled model of the UWP XAML framework that comes with the WinUI 3.0 NuGet package deal.

To make use of the WinUI 3.0 NuGet package deal in your utility, you should set up the WinUI 3.0 undertaking templates in Visible Studio. Discover ways to do that by reading the docs. After putting in the undertaking templates, you might have two undertaking templates to create a WinUI 3.0 undertaking in Visible Studio:

  • Clean App (WinUI in UWP)
  • Clean App, Packaged (WinUI in Desktop) <= Win32

The next screenshot reveals these choices within the “Create a brand new undertaking” dialog of Visible Studio 2019.

Each choices create an utility that references the WinUI 3.0 NuGet package deal, which implies you get the UWP XAML framework and the UWP XAML controls to construct your utility. The distinction is within the underlying app mannequin, or app internet hosting mannequin. So, let’s take a look at this within the subsequent part.

What in regards to the App Mannequin?

Let’s speak about level 6 of my unique checklist, the UWP app mannequin:

6. UWP app mannequin – UWP apps run in a sandbox. They should declare capabilities to get entry to totally different system assets, like for instance your web connection. To help this restricted sandbox, Home windows has to host your utility in a particular method, and that internet hosting mannequin can be sometimes called the UWP app mannequin. The opposite conventional internet hosting mannequin on Home windows is the Win32 internet hosting mannequin, which can be known as the desktop internet hosting mannequin. Additionally a part of the UWP app mannequin is the activation and lifecycle administration, which is particularly necessary for moveable gadgets that run on battery.

With the WinUI undertaking templates put in, you’ll be able to select if you wish to create a WinUI in UWP app, or a WinUI in Desktop app. The primary possibility provides you a standard UWP app that references the WinUI 3.0 NuGet package deal. It signifies that your app runs in a sandbox and you’ll set up it on totally different Home windows gadgets, like PC, HoloLens, Xbox, Floor Hub, or IoT. The app additionally saves assets when it’s within the background, which is necessary for moveable gadgets that run on battery. The second possibility – WinUI in Desktop – creates a basic Win32 app that references the WinUI 3.0 NuGet package deal and that runs in your PC and that may do something there like a WPF or Home windows Types app. This sort of app doesn’t have restricted system entry like a sandboxed UWP utility.

Which means you need to use WinUI 3.0 to construct an utility with the UWP XAML framework and UWP XAML controls and you’ll select between:

  • .NET/C# and C++
  • UWP and Win32 app mannequin

The 2 app fashions make clear what occurred to level 6 of our checklist

1. UWP app
2. UWP XAML framework => a part of WinUI 3.0 NuGet package deal
3. UWP XAML controls => a part of WinUI 3.0 NuGet package deal

4. WinRT
5. UWP packaging
6. UWP app mannequin => a part of Home windows since model 10, out there on all Home windows gadgets, not solely PC/Desktop. With WinUI 3.0, you’ll be able to select between this app mannequin or the standard Win32 app mannequin

The Outdated and the New Manner To Create a UWP app

The WinUI 3.0 undertaking templates provide the possibility to make use of the UWP app mannequin or the Win32 app mannequin, as talked about within the earlier part. This implies additionally that the present Visible Studio undertaking template “Clean App (Common Home windows)” is the previous technique to create a UWP app. Bear in mind, that undertaking template makes use of the UWP XAML framework constructed into Home windows 10, it’s not attainable to reference and use WinUI 3.0 there, however solely WinUI 2.x. For brand spanking new UWP apps, you must use the “WinUI in UWP” undertaking template that creates a UWP utility that makes use of the UWP XAML UI framework and UWP XAML controls from the WinUI 3.0 NuGet package deal. Now you additionally know what occurred with level 1 of our checklist:

1. UWP app – for brand spanking new apps, don’t use “Clean App (Common Winows)” template, however “WinUI in UWP” template that creates a UWP app that references the WinUI 3.0 NuGet package deal.
2. UWP XAML framework => a part of WinUI 3.0 NuGet package deal
3. UWP XAML controls => a part of WinUI 3.0 NuGet package deal

4. WinRT
5. UWP packaging
6. UWP app mannequin => a part of Home windows since model 10, out there on all Home windows gadgets, not solely PC/Desktop. With WinUI 3.0, you’ll be able to select between this app mannequin or the standard Win32 app mannequin

Subsequent, let’s take a look at the packaging.

UWP Packaging for Clear Installations

UWP functions are packaged in a format that has the file extension .appx. That could be a .zip based mostly file format. Home windows 10 is aware of set up and uninstall these packaged functions. There’s no muddle left while you take away an UWP app.

The attention-grabbing half is that this packaging function is definitely constructed into Home windows 10, and you can even use it to put in and uninstall conventional Win32 apps, like WPF, Home windows Types or WinUI in Desktop apps. To do this, Visible Studio has a undertaking template known as “Home windows Utility Packaging Challenge”. This undertaking can reference your Win32 undertaking, and it creates a so-called MSIX package deal, which is the packaging format of Home windows 10. The file that you simply get is an .msix file, and that file format is strictly the identical file format because the .appx file of a standard UWP app. This MSIX package deal permits you to distribute additionally basic Win32 functions like WPF or Home windows Types through the Microsoft Retailer, as they get put in and uninstalled in an excellent clear method, managed by Home windows 10.

See Also

Whenever you create a WinUI in Desktop app that makes use of the Win32 internet hosting mannequin, you robotically get such a package deal undertaking that creates the MSIX package deal for you. Meaning, packaging is unbiased from the chosen app mannequin. Irrespective of for those who use WinUI in UWP or WInUI in Desktop (Win32), you’ll be able to all the time package deal your app to distribute it in a clear method. This implies, we all know what occurred to level 5 of our checklist:

1. UWP app – for brand spanking new apps, don’t use “Clean App (Common Winows)” template, however “WinUI in UWP” template that creates a UWP app that references the WinUI 3.0 NuGet package deal.
2. UWP XAML framework => a part of WinUI 3.0 NuGet package deal
3. UWP XAML controls => a part of WinUI 3.0 NuGet package deal

4. WinRT
5. UWP packaging => a part of Home windows since versioon 10, based mostly on MSIX format. Additionally Win32 functions could be packaged through MSIX to put in/uninstall them in a clear method.
6. UWP app mannequin => a part of Home windows since model 10, out there on all Home windows gadgets, not solely PC/Desktop. With WinUI 3.0, you’ll be able to select between this app mannequin or the standard Win32 app mannequin

Now, lastly, let’s take a look at the WinRT.

The Home windows Runtime (WinRT)

The Home windows Runtime (WinRT) is the trendy Home windows API that’s out there on all Home windows gadgets since Home windows 10. Generally builders additionally consult with this one because the UWP API. The WinRT makes use of many ideas of .NET, like .NET metadata to explain it’s members, and likewise ideas like courses, properties, occasions and so on. But it surely’s necessary to know that the WinRT is a local a part of Home windows and written in C++. However the API is projected into different languages, so that you’ve the sensation that it’s a native a part of the language that you’re utilizing. For instance, in case you are utilizing C#, you need to use C#/WinRT which doesn’t really feel totally different from utilizing another C# element or library.

Beside the WinRT, the older however nonetheless highly effective Win32 API exists in Home windows 10/11. And now the query is: Ought to the out there APIs in your utility rely on the app mannequin (UWP or Win32) that you’ve chosen in your app? No, you must have the ability to get the most effective out of Home windows, irrespective of in case you have a UWP or a Win32 app. And precisely for this, Microsoft works on Challenge Reunion. On 24 June 2021, when Microsoft introduced Home windows 11, they renamed Challenge Reunion to Windows App SDK. That new title makes it truly extra clear what it’s, the title Challenge Reunion was anyway meant for use solely throughout growth. The Home windows App SDK unifies the Home windows developer platform, so that you simply as a developer can construct functions for any Home windows 10/11 model and likewise for any system. Let me simply quote from their GitHub readme:

Challenge Reunion/Home windows App SDK makes it simpler to construct an incredible Home windows app by offering a unified platform for brand spanking new and current Win32 and UWP apps. It is going to unify entry to current Win32 and UWP APIs and make them out there decoupled from the OS, through instruments like NuGet.

https://github.com/microsoft/WindowsAppSDK

Now, what does this imply concerning level 4, WinRT, of our checklist? It signifies that the trendy WinRT API of Home windows 10/11 is accessible in your functions, irrespective of for those who construct WinUI in UWP, WinUI in Desktop, WPF or Home windows Types:

1. UWP app – for brand spanking new apps, don’t use “Clean App (Common Winows)” template, however “WinUI in UWP” template that creates a UWP app that references the WinUI 3.0 NuGet package deal.
2. UWP XAML framework => a part of WinUI 3.0 NuGet package deal
3. UWP XAML controls => a part of WinUI 3.0 NuGet package deal

4. WinRT => a part of Home windows 10 and out there for UWP and Win32 functions
5. UWP packaging => a part of Home windows 10, based mostly on MSIX format. Additionally Win32 functions could be packaged through MSIX to put in/uninstall them in a clear method.
6. UWP app mannequin => a part of Home windows 10, out there on all Home windows 10 gadgets, not solely PC/Desktop. With WinUI 3.0, you’ll be able to select between this app mannequin or the standard Win32 app mannequin

Abstract

Now you might have seen that WinUI 3.0 is definitely simply part of the UWP universe. WinUI 3.0 comprises the UWP XAML framework and the UWP XAML controls. However UWP as such comprises many extra issues, just like the app mannequin with the sandbox, the packaging performance and the WinRT API. All these items are constructed into Home windows since model 10.

The Home windows App SDK (previously referred to as Challenge Reunion) makes all of that out there to Home windows desktop builders, irrespective of which UI framework they’re utilizing.

WinUI 3.0 itself is definitely a sub undertaking of the Home windows App SDK, as a result of WinUI 3.0 permits you to construct desktop apps with Win32, UWP, .NET/C# and likewise C++. It’s your alternative what you wish to use. Additionally MSIX is a sub undertaking of the Home windows App SDK, because it permits you to package deal your utility for Home windows 10/11, irrespective of in case you have created a WinUI in UWP, WinUI in Desktop, WPF or Home windows Types utility.

Now, how can we reply the query: What is definitely a UWP app?

There are builders who advised me that they’ve created a UWP app for the Microsoft Retailer, however what they really did was packaging a WPF app as MSIX. Is {that a} UWP app? They use UWP packaging performance, however I wouldn’t name {that a} UWP app. For me, a UWP app is an utility that runs on the UWP app mannequin, within the sandbox. That’s it. Right this moment you’ll be able to construct such an app with WinUI 3.0. In the event you want full system entry and the sandbox is a matter, since you’re constructing for instance a file explorer that may execute totally different instructions, you need to use WinUI in Desktop to get an app that makes use of the Win32 app mannequin. All the present UWP performance of Home windows like WinRT or packaging is all the time out there for you, irrespective of for those who go together with the UWP or with the Win32 app mannequin.

I hope this weblog submit has shed some mild into the darkish.

Please depart your ideas and questions within the feedback.

In case you have a Pluralsight subscription, additionally take a look at the Fundamentals of Building .NET Desktop Applications course to be taught extra in regards to the totally different UI frameworks for .NET desktop functions.

Thanks for studying,
Thomas



Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top