Reputation: 217
How can I publish a .net MAUI Application to a Single executable? Is this even possible? I Have an application which I want my friends to use on their Windows PC. Is there any way without using the command prompt?
Upvotes: 19
Views: 15881
Reputation: 3451
Try this for net8.0-windows10.0.19041.0
msbuild /restore /t:build /p:TargetFramework=net8.0-windows10.0.19041.0 /p:configuration=release /p:WindowsAppSDKSelfContained=true /p:Platform=x64 /p:WindowsPackageType=None /p:RuntimeIdentifier=win-x64
Upvotes: 1
Reputation: 6828
1- Add a <WindowsPackageType>
node to your .NET MAUI csproj file:
<WindowsPackageType Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">None</WindowsPackageType>
2- In your launchSettings.json set commandName
to Project
3- Build your project in Release
mode
4- Right click on the project -> Open Folder in File Explorer
5- The exe file located in: bin -> Release -> net7.0-windows10.0.19041.0 -> win10-x64
Upvotes: 13
Reputation: 262
With the new release of .net MAUI 6.0.400 (Service Release 1) you can build your application to a working exe file.
In Visual Studio:
Right click your solution, open in terminal.
Run the following command:
msbuild /restore /t:build /p:TargetFramework=net6.0-windows10.0.19041 /p:configuration=release /p:WindowsAppSDKSelfContained=true /p:Platform=x64 /p:WindowsPackageType=None /p:RuntimeIdentifier=win10-x64
or if you want to target x86 for some legacy system:
msbuild /restore /t:build /p:TargetFramework=net6.0-windows10.0.19041 /p:configuration=release /p:WindowsAppSDKSelfContained=true /p:Platform=x86 /p:WindowsPackageType=None /p:RuntimeIdentifier=win10-x86
The build exe (x64) file can be found in \bin\x64\release\net6.0-windows10.0.19041\win10-x64
Publishing to a single file is possible but currently a little bugged, for example images need to be copied from the build folder into the publish folder to work. Images used via Blazor in the wwwroot folder work without a problem though.
Publishing command:
msbuild /restore /t:Publish /p:TargetFramework=net6.0-windows10.0.19041 /p:configuration=release /p:WindowsAppSDKSelfContained=true /p:Platform=x64 /p:PublishSingleFile=true /p:WindowsPackageType=None /p:RuntimeIdentifier=win10-x64
The build exe (x64) file can be found in \bin\x64\release\net6.0-windows10.0.19041\win10-x64\publish\
Upvotes: 25