【问题标题】:TFS build failing when adding a .runsettings file添加 .runsettings 文件时 TFS 构建失败
【发布时间】:2020-08-16 07:18:13
【问题描述】:

我正在尝试从 VS 指定一个运行设置文件以添加一些覆盖规则。

自从我添加它后,其中一个测试开始失败。

测试使用反射来加载依赖程序集并对其类进行一些验证。

String FluentMigratorFullName = "MyAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null";
var fluentMigratorAssemblyName = new AssemblyName(FluentMigratorFullName);
var fluentMigratorAssembly = Assembly.Load(fluentMigratorAssemblyName);

我得到的错误是:

System.IO.FileNotFoundException:无法加载文件或程序集“MyAssembly,Version=0.0.0.0,Culture=neutral,PublicKeyToken=null”或其依赖项之一。系统找不到指定的文件。

这在本地运行良好。

我知道有一个 AssemblyResolution 参数,但在每次执行时位置会有所不同,因为它取决于接收构建的代理。

这是我的 .runsettings

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <!-- Configurations that affect the Test Framework -->
  <RunConfiguration>

  </RunConfiguration>

  <!-- Configurations for data collectors -->
  <DataCollectionRunSettings>
    <DataCollectors>
      <DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
        <Configuration>
          <CodeCoverage>
            <ModulePaths>
              <Exclude>
                <ModulePath>.*MyModule.*</ModulePath>
              </Exclude>
            </ModulePaths>

            <!-- We recommend you do not change the following values: -->
            <UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
            <AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
            <CollectFromChildProcesses>True</CollectFromChildProcesses>
            <CollectAspDotNet>False</CollectAspDotNet>

          </CodeCoverage>
        </Configuration>
      </DataCollector>

    </DataCollectors>
  </DataCollectionRunSettings>

  <!-- Parameters used by tests at runtime -->
  <TestRunParameters>

  </TestRunParameters>

  <!-- Adapter Specific sections -->

  <!-- MSTest adapter -->
  <MSTest>
    <MapInconclusiveToFailed>false</MapInconclusiveToFailed>
    <CaptureTraceOutput>true</CaptureTraceOutput>
  </MSTest>

</RunSettings>

更新:

我注意到“在多核机器上并行运行测试”之前处于活动状态。

重新打开它可以解决问题。知道为什么吗?

【问题讨论】:

  • 如果设置了 runInParallel,测试将利用机器的可用内核并行运行。如果在运行设置文件中指定,这将覆盖 MaxCpuCount。 I know there is a AssemblyResolution parameter, but the location would be different at each execution as it depends on the agent picking up the build. 在多个代理中运行测试时是否会出现一些冲突,从而导致您的问题出现错误。
  • 最后我们在一个单独的测试中运行了有问题的测试。老实说,日志提供的信息不是很好,不得不创建一个单独的代理队列来启用融合日志似乎有点过头了。

标签: c# unit-testing reflection tfs


【解决方案1】:

最后,我们最终在单独的测试步骤上运行了有问题的测试。老实说,日志提供的信息不是很好,必须创建一个单独的代理队列来启用融合日志似乎有点过头了。

【讨论】:

    猜你喜欢
    • 2011-01-15
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    • 2020-04-24
    • 1970-01-01
    相关资源
    最近更新 更多