openshac
openshac

Reputation: 5165

Visual Studio .runsettings excluding too many assemblies

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?

Upvotes: 1

Views: 1252

Answers (2)

openshac
openshac

Reputation: 5165

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>

Upvotes: 1

Andrea Salicetti
Andrea Salicetti

Reputation: 2483

This should do what you want:

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

Upvotes: 0

Related Questions