简体   繁体   English

VS2015诊断与代码修复 - NuGet或VSIX或两者?

[英]VS2015 Diagnostic with Code Fix - NuGet OR VSIX OR both?

When using the .NET Compiler Platform SDK Templates ( https://visualstudiogallery.msdn.microsoft.com/849f3ab1-05cf-4682-b4af-ef995e2aa1a5 ) 使用.NET编译器平台SDK模板时( https://visualstudiogallery.msdn.microsoft.com/849f3ab1-05cf-4682-b4af-ef995e2aa1a5

to create a Roslyn Diagnostic with Code Fix, I get both a NuGet package and a VSIX - as stated by the readme: 使用Code Fix创建一个Roslyn Diagnostic,我得到一个NuGet包和一个VSIX - 如自述文件所述:

"Building this project will produce an analyzer .dll, as well as the following two ways you may wish to package that analyzer: “构建此项目将生成一个分析器.dll,以及您可能希望打包该分析器的以下两种方法:

  • A NuGet package (.nupkg file) that will add your assembly as a project-local analyzer that participates in builds. 一个NuGet包(.nupkg文件),它将您的程序集添加为参与构建的项目本地分析器。

  • A VSIX extension (.vsix file) that will apply your analyzer to all projects and works just in the IDE." 一个VSIX扩展(.vsix文件),它将您的分析器应用于所有项目,并且只在IDE中工作。“

Now the following scenario: what if both are installed – the NuGet as part of the project (eg company policy for this project), the VSIX part of the developer's local installation (eg so she gets the analyzers for other projects too). 现在出现以下情况:如果两者都已安装 - 作为项目的一部分的NuGet(例如,该项目的公司策略),开发人员本地安装的VSIX部分(例如,因此她也获得了其他项目的分析器)。 As of today, the suggestions will show up twice for the aforementioned scenario. 截至今天,建议将针对上述情况出现两次

Can I somehow tell VS2015 that both (NuGet/VSIX) are actually the same (and it runs once only)? 我可以告诉VS2015两者(NuGet / VSIX)实际上是相同的(它只运行一次)? Or is one approach preferred for deployment (eg NuGet) and the other (VSIX) only intended for debugging the diagnostic (more convenient than NuGet)? 或者是一种优先用于部署的方法(例如NuGet)而另一种方法(VSIX)仅用于调试诊断(比NuGet更方便)? Is there some official guidance on this? 对此有一些官方指导吗?

(Note: I work on NR6Pack) (注意:我在NR6Pack上工作)

We recently made a change to unify based on the analyzer name. 我们最近根据分析仪名称进行了统一更改。 So in the case where the VSIX analyzer and the Project analyzer both have the same AssemblyName, it will only be run once and issues will be reported only once in the error list. 因此,在VSIX分析器和Project分析器都具有相同AssemblyName的情况下,它只会运行一次,并且只会在错误列表中报告一次问题。 This change should show up in the next update for VS2015 (it didn't make it into the recently released VS 2015 CTP5 though unfortunately). 此更改应显示在VS2015的下一次更新中(尽管不幸的是它没有进入最近发布的VS 2015 CTP5)。

Regarding NuGet vs VSIX as a deployment mechanism choice: 关于NuGet vs VSIX作为部署机制的选择:

  • Deploying through NuGet and attaching an analyzer to a project means that the analyzer travels with the project to sourcecontrol and so it's easy to apply the same rule for the team. 通过NuGet进行部署并将分析器附加到项目意味着分析器随项目一起移动到源控制,因此很容易为团队应用相同的规则。 It also means commandline builds report the issues reported by the analyzer. 它还意味着命令行构建报告分析器报告的问题。
  • Deploying as a VSIX means that every project in the VS and those issues wouldn't be produced through command line builds. 部署为VSIX意味着VS中的每个项目都不会通过命令行构建生成。

The way I imagine this is that most rules should be deployed through NuGet and enforced at team-level but rules that are personal preferences should probably be deployed through VSIXes. 我想象的方式是大多数规则应该通过NuGet部署并在团队级别强制执行,但个人偏好的规则应该通过VSIX来部署。

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

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