12

I'm planing to create a cross platform application. Minimal supported platforms should be android and windows. I'd like to end up with a classical windows executable, not a UWP app. The new maui platform looks like it might fit.

I've already downloaded the current pre-release version of visual studio 2022 and create a new maui project. When I compile and run it on windows the application visual studio creates is a UWP app. The official microsoft page for maui states:

.NET Multi-platform App UI (.NET MAUI) apps can be written for the following platforms:

Android 5.0 (API 21) or higher. iOS 10 or higher. macOS 10.13 or higher, using Mac Catalyst. Windows 11 and Windows 10 version 1809 or higher, using Windows UI Library (WinUI) 3.

https://learn.microsoft.com/en-us/dotnet/maui/supported-platforms

The following issue on github also looks like it might be possible to create a widnows executable:

Publishing to an exe (not self-contained) works but don't take the published folder files, take the build artifacts, see bullet 3 below for all the details

https://github.com/dotnet/maui/issues/4329

I'm a bit confused about the details of the support for windows. Is only windows possible to create a UWP app or can I compile it to a normal desktop application? Can I change the output to be a normal windows executable, if so how?

oyeraghib
  • 878
  • 3
  • 8
  • 26
mugu90
  • 121
  • 1
  • 5
  • 3
    MAUI **does not** support UWP. Its WinUI 3, which makes it "a normal desktop app". More precisely, it runs with more permissions, does not use the "sandbox" used by UWP apps. What exactly are you seeing, that makes you think the Windows build is UWP? – ToolmakerSteve Apr 03 '22 at 01:57
  • Have you tried [MSIX Packaging Tool](https://learn.microsoft.com/en-us/windows/msix/overview)? – ToolmakerSteve Apr 03 '22 at 02:06
  • @ToolmakerSteve When I start debugging the project it is automatically installed into start menu like an app. If I start it from there it works. When I try to run it from Debug/ or Release/ folder nothing happens if I double click the executable it. – mugu90 Apr 03 '22 at 10:14
  • @ToolmakerSteve I've created a MSIX project and tried to add the maui project as a reference but get an error: "To add an application reference, the project output needs to be an executable" – mugu90 Apr 03 '22 at 10:18
  • Sorry, I haven't actually tried packaging it myself yet. Hopefully someone else sees this, who has. – ToolmakerSteve Apr 03 '22 at 15:03
  • It would help if you could clarify what precisely you mean by "a normal desktop application". If you mean a Win32 app, then no. See all the options here: https://learn.microsoft.com/windows/apps/get-started – Matt Johnson-Pint Jun 16 '22 at 19:27
  • Does this answer your question? [Publish .net MAUI Application as windows executable](https://stackoverflow.com/questions/70097744/publish-net-maui-application-as-windows-executable) – Ingo Jul 01 '22 at 16:30

3 Answers3

2

.NET Maui Apps are not UWP apps. They are built using WinUI 3 and the Windows App SDK which produces a Win32 app. Information about the Windows App SDK can be found here and information regarding different app types can be found here.

If you are asking if it is possible to publish a Windows executable file (.exe) then that is not possible. .NET MAUI only allows publishing an MSIX package.

Matt
  • 66
  • 6
1

This is the only way that worked for me, but it is a little bugged.

Open a terminal and run the following command:

msbuild /restore /t:Publish /p:TargetFramework=net6.0-windows10.0.19041 /p:configuration=release /p:WindowsAppSDKSelfContained=true /p:Platform="any CPU" /p:PublishSingleFile=true /p:WindowsPackageType=None /p:RuntimeIdentifier=win10-x64

The build file can be found in \bin\x64\release\net6.0-windows10.0.19041\win10-x64\publish

emilim
  • 109
  • 7
1

Using dotnet then could look like:

Framework Dependent:

dotnet publish -f net6.0-windows -p:WindowsPackageType=None

Self-Contained:

dotnet publish -f net6.0-windows -p:WindowsPackageType=None -p:SelfContained=true -p:WindowsAppSDKSelfContained=true

your build App.exe can be found in \bin\Release\net6.0-windows

DksDev
  • 11
  • 1