Publishing .NET MAUI Apps with VS Code

In this tutorial, I will guide you through the step-by-step process of publishing .NET MAUI apps using Visual Studio Code and the ‘.NET MAUI – Archive / Publish tool’ extension by me. This extension simplifies the publishing process by providing a user-friendly interface within VS Code.

Without the help of an extension

You will need to dive into a terminal, and give out the following commands, based on which platform you want to build for.

# Android:
dotnet publish -f net8.0-android -c Release -p:AndroidKeyStore=true -p:AndroidSigningKeyStore={filename}.keystore -p:AndroidSigningKeyAlias={keyname} -p:AndroidSigningKeyPass={password} -p:AndroidSigningStorePass={password}
# iOS:
dotnet publish -f net8.0-ios -c Release -p:ArchiveOnBuild=true -p:RuntimeIdentifier=ios-arm64 -p:CodesignKey="Apple Distribution: John Smith (AY2GDE9QM7)" -p:CodesignProvision="MyMauiApp"

You can learn more, how to do it without my extension at:
https://learn.microsoft.com/en-us/dotnet/maui/ios/deployment/publish-cli?view=net-maui-8.0
and
https://learn.microsoft.com/en-us/dotnet/maui/android/deployment/publish-cli?view=net-maui-8.0

But don’t waste your time. I’ve put together a Visual Studio Code extension for you that will easily save you those unnecessary lines and allow you to publish from the UI.

Step 1: Install VS Code Extension


Visit the VS Code Marketplace and install the ‘.NET MAUI – Archive / Publish tool’ extension by ‘banditoth’.

You might be required to reload your VS Code instance.

Step 2: Open Your .NET MAUI Project

Launch Visual Studio Code and open your .NET MAUI project.

Step 3: Access the Command Palette

Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac) to open the command palette in Visual Studio Code.

Step 4: Choose Publish Android or Publish iOS

Type ‘MAUI Publish’ in the command palette. You will see two options: ‘MAUI: Publish Android’ and ‘MAUI: Publish iOS’. Select the one that corresponds to your target platform.

Publishing for Android:

The extension will prompt you to choose between a signed or non-signed binary. Select your preferred option.

Next, choose the package format – either apk (Android Package) or aab (Android App Bundle).

If signing is required (for a signed binary), the extension will list all installed keystore files. Choose the appropriate keystore.

Enter the keystore password when prompted.

The extension will start the publishing process, and you’ll see progress information directly in the VS Code output.

Publishing for iOS:

Select ‘MAUI: Publish iOS’ from the command palette.

The extension will ask for the code signing identity. Choose the desired code signing identity from the available options.

Next, choose a provisioning profile to sign the app.

The extension will initiate the publishing process for iOS, displaying progress information in the VS Code output.

Conclusion

With the ‘.NET MAUI – Archive / Publish tool’ extension, publishing your .NET MAUI apps for Android and iOS becomes a straightforward process within Visual Studio Code. You no longer need to manually execute complex CLI commands; instead, you can leverage the extension’s user-friendly interface for a seamless publishing experience. Enjoy the convenience and efficiency of this simplified workflow for your .NET MAUI projects!

Support the project

You can find more information about how to contribute on this project at the project’s github page: https://github.com/banditoth/maui-archiver-vscode

.NET Core : Run Core apps as Windows service.

You may want to host your .NET Core application in a Windows computer, even a Windows server. You want to get rid of Console windows, and do not want to start the app manually after the computer is started, or restart it when the application has crashed. This tutorial helps you to make a windows service from your .NET Core application, especially a .NET Core WebAPI.

Install the “Microsoft.Extensions.Hosting.WindowsServices” NuGet package for you .NET Core application. This can be achieved from NuGet package manager console:

Install-Package Microsoft.Extensions.Hosting.WindowsServices

Make changes in your Program.cs file. Add the UseWindowsService call to the CreateHostBuilder function. The result may look something like this:

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseUrls("https://0.0.0.0:8080/", "http://0.0.0.0:8081/");
                    webBuilder.UseStartup<Startup>();
                })
                .ConfigureLogging((hostingContext, logging) =>
                {
                    logging.ClearProviders();
                    logging.AddConsole();
                })
                .UseWindowsService();

This is all of the code change you need to do.
Let’s Publish your application.

Publish your application to a folder

Make the following changes in the following dialog by pressing an edit button next to a summary label.

Set the deployment mode toself-contained

Click on Publish. Once the publish is done, copy the published files to a specific directory of the computer, or an another computer. Run the powershell script above, to create a new windows service on the hosting computer.

# New-Service documentation: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/new-service?view=powershell-7.1
# Script by banditoth

$serviceName = "typeyourservicename";
$serviceDescription = "typeyourdescription";
$displayName = "displayname";
$exeFilePath = "pathtoyourexefile.exe";
$serviceUserName = "MustBeDomain\User";

New-Service -Name $serviceName -DisplayName $displayName -BinaryPathName $exeFilePath -Credential $serviceUserName -Description $serviceDescription -StartupType Automatic

Do NOT forget to set the inbound policies for your application in Advanced Windows Firewall. Also keep in mind, if you want to access your web application outside of your local network, you need to forward ports on your router.

This content has 3 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

AppStore publish error: ITMS-90809 (Deprecated API Usage WebView-re [Xamarin])

Alkalmazás publikálásánál az AppStore-ban a következőt jelzi vissza az Apple:

ITMS-90809: Deprecated API Usage - Apple will stop accepting submissions of apps that use UIWebView APIs . See https://developer.apple.com/documentation/uikit/uiwebview for more information.

Ez azért van, mert a Xamarin Forms WebView implementációja a Xamarin Forms 4.4-es verziójánál kisebb verziókban a UIWebView-t használja platformspecifikus implementációként. (Forrás: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/webview?tabs=windows#performance)

"Therefore, since Xamarin.Forms 4.4, the Xamarin.Forms WebView is implemented on iOS by the WkWebView class, which supports faster browsing."

Főverzió frissítése után nem szabad dobnia a hibát a publikálásnál. Az alkalmazás publikálása ettől függetlenül végbemegy, amennyiben csak ez a hiba

This content has 4 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

AppStore publish error: ITMS-90717 (Alpha csatornás PNG ikon)

Transporter app-al való alkalmazásfeltöltésnél az AppStore-ba hibát dob:

ERROR ITMS-90717: "Invalid App Store Icon. The App Store Icon in the asset catalog in 'SimpleTaxiOrderXamarin.iOS.app' can't be transparent nor contain an alpha channel."

Ebben az esetben nem az info.plist-ben lévő iTunes Artworkot kell módosítani, hanem az alkalmazás ikonjának kiválasztott AssetCatalogban lévő AppStore ikonokat.

Hasznos tool az alkalmazás ikonok elkészítéséhez: https://appicon.co/

This content has 4 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.