Exclude WCF datasource file from SonarQube analysis

710 Views Asked by At

After updating to the MSBuild Runner V1 SonarQube picks up the reference to WCF Datasource files and tries to analyse it. This breaks ofc due to the length of the full path being longer than limit set by MS and logs the following error:

Cannot evaluate the item metadata "%(FullPath)". The item metadata "%(FullPath)"

Is there a way to exclude datasource files. We tried adding *.datasource to the exclusion tab but made no difference.

Using MSbuild.SonarQube.Runner V1 with SonarQube 5.1

1

There are 1 best solutions below

1
On

You can exclude individual files from analysis by setting the metadata property SonarQubeExclude in the individual project files e.g.

<ItemGroup>
  <Compile Include="MyFile.cs">
    <!-- Exclude the file from analysis -->
    <SonarQubeExclude>true</SonarQubeExclude>
  </Compile>
</ItemGroup>

See the documentation on GitHub for more info.

You should be able to use an MSBuild ItemGroupDefinition to automatically set the metadata item for all *.datasource files.