简体   繁体   English

使用VS 2015代码分析器时出错

[英]Error using VS 2015 code analyzers

Using Visual Studio 2015 RTM, I have a .NET 4.0 class library project. 使用Visual Studio 2015 RTM,我有一个.NET 4.0类库项目。

I've added the Microsoft.CodeAnalysis.FxCopAnalyzers NuGet package to the project. 我已将Microsoft.CodeAnalysis.FxCopAnalyzers NuGet包添加到项目中。 This results in the following Analyzers being listed for the project in Solution Explorer. 这导致在解决方案资源管理器中为该项目列出了以下分析器。

  • Microsoft.AnalyzerPowerPack.Common 微软AnalyzerPowerPack.Common
  • Microsoft.AnalyzerPowerPack.CSharp Microsoft.AnalyzerPowerPack.CSharp
  • System.Runtime.Analyzers System.Runtime.Analyzers
  • System.Runtime.CSharp.Analyzers System.Runtime.CSharp.Analyzers
  • System.Runtime.InteropServices.Analyzers System.Runtime.InteropServices.Analyzers
  • System.Runtime.InteropServices.CSharp.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. 无法加载分析器程序集C:\\ Dev \\ git \\ MySolution \\ packages \\ System.Runtime.Analyzers.1.0.0 \\ analyzers \\ dotnet \\ cs \\ System.Runtime.Analyzers.dll:无法加载文件或程序集'System.Runtime .Analyzers,版本= 1.0.0.0,区域性=中性,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。 Strong name validation failed. 强名验证失败。 (Exception from HRESULT: 0x8013141A) (来自HRESULT的异常:0x8013141A)

(and similar for System.Runtime.CSharp.Analyzers and System.Runtime.InteropServices.Analyzers) (和类似的System.Runtime.CSharp.Analyzers和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? 是否有办法使它们起作用,或者可能与.NET 4.0项目有关?

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. 上载到nuget的System.Runtime。*分析器程序集确实仅经过测试签名,因此会导致程序集加载失败。 We are working uploading newer nuget packages for System.Runtime.Analyzers and System.Runtime.InteropServices.Analyzers which will have signed assemblies. 我们正在为System.Runtime.Analyzers和System.Runtime.InteropServices.Analyzers上载较新的nuget程序包,这些程序包将具有已签名的程序集。

Meanwhile, you can get the non System.Runtime based FXCop analyzers by installing "Microsoft.AnalyzerPowerPack" from here: https://www.nuget.org/packages/Microsoft.AnalyzerPowerPack/ . 同时,可以通过从以下位置安装“ Microsoft.AnalyzerPowerPack”来获得非基于System.Runtime的FXCop分析器: 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. 一旦我们上传了签名的System.Runtime分析器程序包,我将在此线程上发布更新。

Sorry for the inconvenience and thanks again for reporting it! 不便之处,敬请见谅。

Regards, Manish 问候,Manish

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM