Environment variables for each user in Xamarin Studio

I want to set environment variables in the .NET application runtime in Xamarin Studio for each user. These environment variables can control things such as logging or other debugging-related configurations that should not be widely used.

Consider a few trivial applications:

using System; public class TrivialApplication { public static void Main(string[] args) { Console.WriteLine(Environment.GetEnvironmentValue("NAME")); } } 

I want to be able to add an environment variable for NAME that appears when the application starts or debugs.

I can add environment variables to Project Settings> Run> General> Environment Variables, but they are saved in .csproj , which is version-controlled. I would like them to go to the configuration for each user.

I naively tried to just put the EnvironmentVariables lines in .csproj.user :

 <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <EnvironmentVariables> <EnvironmentVariables> <Variable name="NAME" value="value" /> </EnvironmentVariables> </EnvironmentVariables> </PropertyGroup> </Project> 

However, either my .csproj.user not readable, or environment variables are not applied. How can i do this?

+6
source share

Source: https://habr.com/ru/post/982359/


All Articles