我正在为我的团队使用Visual Studio 2015 Enterprise设置代码分析器的内部NuGet包。我通过创建一个新文件夹并使用" nuget spec"来保持简单。命令来创建nuspec文件。
我的nuspec文件如下:
<?xml version="1.0"?>
<package >
<metadata>
<id>Test.CodeAnalysis</id>
<version>1.0.0.5</version>
<authors>Tom Atwood</authors>
<owners>Tom Atwood</owners>
<licenseUrl>LICENSEURL</licenseUrl>
<projectUrl>PROJECTURL</projectUrl>
<iconUrl>ICONURL</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Code analysis analyzers used at my company.</description>
<releaseNotes>No release notes available.</releaseNotes>
<copyright>COPYRIGHT MESSAGE HERE</copyright>
<tags>code analysis</tags>
<dependencies>
<dependency id="ClrHeapAllocationAnalyzer" version="[1.0.0.8]" />
<dependency id="codecracker.CSharp" version="[1.0.0]" />
<dependency id="Microsoft.CodeAnalysis.FxCopAnalyzers" version="[1.1.0]" />
<dependency id="RefactoringEssentials" version="[4.2.0]" />
<dependency id="SonarAnalyzer.CSharp" version="[1.16.0]" />
<dependency id="StyleCop.Analyzers" version="[1.0.0]" />
</dependencies>
<frameworkAssemblies>
<frameworkAssembly assemblyName="System" targetFramework=".NETFramework4.0" />
<frameworkAssembly assemblyName="System" targetFramework=".NETFramework4.5" />
<frameworkAssembly assemblyName="System" targetFramework=".NETFramework4.51" />
<frameworkAssembly assemblyName="System" targetFramework=".NETFramework4.52" />
<frameworkAssembly assemblyName="System" targetFramework=".NETFramework4.6" />
<frameworkAssembly assemblyName="System" targetFramework=".NETFramework4.61" />
<frameworkAssembly assemblyName="System" targetFramework="native0.0" />
<frameworkAssembly assemblyName="System.Xml" targetFramework=".NETFramework4.0" />
<frameworkAssembly assemblyName="System.Xml" targetFramework=".NETFramework4.5" />
<frameworkAssembly assemblyName="System.Xml" targetFramework=".NETFramework4.51" />
<frameworkAssembly assemblyName="System.Xml" targetFramework=".NETFramework4.52" />
<frameworkAssembly assemblyName="System.Xml" targetFramework=".NETFramework4.6" />
<frameworkAssembly assemblyName="System.Xml" targetFramework=".NETFramework4.61" />
<frameworkAssembly assemblyName="System.Xml" targetFramework="native0.0" />
</frameworkAssemblies>
</metadata>
<files>
<file src="CodeAnalysis.props" target="\build\net40\" />
<file src="CodeAnalysis.props" target="\build\net45\" />
<file src="CodeAnalysis.props" target="\build\net451\" />
<file src="CodeAnalysis.props" target="\build\net452\" />
<file src="CodeAnalysis.props" target="\build\net46\" />
<file src="CodeAnalysis.props" target="\build\net461\" />
<file src="CodeAnalysis.ruleset" target = "\content\net40\" />
<file src="CodeAnalysis.ruleset" target = "\content\net45\" />
<file src="CodeAnalysis.ruleset" target = "\content\net451\" />
<file src="CodeAnalysis.ruleset" target = "\content\net452\" />
<file src="CodeAnalysis.ruleset" target = "\content\net46\" />
<file src="CodeAnalysis.ruleset" target = "\content\net461\" />
<file src="stylecop.json" target = "\content\net40\" />
<file src="stylecop.json" target = "\content\net45\" />
<file src="stylecop.json" target = "\content\net451\" />
<file src="stylecop.json" target = "\content\net452\" />
<file src="stylecop.json" target = "\content\net46\" />
<file src="stylecop.json" target = "\content\net461\" />
<file src="install.ps1" target="\tools\net40\" />
<file src="install.ps1" target="\tools\net45\" />
<file src="install.ps1" target="\tools\net451\" />
<file src="install.ps1" target="\tools\net452\" />
<file src="install.ps1" target="\tools\net46\" />
<file src="install.ps1" target="\tools\net461\" />
<file src="uninstall.ps1" target="\tools\net40\" />
<file src="uninstall.ps1" target="\tools\net45\" />
<file src="uninstall.ps1" target="\tools\net451\" />
<file src="uninstall.ps1" target="\tools\net452\" />
<file src="uninstall.ps1" target="\tools\net46\" />
<file src="uninstall.ps1" target="\tools\net461\" />
</files>
</package>
我遇到的问题如下:
即使根据需要将stylecop.json文件添加到目标项目中,props文件也未正确设置文件。对于stylecop.json,这意味着在csproj文件中具有以下设置,以使stylecop.json文件处于活动状态并被识别:
<ItemGroup>
<AdditionalFiles include="stylecop.json"
</ItemGroup>
目前,它不是&#34; AdditionalFiles&#34;,而是设置为&#34;无&#34;。
即使将规则集文件加载到项目中,项目的属性也不会在构建时启用代码分析,也不会启用默认的&#34; Microsoft托管推荐规则&#34;为规则集文件而不是导入的文件设置。
对于上述两个项目,道具文件的设置如下:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRuleSet>CodeAnalysis.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<AdditionalFiles Include="stylecop.json"/>
<CodeAnalysisDictionary Include="CodeAnalysis.Dictionary.xml" />
</ItemGroup>
</Project>
请注意,install.ps1和uninstall.ps1目前处于默认配置状态,并且不处理任何任务。
没有关于如何正确解决这个问题的大量详细信息。是否存在我执行不正确的具体问题?