ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

c# – 如何在.net标准项目中获得一个stylecop规则集

2019-07-05 13:14:52  阅读:315  来源: 互联网

标签:c net stylecop nuget net-standard


我们正在尝试使用stylecop规则集为我们的所有项目提供nuget包.
我们获取项目中的文件,但规则集不适用于我们的项目.它仍然使用minimimumrecomended.ruleset.

我们现在拥有的是:

Custom.stylecop.props

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <RunCodeAnalysis>true</RunCodeAnalysis>
    <CodeAnalysisRuleSet>Custom.StyleCop.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>
</Project>

custom.stylecop.targets

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <AdditionalFiles Include="$(MSBuildThisFileDirectory)\Content\stylecop.json">
      <Link>stylecop.json</Link>
    </AdditionalFiles>
  </ItemGroup>
</Project>

Custom.stylecop.nuspec

<contentFiles>
    <files include="Content/stylecop.json" buildAction="EmbeddedResource" />
</contentFiles>
....
<files>
    <file src="build\**" target="build" />
    <file src="Content/stylecop.json" target="contentFiles" />
</files>

有没有人在github上有任何想法或例子,我们可以找到一个例子,因为我们找不到任何.

解决方法:

在我们的Xamarin.Forms项目中,修复是一个编辑.NET Standard .csproj文件的手动过程.如果有更好的方法,请告诉我!

>首先,在文本编辑器中打开.NET Standard项目(_Notepad)
>然后添加< CodeAnalysisRuleSet> …< / CodeAnalysisRuleSet>在< PropertyGroup>内

<PropertyGroup>
    <CodeAnalysisRuleSet>..\stylecop.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

>(可选)如果要在项目中访问这些文件,可以使用< AdditionalFiles ... />创建一个ItemGroup.

<ItemGroup>
    <AdditionalFiles Include="..\stylecop.json" />
    <AdditionalFiles Include="..\stylecop.ruleset" />
</ItemGroup>

参考

https://github.com/dotnet/roslyn/blob/master/docs/compilers/Rule%20Set%20Format.md

标签:c,net,stylecop,nuget,net-standard
来源: https://codeday.me/bug/20190705/1387762.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有