Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft] [Design mode] Invoking vstest.console with environment variables #2023

Merged
merged 2 commits into from
May 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this check


/// <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