Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSBuild Warning MSB3884 when building from command line

When building our solution on the build server (using Jenkins) with MSBuild 14 following warning occurs:

C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.VisualBasic.CurrentVersion.targets(133,9): warning MSB3884: ruleset file "ManagedMinimumRules.ruleset" could not be found.

Executing the same command line call on my dev machine, this warning won't appear.

Any ideas why this warning appears on the build server?

I've already opened an issue for MSBuild: https://github.com/Microsoft/msbuild/issues/361

like image 552
Toni Wenzel Avatar asked Oct 27 '25 06:10

Toni Wenzel


1 Answers

Solution: Create an empty rule set file and pass that as a command line parameter to MSBuild.

NoRules.ruleset file:

<?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>     

For a Jenkins build, add the following MSBuild switch to override the project settings and use the NoRules file:

/property:CodeAnalysisRuleSet="$Workspace\NoRules.ruleset" 

You can just add the NoRules file to source control. I chose to build it on the fly in Jenkins with a Batch file prior to the MSBuild step:

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%

This file also shows the comments in the Jenkins ConsoleOut display. This should help you know what why you did this later.

like image 57
Wayne Mack Avatar answered Oct 29 '25 03:10

Wayne Mack