[英]Include code analyzers in a nuget package
I currently have 25+ repositories to maintain.我目前有 25 个以上的存储库需要维护。 For all these repositories I would like to add Code Analysis using Roslyn analyzers.对于所有这些存储库,我想使用 Roslyn 分析器添加代码分析。
Because I want to have to control over the analyzers that are being used from one central location.因为我想从一个中心位置控制正在使用的分析仪。 My idea was to create a NuGet package which is referencing all the analyzers that I need.我的想法是创建一个引用我需要的所有分析器的 NuGet 包。 However, this seems not to be working.但是,这似乎不起作用。
My NuGet package now looks like this:我的 NuGet 包现在看起来像这样:
<ItemGroup>
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.3.0.14607">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
And the nuget package is referenced like this: nuget 包是这样引用的:
<PackageReference Include="NuGet.Package" Version="1.0.0" />
The analyzer SonarQube.CSharp doesn't appear in the list of analyzers in the parent project.分析器 SonarQube.CSharp 没有出现在父项目的分析器列表中。
Should this work?这应该工作吗? And how should I change it to make this work?我应该如何更改它以使其工作?
I seem to have found the solution.我似乎找到了解决办法。 Adding the packagereference in the .props file of the NuGet package will get the analyzer to work.在 NuGet 包的 .props 文件中添加 packagereference 将使分析器工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.