Reputation: 151
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?
Upvotes: 15
Views: 11491
Reputation: 11
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
Upvotes: 1
Reputation: 134
.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.
Upvotes: 3
Reputation: 109
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
Upvotes: 1