Visual Studio .runsettings excluding too many assemblies

1.1k views Asked by At

I am using a .runsettings file to manage the assemblies which generate code coverage results.

With the following section in my .runsettings file I get all the assemblies including my test projects some unwanted TFSBuildExtensions assemblies:

<!-- Match assembly file paths: -->
<ModulePaths>
  <Include />
  <Exclude />
</ModulePaths>

So I modified it to exclude my test projects which are all named MyCompany.MyProject1.Tests.dll

<!-- Match assembly file paths: -->
<ModulePaths>
  <Include />
  <Exclude>
    <ModulePath>.*Tests.*</ModulePath>
  </Exclude>
</ModulePaths>

However now all my assemblies are excluded and I'm left only with the TFSBuildExtensions assemblies.

What should I be specifying in the exclude section to exclude the following assemblies?

  • MyCompany.MyProject1.Tests.dll
  • ...
  • MyCompany.AnyProjectName.Tests.dll
  • TFSBuildExtensions.XXX.dll
2

There are 2 answers

0
openshac On BEST ANSWER

OK so I found what the issue was here: https://stackoverflow.com/a/15961727/283787

The Regex is looking for a path, not just a module name, you need the .* in front of the module to ignore it – that is, you want to ignore it at any given file path.

So when I changed it to following it worked fine:

<ModulePaths>
  <Exclude>
    <ModulePath>.*tests\.dll$</ModulePath>
    <ModulePath>.*tfsbuildextensions\..*\.dll$</ModulePath>
  </Exclude>
</ModulePaths>
1
Andrea Salicetti On

This should do what you want:

<!-- Match assembly file paths: -->
<ModulePaths>
  <Include />
  <Exclude>
    <ModulePath>^.*Tests\.dll$</ModulePath>
    <ModulePath>^tfsbuildextensions\..*\.dll$</ModulePath>
  </Exclude>
</ModulePaths>