1

We are currently working on a Xamarin Forms (.NET Core) application. We use Microsofts DevOps for the code repo, building and deployment.
Since we want to test newly developed features in a safe testing environment, we need to configure the app before building. At the bare minimum we need to swap out the backend uri (e.g. one for testing and one for production).

We thought about using pre-compiler flags, but we would like to keep the configuration away from the code if possible.

Is there an elegant solution or a best practice for handling that?

1 Answers1

0

It's been a while since I did Xamarin, but I believe the approach I used was to have a configuration file as an asset.

Your build steps can modify the configuration file as required pre build and package

Your code then parses the asset text and reads out the configuration values.

This isn't really any different from compiler macros though. Maybe a bit neater if you have large blocks of config.

Alternately, If you app logs on, you can have the login api return settings for the user. Although obviously you now have a hardcoded login url.

Ewan
  • 83,178