【发布时间】:2017-11-02 13:53:30
【问题描述】:
我已经为我的公共项目(这是一个 NuGet 包)安装了 AsyncUsageAnalyzers,并且我希望在依赖它的所有包/应用程序中强制执行这些规则。
我更改了UseConfigureAwait 规则的严重性,并创建了一个.ruleset。
我在https://stackoverflow.com/a/20271758/2663813 上读到过,我需要一个具有给定结构的 NuGet 包。该断言已在此处得到确认https://stackoverflow.com/a/46115423/2663813
我现在拥有的:
构建/Common.ruleset
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="My common analyzer rules" Description="The rules that are enforced on all of my projects" ToolsVersion="10.0">
<Rules AnalyzerId="AsyncUsageAnalyzers" RuleNamespace="AsyncUsageAnalyzers">
<Rule Id="UseConfigureAwait" Action="Error" />
</Rules>
</RuleSet>
构建/My.Package.Id.targets
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)Common.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
</Project>
在我的 .csproj 中
<Import Project="build\My.Package.Id.targets" />
我的问题是:既然我已经做到了,并且规则已正确应用于我的项目,我如何在 NuGet 包内的 build/ 下添加文件,在 build/ 文件夹内?我知道我可以使用链接中提到的 .nuspec 文件来做到这一点,但我想使用新的 .csproj 语法来做到这一点。
【问题讨论】: