vendredi 1 mai 2020

TFS build failing when adding a .runsettings file

I'm trying to specify a runsettings file from VS to add some coverage rules.

Since I added it, one of the tests started to fail.

The test uses reflection to load a dependent assembly and enforce some validation on its classes.

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

The error I get is:

System.IO.FileNotFoundException: Could not load file or assembly 'MyAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

This works fine locally.

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.

This is my .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>

What am I doing wrong?





Aucun commentaire:

Enregistrer un commentaire