How to use variable in MAUI AndroidManifest.xml file based on configuration

369 views Asked by At

I'd like to use different values for dev,qa,prod environments in .Net MAUI app AndroidManifest.xml file or different version of the file like AndroidManifest.dev.xml, AndroidManifest.release.xml.

I could not find any example, can someone point me right direction?

Thanks,

1

There are 1 answers

0
Jessie Zhang -MSFT On

Configuration files provide an easy and efficient way to manage environment based settings and variables. You can start by following steps:

1.creating Build Configurations in your project

enter image description here

2.Configure Android Manifest Files for your Environments

You can start by creating AndroidManifest for all your environments. You can duplicate the existing AndroidManifest.xml and rename it for each environment in your solution.

And then edit your .csproj file:

<AndroidManifest>Platforms\Android\$(Configuration)\AndroidManifest.xml</AndroidManifest>
</PropertyGroup>

3.Set up Environment Based Configuration.

4.Read Configurations

Note:

The specific method of setting and reading variables is different, but the overall implementation process is similar.

For more information, you can refer to the following links:

How to switch AndroidManifest.xml for multiple Android builds.

Managing Configurations.