2

I'm creating a Xamarin shared project (but this could apply to C#/Visual Studio in general) that I'd like to reuse in more than one solution.

Some of the classes use constant strings to define IDs and similar, for example:

private readonly string CLIENT_ID = "myID";
private readonly string USERPOOL_ID = "myUserPool";

Is there a way to define some kind of environment variable or macro, so I can specify different IDs for different projects? I would like to achieve something like this:

private readonly string CLIENT_ID = $(CLIENT_ID);
private readonly string USERPOOL_ID = $(USER_POOL_ID);
G.Arna
  • 21
  • 2
  • Sorry - realised that .configs don't really work on iOS/Android projects. Although you could possibly do something similar with the manifest files? – Zhaph - Ben Duguid May 18 '18 at 09:03
  • You could use PCLAppConfig to "simulate" using a normal `app.config` via https://github.com/mrbrl/PCLAppConfig and modify the app.config before building (either manually or via script)... personally if you go way, you might as well just use å script to modify a single `.cs` file via a search and replace routine and skip the PCLAppConfig. – SushiHangover May 18 '18 at 09:07

0 Answers0