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

Specify environment variables in the runsettings file #2100

Closed
ViktorHofer opened this issue Jul 19, 2019 · 3 comments
Closed

Specify environment variables in the runsettings file #2100

ViktorHofer opened this issue Jul 19, 2019 · 3 comments

Comments

@ViktorHofer
Copy link
Member

Specifying environment variables in the runsettings file is necessary to support non-trivial projects that require settings env vars like DOTNET_ROOT. As discussed offline this is a blocker for dotnet repositories like corefx and sdk to onboard onto VSTest (dotnet test / vstest) and being able to use VS Test Explorer.

cc @singhsarab @cltshivash @vitek-karas @mayankbansal018

@vagisha-nidhi
Copy link
Contributor

@ViktorHofer
What is the exact ask here? From what I am understanding, we need the capability to set environment variables before the test run starts.
I'll share a sample runsettings.

<?xml version="1.0" encoding="utf-8"?>
<!-- File name extension must be .runsettings -->
<RunSettings>
 <RunConfiguration>
    <MaxCpuCount>1</MaxCpuCount>
    <ResultsDirectory>.\TestResults</ResultsDirectory>
    <TargetPlatform>x86</TargetPlatform>
    <TargetFrameworkVersion>Framework40</TargetFrameworkVersion>
    <TestAdaptersPaths>%SystemDrive%\Temp\foo;%SystemDrive%\Temp\bar</TestAdaptersPaths>
    <TestSessionTimeout>10000</TestSessionTimeout>
  </RunConfiguration>
  <DataCollectionRunSettings>
    <DataCollectors>
     </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
  <EnvironmentVariables>
    <!-- List of environment variables we want to set as element and its value-->
    <DOTNET_ROOT>C:\ProgramFiles\dotnet</DOTNET_ROOT>
    <SDK_PATH>C:\Codebase\Sdk</SDK_PATH>
  </EnvironmentVariables>
</RunSettings>

These environment variables will be set when test host process is launched as part of its ProcessStartInfo.

@ViktorHofer Is there anything else to be taken into consideration?

cc: @singhsarab @PBoraMSFT

@singhsarab
Copy link
Contributor

Things to consider:

  1. Should we have a separate node? or should this node be part of the RunConfiguration node itself?
  2. Will this run in isolation always (i.e. tests run in test host) ?
  3. Can users give these settings as commandline arguments ?

@vagisha-nidhi
Copy link
Contributor

@ViktorHofer Also, there is an option to specify run parameters as key value pairs which can be used at run time. Does this suffice your need?
Or is it necessary to set the variables during test host process start?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants