Error using VS 2015 code analyzers

1

Using Visual Studio 2015 RTM, I have a .NET 4.0 class library project.

I've added the Microsoft.CodeAnalysis.FxCopAnalyzers NuGet package to the project. This results in the following Analyzers being listed for the project in Solution Explorer.

  • Microsoft.AnalyzerPowerPack.Common
  • Microsoft.AnalyzerPowerPack.CSharp
  • System.Runtime.Analyzers
  • System.Runtime.CSharp.Analyzers
  • System.Runtime.InteropServices.Analyzers
  • System.Runtime.InteropServices.CSharp.Analyzers

However in the Error List window, the following error appears:

Unable to load Analyzer assembly C:\Dev\git\MySolution\packages\System.Runtime.Analyzers.1.0.0\analyzers\dotnet\cs\System.Runtime.Analyzers.dll : Could not load file or assembly 'System.Runtime.Analyzers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)

(and similar for System.Runtime.CSharp.Analyzers and System.Runtime.InteropServices.Analyzers)

The first two analyzers do work correctly, but I'm not getting anything for the last four (probably related to the above errors).

Is there a way to get these to work, or is it possibly related to the project being .NET 4.0?

c#
visual-studio-2015
roslyn
asked on Stack Overflow Jul 22, 2015 by David Gardiner

1 Answer

5

Thank you for reporting this issue. The System.Runtime.* analyzer assemblies uploaded to nuget are indeed only test-signed, and hence cause the assembly load failures. We are working uploading newer nuget packages for System.Runtime.Analyzers and System.Runtime.InteropServices.Analyzers which will have signed assemblies.

Meanwhile, you can get the non System.Runtime based FXCop analyzers by installing "Microsoft.AnalyzerPowerPack" from here: https://www.nuget.org/packages/Microsoft.AnalyzerPowerPack/. These do contain all signed assemblies and should work fine.

I'll post an update on this thread once we have uploaded signed System.Runtime analyzer packages.

Sorry for the inconvenience and thanks again for reporting it!

Regards, Manish

answered on Stack Overflow Jul 22, 2015 by Manish Vasani

User contributions licensed under CC BY-SA 3.0