如何使用Stylecop Analyzer和自定义规则集创建nuget包?

问题描述 投票:0回答:1

我需要使用stylecop.json和something.ruleset创建一个nuget包,并引用stylecop分析器。该软件包将在所有团队中使用,以标准化.net规则。我读过这篇:

但是很遗憾,我没有正确理解如何实现这一目标。我有stylecop.json和.ruleset文件。我已完成以下步骤:

  • 为Stylecop分析仪添加了nuget包
  • 将stylecop.json文件添加到解决方案中
  • 将.ruleset文件添加到解决方案中
  • 向解决方案添加了nuspec文件

[请让我知道现在要创建包括stylecop.json和.ruleset文件的nuget包需要做什么?

enter image description here

c# .net visual-studio nuget stylecop
1个回答
0
投票

请让我知道现在要创建nuget包需要做什么。包括stylecop.json和.ruleset文件?

您应该在xxx.nuspec中添加有关这些文件的一些节点,然后将nuget.exe cli与xxxx.nuspec文件一起使用来打包您的项目。

自]以来,您已经生成了xxxx.nuspec文件,应将它们添加到nuspec文件中。

解决方案>>

[1)您应该将这些节点添加到xxx.nuspec文件中,并通过nuget将这些文件添加到新项目中。

<?xml version="1.0" encoding="utf-8"?>
<package >
  <metadata>
    .......

<contentFiles>
<files include="any/any/stylecop.json "(the relativepath of the file under the ContentFiles folder in the xxx.nupkg) buildAction="None" copyToOutput="true" flatten="false" />
<files include="any/any/xxxx.Ruleset "(the relativepath of the file under the ContentFiles folder in the xxx.nupkg) buildAction="None" copyToOutput="true" flatten="false" />
</contentFiles>
  </metadata>

<files>
<file src="stylecop.json(the relativePath of the file under the project)" target="contentFiles/any/any" />
<file src="xxxx.Ruleset(the relativePath of the file under the project)" target="contentFiles/any/any" />
<file src="stylecop.json(the relativePath of the file under the project)" target="content" />
<file src="xxxx.Ruleset(the relativePath of the file under the project)" target="content" />
</files>

</package>

[2)

然后可以在CMD中使用nuget pack打包项目,然后将获得xxx.nupkg,它是nuget程序包。
© www.soinside.com 2019 - 2024. All rights reserved.