解决方案:创建一个空的规则集文件并将其作为命令行参数传递给 MSBuild。
NoRules.ruleset 文件:
<?xml version="1.0" encoding="utf-8"?>
<!--
Problem: warning MSB3884
Visual Studio 2015 includes references to MinimumRecommendedRules.ruleset in .csproj files.
MSBuild 10 cannot find this reference and generates warning MSB3884.
Solution: Create NoRules.ruleset [this file] and pass it to MSBuild in a command switch. Need to pass full path name to MSBuild.
Example: MSBuild /property:CodeAnalysisRuleSet="$Workspace\NoRules.ruleset"
References:
https://msdn.microsoft.com/en-us/library/dd264949.aspx
https://msdn.microsoft.com/en-us/library/ms164311.aspx
-->
<RuleSet Name="NoRules" Description="This rule set contains no rules." ToolsVersion="14.0">
</RuleSet>
对于 Jenkins 构建,添加以下 MSBuild 开关以覆盖项目设置并使用 NoRules 文件:
/property:CodeAnalysisRuleSet="$Workspace\NoRules.ruleset"
您只需将 NoRules 文件添加到源代码管理即可。我选择在 MSBuild 步骤之前使用批处理文件在 Jenkins 中即时构建它:
set NoRules=NoRules.ruleset
@echo Making %NoRules%
if not exist %NoRules% (
@echo ^<?xml version="1.0" encoding="utf-8"?^> >%NoRules%
@echo ^<!-- >>%NoRules%
call :WriteToFile %NoRules% "Problem: warning MSB3884"
call :WriteToFile %NoRules% " Visual Studio 2015 includes references to MinimumRecommendedRules.ruleset in .csproj files."
call :WriteToFile %NoRules% " MSBuild 10 cannot find this reference and generates warning MSB3884."
@echo. >>%NoRules%
call :WriteToFile %NoRules% "Solution: Create NoRules.ruleset [this file] and pass it to MSBuild in a command switch."
call :WriteToFile %NoRules% " Need to pass full path name to MSBuild."
@echo Example: MSBuild /property:CodeAnalysisRuleSet="$WORKSPACE\NoRules.ruleset" >>%NoRules%
@echo. >>%NoRules%
call :WriteToFile %NoRules% "References:"
call :WriteToFile %NoRules% " https://msdn.microsoft.com/en-us/library/dd264949.aspx"
call :WriteToFile %NoRules% " https://msdn.microsoft.com/en-us/library/ms164311.aspx"
@echo --^> >>%NoRules%
@echo ^<RuleSet Name="NoRules" Description="This rule set contains no rules." ToolsVersion="14.0"^> >>%NoRules%
@echo ^</RuleSet^> >>%NoRules%
)
exit /b %errorlevel%
:WriteToFile
@echo %~2 >>%1
exit /b %errorlevel%
此文件还显示 Jenkins ConsoleOut 显示中的注释。这应该可以帮助您了解您后来这样做的原因。