我正在寻找一种使用相对文件路径定义程序集分辨率值的方法。
我按照 Microsoft文档的建议通过定义和引用环境变量来解决此问题。正如您从下面的代码片段中看到的,我定义了一个环境变量“test”,并在 MSTest 适配器部分引用它。使用 VS 编译和运行测试会产生有关缺少引用依赖项的错误。
我已经验证通过将“测试”值设置为等于硬编码目录路径可以解决此问题。除了代码片段中设置的值之外,我还尝试了以下“test”值定义,但没有成功:
<RunConfiguration>
<MaxCpuCount>1</MaxCpuCount>
<!-- Path relative to directory that contains .runsettings file-->
<ResultsDirectory>.\TestResults</ResultsDirectory>
<!-- x86 or x64 -->
<!-- You can also change it from the Test menu; choose "Processor Architecture for AnyCPU Projects" -->
<TargetPlatform>x86</TargetPlatform>
<!-- Framework35 | [Framework40] | Framework45 -->
<TargetFrameworkVersion>Framework40</TargetFrameworkVersion>
<!-- Path to Test Adapters -->
<TestAdaptersPaths>%SystemDrive%\Temp\foo;%SystemDrive%\Temp\bar</TestAdaptersPaths>
<!-- TestSessionTimeout was introduced in Visual Studio 2017 version 15.5 -->
<!-- Specify timeout in milliseconds. A valid …Run Code Online (Sandbox Code Playgroud)