添加代码通过的NuGet包analisys规则集 [英] Add code analisys ruleset through nuget package
问题描述
我想建立一个的NuGet软件包,自动更新增加了我们公司的代码分析字典。
该规则集在内容文件夹中添加的,现在我要使用install.ps1脚本添加规则在项目文件中设置。结果
我想通了,去将使用envDTE的方式,但我找不到关于它的很多有用的文档其他那么这个压倒性的对象图中,我找不到CodeAnalysisRuleset节点。结果
的 http://msdn.microsoft.com/en-us/library/za2b25t3(v = VS.100)的.aspx
是我追求正确的道路?结果
是否有关于如何在PowerShell中的NuGet使用envDTE任何相关教程/文档?结果
我如何运行/调试我的安装脚本,而不不必实际将其添加到包并安装它针对一个项目?
旁注结果
虽然@Nicole Calinoiu显示更好的方式,这一口的信息可能会派上用场以后:
的foreach($在$ project.ConfigurationManager配置){
$ config.Properties.Item(CodeAnalysisRuleSet)。值=myruleset.ruleset
}
有没有必要这个脚本。这两个规则集和字典可以通过导入的MSBuild注册 .props
文件,在 http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package#Import_MSBuild_targets_and_props_files_into_project_(Requires_NuGet_2 。.5_or_above)
例如,您的NuGet源文件夹结构可能是这样的(假设CodeAnalysisSettings是你的包ID):
- 打造
- CodeAnalysisSettings.props
- 内容
- MyCustomDictionary.xml
- MyRules.ruleset
其中的内容 CodeAnalysisSettings.props
是有点像以下内容:
<项目的xmlns =http://schemas.microsoft.com/developer/msbuild/2003>
<&的PropertyGroup GT;
< RunCodeAnalysis>真< / RunCodeAnalysis>
< CodeAnalysisRuleSet> MyRules.ruleset< / CodeAnalysisRuleSet>
< /&的PropertyGroup GT;
<&的ItemGroup GT;
< CodeAnalysisDictionary包括=MyCustomDictionary.xml/>
< /&的ItemGroup GT;
< /项目>
I'm trying to build a NuGet package that adds our company's code analysis dictionary automatically and updatable.
The rule set is added in the content folder and now I want to use the install.ps1 script to add the rule set in the project file.
I figured out the way to go would be to use the envDTE, but I can't find much useful documentation about it other then this overwhelming object graph in which I can't find the CodeAnalysisRuleset node.
http://msdn.microsoft.com/en-us/library/za2b25t3(v=vs.100).aspx
Am I pursuing the right path?
Is there any relevant tutorial/documentation on how to use the envDTE in NuGet powershell?
How can I run/debug my install script without having to actually add it to a package and install it against a project?
Sidenote
Although @Nicole Calinoiu showed the better way, this morsel of information might come in handy later on:
foreach ($config in $project.ConfigurationManager){
$config.Properties.Item("CodeAnalysisRuleSet").Value = "myruleset.ruleset"
}
There's no need to script this. Both the ruleset and dictionary can be registered via an imported MSBuild .props
file, as described at http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package#Import_MSBuild_targets_and_props_files_into_project_(Requires_NuGet_2.5_or_above).
For example, your NuGet source folder structure might look like this (assuming "CodeAnalysisSettings" is your package ID):
- build
- CodeAnalysisSettings.props
- content
- MyCustomDictionary.xml
- MyRules.ruleset
where the contents of CodeAnalysisSettings.props
are something like the following:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRuleSet>MyRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<CodeAnalysisDictionary Include="MyCustomDictionary.xml" />
</ItemGroup>
</Project>
这篇关于添加代码通过的NuGet包analisys规则集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!