DEV Community

Cover image for .NET MAUI: Archive and Publish using Visual Studio Code
Victor Hugo Garcia
Victor Hugo Garcia

Posted on

.NET MAUI: Archive and Publish using Visual Studio Code

.NET MAUI (Multi-platform App UI) is a modern framework for building native cross-platform apps with C# and XAML. With .NET MAUI, you can target Android, iOS, macOS, and Windows platforms with a single codebase and a consistent user interface. In this post, I will show you how to use Visual Studio Code in macOS, a popular and lightweight code editor, to archive and publish your .NET MAUI apps with ease and efficiency.


Recommendations

It is important to highlight that the official documentation from Microsoft is very helpful, and I encourage you to read it. Additionally, it is required for you to install the official .NET MAUI extension in Visual Studio Code.

How to archive and publish for iOS

  1. Open your .NET MAUI app folder on Visual Studio Code. The .NET MAUI extension will automatically load your solution with the referenced projects.
  2. Once Visual Studio Code loaded your project successfully, On the Solution Explorer, select the name of the project.
  3. Open the Visual Studio Code integrated terminal and run the following command: dotnet publish -f net8.0-ios -p:ArchiveOnBuild=true
  4. The previous command will read your project properties you have set on your .csproj file, for example:
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-ios|AnyCPU'">
      <CreatePackage>false</CreatePackage>
      <RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
      <CodesignProvision>Test App Distribution</CodesignProvision>
      <CodesignKey>iPhone Distribution: Known (YYYYY123456)</CodesignKey>
      <CodesignEntitlements>Platforms\iOS\Entitlements.plist</CodesignEntitlements>
      <MtouchLink>SdkOnly</MtouchLink>
      <MtouchUseLlvm>true</MtouchUseLlvm>
    </PropertyGroup>
Enter fullscreen mode Exit fullscreen mode

If your Apple Distribution Certificate and Apple Distribution Profile are valid, the output will be successfully.

  • Once it finishes archiving and publishes the application, Launch XCode on macOS and then open the Organizer by going to the Window menu.
  • On the Organizer window, select the app and version you want to validate and click the Validate button.
  • If the application passes the validation, then click the Upload button and select your preferences, either for TestFlight only or TestFlight & Store.
  • Done.

Once the publishing process finishes on the terminal, what I love about the process above, is that I don't have to worry about the IPA location to upload it manually, and instead I use XCode to manage the upload for me. If you cannot use XCode, you can find the IPA file on the following folder path: bin/Release/net8.0-ios/ios-arm64/publish/ and upload it manually.

How to archive and publish for Android

  1. Open your .NET MAUI app folder on Visual Studio Code. The .NET MAUI extension will automatically load your solution with the referenced projects.
  2. Once Visual Studio Code loaded your project successfully, On the Solution Explorer, select the name of the project.
  3. Open the Visual Studio Code integrated terminal and run the following command: dotnet publish -f net8.0-android -p:ArchiveOnBuild=true
  4. The previous command will read your project properties you have set on your .csproj file, for example:
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-android|AnyCPU'">
      <AndroidKeyStore>True</AndroidKeyStore>
      <AndroidSigningKeyStore>/Users/temp/projects/Certificates/testapp-keystore.jks</AndroidSigningKeyStore>
      <AndroidSigningStorePass>123abc</AndroidSigningStorePass>
      <AndroidSigningKeyAlias>testapp</AndroidSigningKeyAlias>
      <AndroidSigningKeyPass>123def</AndroidSigningKeyPass>
      <AndroidApkSignerAdditionalArguments>123abc</AndroidApkSignerAdditionalArguments>
    </PropertyGroup>
Enter fullscreen mode Exit fullscreen mode
  • If your keystore information is valid, the output will be successfully. So, the signed aab or apk can be uploaded to Google Play Console manually.

You can find the signed aab or apk file on the following folder path: bin/Release/net8.0-android/ and upload it manually.

Conclusion

With these skills, you can streamline your development workflow and deliver high-quality apps to your users. Honestly, I was scared at the beginning when Visual Studio for Mac was deprecated, but then when I saw the .NET MAUI extension in VS Code, I quickly shifted and started enjoying how fast it is to develop there.

I hope you enjoyed this article and found it useful. If you have any questions or feedback, feel free to leave a comment below.

Thank you for reading!

Follow me on Social:

Top comments (2)

Collapse
 
andydonegan profile image
Andy Donegan

Cheers Victor, excellent documentation really helpful thank you !

Collapse
 
alfredopizana profile image
alfredopizana

Really Helpful! Thanks for sharing!