VC JS
VC JS

Reputation: 125

Why is .NET MAUI app not running after compile?

this might sound like a novice or stupid question (it probably is).

But I created a very simple .NET MAUI app, almost the same as the default template with slight modifications. It runs well in the editor (default debug, any cpu config), but it won't run the .exe after build.

Build is correct and .EXE is generated, but when trying to run it (regardless of admin rights) it doesn't open any window. Checked the task manager and it opens a task with the exe name that terminates instantly.

Any ideas on why is this happening?

Thanks in advance.

Upvotes: 9

Views: 8112

Answers (2)

Erdogan
Erdogan

Reputation: 400

It's because MSIX Packaging. It's solved by Microsoft already. Please check this issue from MAUI's official GitHub repo.

Add this lines to your csproj file;

<WindowsPackageType>None</WindowsPackageType>
<WindowsAppSDKSelfContained Condition="'$(IsUnpackaged)' == 'true'">true</WindowsAppSDKSelfContained>
<SelfContained Condition="'$(IsUnpackaged)' == 'true'">true</SelfContained>

change your launchSettings.json file like this;

{
    "profiles": {
        "Windows Machine": {
        "commandName": "Project"
        ,
    }
}

and you have to install the Windows App SDK runtime and MSIX packages if it's not installed already.

Upvotes: 7

alansiqueira27
alansiqueira27

Reputation: 8534

I had the same issue, and I solved by installing WinUI3 from Windows Store: https://apps.microsoft.com/store/detail/winui-3-gallery/9P3JFPWWDZRC?hl=en-us&gl=us

To explain: .NET MAUI can run on Windows 10, but only by installing the WinUI3 mentioned above. These are the requirements: https://learn.microsoft.com/en-us/dotnet/maui/supported-platforms?view=net-maui-7.0

Upvotes: 9

Related Questions