44

When I imported an old solution in VS2015 I receive loads of warnings MSB3884 warning: Could not find rule set file .. when building the solution.

Q How can I get rid of this annoying problem?

participant
  • 2,923
  • 2
  • 23
  • 40

5 Answers5

51

You need to edit the .csproj file and find the reference to the CodeAnalysisRuleSetDirectories. Change the version of the Visual Studio reference in the path to the one that is for VS2015 (a.k.a 14) and reload the project. (That worked for me.)

Alternatively delete all references of

<CodeAnalysisRuleSetDirectories>
<CodeAnalysisIgnoreBuiltInRuleSets> 
<CodeAnalysisRuleDirectories> 
<CodeAnalysisIgnoreBuiltInRules>

I found the solution here.

participant
  • 2,923
  • 2
  • 23
  • 40
21

Use the DevEnvDir instead of the hardcoded path to your old version of VS (probably 2010).

<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSetDirectories>;$(DevEnvDir)\..\..\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
timB33
  • 1,977
  • 16
  • 33
  • This worked perfectly for me. In my case it was the older VS 2010 as you have said. I no longer have an install of 2010 - but I assume this isn't backward compatible - meaning if someone else opened the solution in VS 2010 they would get an error or warning? – Don Gossett Feb 25 '16 at 13:19
  • Nevermind - I found someone with 2010, and it IS backward compatible. I think this is the best answer since it will work dynamically regardless of which VS version, at least 2010 - 2015. – Don Gossett Feb 25 '16 at 13:35
  • I think the `;` is misplaced here (from `;$(DevEnvDir)`), I did not put it in and then the path could be found :) – DrCopyPaste Mar 16 '16 at 13:55
  • @DrCopyPaste I'm assuming that since the property is called "directories", plural, the semicolon is just a separator for multiple paths, and is thus either harmless or specifically adds the working directory. – Nyerguds Mar 24 '21 at 09:16
8

Received this warning on a build machine where only VS 2017 Build Tools was installed (VS 2017 not installed). Once I installed the Static analysis tools (Individual components -> Code tools -> Static analysis tools) the warnings went away.

KornMuffin
  • 2,887
  • 3
  • 32
  • 48
1

I solved to add following to app.config.

<Target Name="BeforeBuild">
    <PropertyGroup>
      <CodeAnalysisRuleSet></CodeAnalysisRuleSet>
    </PropertyGroup>
</Target>
  • This was the only thing that seemed to work for me. I placed the new in Directory.Build.targets at the root level. – CPAR Aug 03 '22 at 16:45
1

These binary analyzers are now deprecated link

New projects in VS don't have these lines anymore.

In VS 2019, I solved the problem by editing the project files and removing all lines related to CodeAnalysis, in all PropertyGroups.

sample: .csproj or .vbproj file, red X indicates what I've removed

J Pollack
  • 2,788
  • 3
  • 29
  • 43
fsbflavio
  • 664
  • 10
  • 22