.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.

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

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/