I have a Windows 10 box where I'm running my own Azure Build Agent that I've installed
I set some environment variables on said box, using setx
commands, like this:
I then rebooted the whole box to ensure whatever process I am launching (visual studio, or build agent) has a proper opportunity to read the environment
Running the code locally in Visual Studio works, and I can write the contents of the vars with a simple Console.WriteLine
within my UnitTest, e.g.:
private static string _user;
private static string _pass;
[ClassInitialize]
public static void ClassInit(TestContext ctx)
{
IConfiguration config = new ConfigurationBuilder()
.AddEnvironmentVariables()
.Build();
_user = config["OrderEntryClient:UnitTestCredentials:UserName"];
_pass = config["OrderEntryClient:UnitTestCredentials:Password"];
Console.WriteLine($"Here are my vars:{_user}-{_pass}");
}
Output: Here are my vars:UserName123-Password123456
I've seen some stuff on the interwebs about MSBuild being picky about environment variables, and maybe this is all by design when running multiple builds on the same machine simultaneously.. but.. what am I doing wrong?
The Console.WriteLine
output on the build agent shows nothing has loaded when I run it