How to build an application correctly in the WinUI3 project template?

RΞY 20 Reputation points
2024-10-15T14:33:58.7666667+00:00

I am working in the Blank App, Packaged (WinUI 3 in Desktop). When compiling and launching a new project in Visual Studio using the keyboard shortcut "Ctrl + F5", the application opens without problems. However, when building the project and going to the Debug folder where the exe file is located, difficulties arise: when trying to open the application through the compiled exe file, nothing happens. The mouse cursor changes to the download cursor for a few seconds, but the application does not start.

I assume that the problem may be related to the Package.appxmanifest file. It is possible that the application is incorrectly packaged in an exe file, and this prevents it from running. When running through Visual Studio, an additional "WinUI Desktop" process is displayed in the task Manager (Attached screenshot), which is not displayed when launching the application through the exe file.Screen

I ask you to help me solve this problem :'(

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
804 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
824 questions
0 comments No comments
{count} votes

Accepted answer
  1. Roy Li - MSFT 33,501 Reputation points Microsoft Vendor
    2024-10-16T02:56:08.6066667+00:00

    Hello,

    Welcome to Microsoft Q&A!

    when trying to open the application through the compiled exe file, nothing happens

    This behavior is by design. For packaged WinUI3 application, it is not allowed to just launch the app from the exe file.

    If you want to make a feature that the app could be launched from the exe file, you will need to create an unpackaged WinUI3 app. What you need to do is modify the project file of the packaged WinUI3 app. Then add the following line to the PropertyGroup part.

      <PropertyGroup>
        ...
        <WindowsPackageType>None</WindowsPackageType>
        <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
        ...
      </PropertyGroup>
    
    

    After adding this, you will see the unpackage mode of the app like this

    User's image

    After building and running the app, now you could find the exe file of your app in the debug folder and directly run it.

    More details about creating a unpackaged app, please check: Unpackaged: Create a new project for an unpackaged C# or C++ WinUI 3 desktop app and Windows App SDK deployment guide for self-contained apps

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.