Azure DevOps for .NET MAUI using YML
Tags: dotnetmaui, dotnet, azure, multienvironment
Published: 2022-12-19 17:40:39

NET Multi-platform App UI (**.NET MAUI**) is a cross-platform framework for creating native mobile and desktop apps with C# and XAML. Using .NET MAUI, you can develop apps that can run on Android, iOS, macOS, and Windows from a single shared code-base. In these post series, I will show you how to implement Continuous Integration in your .NET MAUI app using the Microsoft Azure DevOps with YML in a multi-environment.


---
## Disclaimer

The steps below represent an approach I follow for my projects due to they accommodate for my requirements. You are free to update the logic and YML files to fit your needs on each project. Also, in an effort to demo the multi-environment, I am using Firebase Analytics services.

---

## Getting Started
### Shared
- In the Azure Pipelines -> Library upload the Android KeyStore file, the Apple .p12 certificate & provisioning profile files and the Google firebase config files if you are using this service.

> Make sure the Google firebase files are renamed using the following sample: 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yqqwwgk9mazkkyszgha3.png)



- Then create a variable group called: "App Configuration" within the Library, this variable group will contain the configuration keys for the Android and iOS build and we use them because it is the securest way to store the sensitive data.

| Variable | Value |
|--|--|
| app-build-configuration | Release |
| app-check-dependencies | true |
| app-id-android | com.company.appname |
| app-id-ios | com.company.appname |
| app-path-contents | PROJECT_PATH/bin |
| app-path-project | PROJECT_PATH/project.csproj |
| app-path-root | PROJECT_PATH |
| app-target-framework-android | .net7.0-android |
| app-target-framework-ios | .net7.0-ios |
| apple-certificate-name | CERTIFICATE_NAME.p12 |
| apple-certificate-password | ****** |
| apple-provisioning-profile-name | PROFILE_NAME.mobileprovision |
| dotnet-version | 7.0.x |
| android-signing-key-password | ****** |
| android-keystore-alias | ALIAS |
| android-keystore-name | FILE.keystore |
| android-keystore-password | ****** |


### iOS
- Create a new file azure-pipelines-ios.yml in your code repository at any path you prefer.

{% embed https://gist.github.com/vhugogarcia/0011589b8b9f80305c0c1f036ce55f2d %}


### Android
- Create a new file azure-pipelines-android.yml in your code repository at any path you prefer.

{% embed https://gist.github.com/vhugogarcia/257fd2f0a277e9b3dc783b569e88547e %}

Basically, the pipelines will always trigger automatically pointing to the staging environment when a versioning tag is added to a branch, however, you can run the pipeline manually and set the environment pointing to production, so it generates a new version of the app. Just, don't forget to set the version tag before trigger the pipeline manually.

## What About Distribution?
I'm working in a post to share how to distribute the application through different channels. I hope to have it ready soon.


## Conclusion

There are tons of combinations and customizations for the YML and each project may have its own set of rules for CI. Take this just as an example or base and improve it, please!

I hope this helps others to create their own pipelines for .NET MAUI.