Skip to content

Commit

Permalink
[Draft] [Design mode] Invoking vstest.console with environment variab…
Browse files Browse the repository at this point in the history
…les (#2023)

* Changes to allow clients to provide environment variable while initializing VsTestConsoleWrapper

* Changes based on comments.
  • Loading branch information
singhsarab authored and cltshivash committed May 29, 2019
1 parent 93ffe26 commit 7d28e20
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;

Expand Down Expand Up @@ -37,6 +38,16 @@ public ConsoleParameters(IFileHelper fileHelper)
this.fileHelper = fileHelper;
}

#if NET451

/// <summary>
/// TODO: Remove the #if when project is targeted to netstandard2.0
/// Environment variables to be set for the process
/// </summary>
public Dictionary<string, string> EnvironmentVariables { get; set; }

#endif

/// <summary>
/// Trace level for logs.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Microsoft.TestPlatform.VsTestConsole.TranslationLayer
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers;
using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
Expand Down Expand Up @@ -106,6 +107,19 @@ public void StartProcess(ConsoleParameters consoleParameters)

EqtTrace.Verbose("VsTestCommandLineWrapper: Process Start Info {0} {1}", info.FileName, info.Arguments);

#if NET451
if (consoleParameters.EnvironmentVariables != null)
{
info.EnvironmentVariables.Clear();
foreach (var envVariable in consoleParameters.EnvironmentVariables)
{
if (envVariable.Key != null)
{
info.EnvironmentVariables.Add(envVariable.Key.ToString(), envVariable.Value?.ToString());
}
}
}
#endif
this.process = Process.Start(info);
this.process.Start();

Expand Down

0 comments on commit 7d28e20

Please sign in to comment.