Create a new WinUI 3 and Uno Platform app

Uno Platform apps can be created in both UWP-compatible (Windows.UI.Xaml, also known as WUX) and WinUI 3-compatible (Microsoft.UI.Xaml, also known as MUX) flavors. In the latter case, you can use the latest features of .NET 5 and WindowsAppSDK (formerly known as "Project Reunion") for WinUI 3 Desktop apps. This article takes you through the steps of creating a WinUI 3-flavored Uno Platform app and running the app with WindowsAppSDK for Desktop.

Prerequisites

Set up your environment

  1. Install the Uno Platform dotnet templates. From a command-line prompt, run the following command:
    dotnet new -i Uno.ProjectTemplates.Dotnet
    

Create a new app

  1. Create a folder for your app.
  2. From a command-line prompt at that folder location, run the following command:
    dotnet new unoapp-winui -o MyUnoApp
    
  3. Open the solution file you created.
  4. UI Tooling features (Live Visual Tree, Live Property Explorer, and Hot Reload) for WinUI 3 need to be enabled in Visual Studio as a Preview Feature. Navigate to Tools -> Options -> Environment -> Preview Features and toggle "Enable UI Debugging Tooling for WinUI 3 Projects". Preview Feature screenshot
  5. To debug the WinUI 3 Desktop project, set [MyAppName].Windows.Package as the startup project, set the Solution Platform to x86, and run the application.

Create a new app with .NET 6

  1. Create a folder for your app.
  2. From a command-line prompt at that folder location, run the following command:
    dotnet new unoapp-winui-net6 -o MyUnoApp
    
  3. To debug the WinUI 3 Desktop project, set [MyAppName].Windows as the startup project, set the Solution Platform to x86, and run the application.

Note that this project template comes with two packaging flavors (packaged or unpackaged). Depending on the one you will choose, you'll need to adjust these properties (WindowsAppSDKSelfContained or SelfContained).

If the application is started in an mismatched configuration, you'll get this runtime error:

System.DllNotFoundException: 'Unable to load DLL 'Microsoft.ui.xaml.dll' or one of its dependencies: The specified module could not be found.

Further reading