Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-18151

FxCop-Runner sets build results to unstable when FxCop runs succesfully

        [JENKINS-18151] FxCop-Runner sets build results to unstable when FxCop runs succesfully

        Hi Michael Fowler.

        Please write console output log.

        Yasuyuki Saito added a comment - Hi Michael Fowler. Please write console output log.

        Ryan Davis added a comment -

        I'm experiencing this too, and figured out a solution. I needed to disable saving messages.

        http://social.msdn.microsoft.com/Forums/en-US/60bc9dbf-5557-46d4-8905-d850286b8787/could-not-import-all-messages-error-supression has a good description of the problem and solution, but I'll repeat it here.

        I'm using an .fxcop file to configure the rules, and occasionally open/edit that using FXCop directly. In my jenkins configuration, I add a command line argument to load up my .fxcop file. Using the fxcop defaults, it's trying to save the warnings in the fxcop file every time, and fxcopcmd will emit warnings that trigger build instability.

        To fix it, in my fxcop file (which is XML), I changed SaveMessages/Project/Status to "Excluded", which might not be the best setting, but it made it work for me. In Fxcop GUI this is done via:

        • Open your project in FxCop
        • Choose Project -> Project Options
        • Under Save Messages and next to Project uncheck the Active checkbox
        • click OK
        full output
        Started by user (null)
        Building remotely on MY_JENKINS_SLAVE in workspace C:\Jenkins\workspace\MY_PROJECT
        Checkout:MY_PROJECT / C:\Jenkins\workspace\MY_PROJECT - hudson.remoting.Channel@3ecfea4e:MY_JENKINS_SLAVE
        Using strategy: Default
        Last Built Revision: Revision 655c79fcdeaef3d871d0dfe941f083e83e475b68 (origin/master)
        Fetching changes from 1 remote Git repository
        Fetching upstream changes from origin
        Commencing build of Revision bb32fd2e656441de1f65daf3a1019ad20a7ba858 (origin/master)
        Checking out Revision bb32fd2e656441de1f65daf3a1019ad20a7ba858 (origin/master)
        Cleaning workspace
        Resetting working tree
        [MY_PROJECT] $ cmd /c call C:\Users\jenkins\AppData\Local\Temp\hudson2073588205894679312.bat
        
        C:\Jenkins\workspace\MY_PROJECT>c:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe MY_PROJECT.proj /t:test 
        Microsoft (R) Build Engine version 4.0.30319.17929
        [Microsoft .NET Framework, version 4.0.30319.18052]
        Copyright (C) Microsoft Corporation. All rights reserved.
        
        Build started 7/29/2013 5:01:07 PM.
        ... MSBUILD OUTPUT COMPILING AND RUNNING NUNIT ...
        
        Build succeeded.
        
          C:\Jenkins\workspace\MY_PROJECT\src\MY_WEBSITE\MY_WEBSITE.csproj(271,3): warning MSB4011: "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" cannot be imported again. It was already imported at "C:\Jenkins\workspace\MY_PROJECT\src\MY_WEBSITE\MY_WEBSITE.csproj (270,3)". This is most likely a build authoring error. This subsequent import will be ignored. 
        
            1 Warning(s)
            0 Error(s)
        
        Time Elapsed 00:00:10.58
        
        C:\Jenkins\workspace\MY_PROJECT>exit 0 
        Path To FxCopCmd.exe: C:\Program Files (x86)\Microsoft Fxcop 10.0\FxCopCmd.exe
        Executing FxCop: cmd.exe /C C:\Users\jenkins\AppData\Local\Temp\fxcop_runner9006884407026696209.bat && exit %ERRORLEVEL%
        [MY_PROJECT] $ cmd.exe /C C:\Users\jenkins\AppData\Local\Temp\fxcop_runner9006884407026696209.bat && exit %ERRORLEVEL%
        
        C:\Jenkins\workspace\MY_PROJECT>"C:\Program Files (x86)\Microsoft Fxcop 10.0\FxCopCmd.exe" /out:"fxcop.xml" /ignoregeneratedcode /forceoutput /p:src\MY_PROJECT.FxCop 
        Microsoft (R) FxCop Command-Line Tool, Version 10.0 (10.0.30319.1) X86
        Copyright (C) Microsoft Corporation, All Rights Reserved.
        
        Loading src\MY_PROJECT.FxCop...
        Loaded DesignRules.dll...
        Loaded GlobalizationRules.dll...
        Loaded MobilityRules.dll...
        Loaded NamingRules.dll...
        Loaded PerformanceRules.dll...
        Loaded PortabilityRules.dll...
        Loaded SecurityRules.dll...
        Loaded SecurityTransparencyRules.dll...
        Loaded UsageRules.dll...
        Loaded MY_WEBSITE.dll...
        Loaded MY_PROJECT.dll...
        There were non-critical errors loading FxCop project:
        * Could not import all messages.
        * End of project load errors.
        Initializing Introspection engine...
        Analyzing...
        Analysis Complete.
        Writing 31 messages...
        Writing report to C:\Jenkins\workspace\MY_PROJECT\fxcop.xml...
        Done:00:00:03.4706186
        Build step 'FxCop exec.' changed build result to UNSTABLE
        Recording NUnit tests results
        Jabber notifier plugin: Sending notification to: jenkins@my.jabber.server
        Jabber notifier plugin: Notifying suspects
        Jabber notifier plugin: Sending notification to suspect: me@my.jabber.server
        Jabber notifier plugin: Notifying culprits
        Finished: UNSTABLE
        

        After changing my fxcop config I don't get these messages:

        There were non-critical errors loading FxCop project:
        * Could not import all messages.
        * End of project load errors.
        

        Ryan Davis added a comment - I'm experiencing this too, and figured out a solution. I needed to disable saving messages. http://social.msdn.microsoft.com/Forums/en-US/60bc9dbf-5557-46d4-8905-d850286b8787/could-not-import-all-messages-error-supression has a good description of the problem and solution, but I'll repeat it here. I'm using an .fxcop file to configure the rules, and occasionally open/edit that using FXCop directly. In my jenkins configuration, I add a command line argument to load up my .fxcop file. Using the fxcop defaults, it's trying to save the warnings in the fxcop file every time, and fxcopcmd will emit warnings that trigger build instability. To fix it, in my fxcop file (which is XML), I changed SaveMessages/Project/Status to "Excluded", which might not be the best setting, but it made it work for me. In Fxcop GUI this is done via: Open your project in FxCop Choose Project -> Project Options Under Save Messages and next to Project uncheck the Active checkbox click OK full output Started by user ( null ) Building remotely on MY_JENKINS_SLAVE in workspace C:\Jenkins\workspace\MY_PROJECT Checkout:MY_PROJECT / C:\Jenkins\workspace\MY_PROJECT - hudson.remoting.Channel@3ecfea4e:MY_JENKINS_SLAVE Using strategy: Default Last Built Revision: Revision 655c79fcdeaef3d871d0dfe941f083e83e475b68 (origin/master) Fetching changes from 1 remote Git repository Fetching upstream changes from origin Commencing build of Revision bb32fd2e656441de1f65daf3a1019ad20a7ba858 (origin/master) Checking out Revision bb32fd2e656441de1f65daf3a1019ad20a7ba858 (origin/master) Cleaning workspace Resetting working tree [MY_PROJECT] $ cmd /c call C:\Users\jenkins\AppData\Local\Temp\hudson2073588205894679312.bat C:\Jenkins\workspace\MY_PROJECT>c:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe MY_PROJECT.proj /t:test Microsoft (R) Build Engine version 4.0.30319.17929 [Microsoft .NET Framework, version 4.0.30319.18052] Copyright (C) Microsoft Corporation. All rights reserved. Build started 7/29/2013 5:01:07 PM. ... MSBUILD OUTPUT COMPILING AND RUNNING NUNIT ... Build succeeded. C:\Jenkins\workspace\MY_PROJECT\src\MY_WEBSITE\MY_WEBSITE.csproj(271,3): warning MSB4011: "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" cannot be imported again. It was already imported at "C:\Jenkins\workspace\MY_PROJECT\src\MY_WEBSITE\MY_WEBSITE.csproj (270,3)" . This is most likely a build authoring error. This subsequent import will be ignored. 1 Warning(s) 0 Error(s) Time Elapsed 00:00:10.58 C:\Jenkins\workspace\MY_PROJECT>exit 0 Path To FxCopCmd.exe: C:\Program Files (x86)\Microsoft Fxcop 10.0\FxCopCmd.exe Executing FxCop: cmd.exe /C C:\Users\jenkins\AppData\Local\Temp\fxcop_runner9006884407026696209.bat && exit %ERRORLEVEL% [MY_PROJECT] $ cmd.exe /C C:\Users\jenkins\AppData\Local\Temp\fxcop_runner9006884407026696209.bat && exit %ERRORLEVEL% C:\Jenkins\workspace\MY_PROJECT> "C:\Program Files (x86)\Microsoft Fxcop 10.0\FxCopCmd.exe" /out: "fxcop.xml" /ignoregeneratedcode /forceoutput /p:src\MY_PROJECT.FxCop Microsoft (R) FxCop Command-Line Tool, Version 10.0 (10.0.30319.1) X86 Copyright (C) Microsoft Corporation, All Rights Reserved. Loading src\MY_PROJECT.FxCop... Loaded DesignRules.dll... Loaded GlobalizationRules.dll... Loaded MobilityRules.dll... Loaded NamingRules.dll... Loaded PerformanceRules.dll... Loaded PortabilityRules.dll... Loaded SecurityRules.dll... Loaded SecurityTransparencyRules.dll... Loaded UsageRules.dll... Loaded MY_WEBSITE.dll... Loaded MY_PROJECT.dll... There were non-critical errors loading FxCop project: * Could not import all messages. * End of project load errors. Initializing Introspection engine... Analyzing... Analysis Complete. Writing 31 messages... Writing report to C:\Jenkins\workspace\MY_PROJECT\fxcop.xml... Done:00:00:03.4706186 Build step 'FxCop exec.' changed build result to UNSTABLE Recording NUnit tests results Jabber notifier plugin: Sending notification to: jenkins@my.jabber.server Jabber notifier plugin: Notifying suspects Jabber notifier plugin: Sending notification to suspect: me@my.jabber.server Jabber notifier plugin: Notifying culprits Finished: UNSTABLE After changing my fxcop config I don't get these messages: There were non-critical errors loading FxCop project: * Could not import all messages. * End of project load errors.

        Ryan Davis added a comment -

        I found another potential source. If FxCop can't find all your assemblies, it will throw warnings and mark the build as unstable.

        http://stackoverflow.com/questions/12120741/code-analysis-error-could-not-load-file-or-assembly-system-net-http-version-2

        You can tell fxcop to scan the global assembly cache (/gac flag), or sometimes you need to change the FxCopCmd.exe.config file to change it's assembly lookup strategy. On a different project than the one above I had this error in my output:

        NOTE: One or more referenced assemblies could not be found. Use the '/directory' or '/reference' switch to specify additional assembly reference search paths.

        I had to change FxCopCmd.exe.config to set

        <add key="AssemblyReferenceResolveMode" value="StrongNameIgnoringVersion" />

        .

        Ryan Davis added a comment - I found another potential source. If FxCop can't find all your assemblies, it will throw warnings and mark the build as unstable. http://stackoverflow.com/questions/12120741/code-analysis-error-could-not-load-file-or-assembly-system-net-http-version-2 You can tell fxcop to scan the global assembly cache (/gac flag), or sometimes you need to change the FxCopCmd.exe.config file to change it's assembly lookup strategy. On a different project than the one above I had this error in my output: NOTE: One or more referenced assemblies could not be found. Use the '/directory' or '/reference' switch to specify additional assembly reference search paths. I had to change FxCopCmd.exe.config to set <add key= "AssemblyReferenceResolveMode" value= "StrongNameIgnoringVersion" /> .

        Ryan Davis added a comment -

        I added a "Common Problems" section to https://wiki.jenkins-ci.org/display/JENKINS/FxCop+Runner+Plugin to document a lot of this. I don't think there's any code fix for this issue, these are just valid fxcop warnings. I think the best solution is more documentation about how to identify and resolve these fxcop configuration problems.

        I struggled a little with the wiki formatting, couldn't figure out how to NOT indent my "see also" links.

        Ryan Davis added a comment - I added a "Common Problems" section to https://wiki.jenkins-ci.org/display/JENKINS/FxCop+Runner+Plugin to document a lot of this. I don't think there's any code fix for this issue, these are just valid fxcop warnings. I think the best solution is more documentation about how to identify and resolve these fxcop configuration problems. I struggled a little with the wiki formatting, couldn't figure out how to NOT indent my "see also" links.

        Thank you for reporting and added to the Wiki.

        Yasuyuki Saito added a comment - Thank you for reporting and added to the Wiki.

        Pete W added a comment -

        I get this too, FxCop reports this error:

        Conflicting target platforms 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' vs 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

        Could we have an option to not mark the build unstable if FxCop has warnings?
        Though ideally I need to fix this, with project time constraints I do not have time right now, but the FxCop results file produced is still useful.

        Pete W added a comment - I get this too, FxCop reports this error: Conflicting target platforms 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' vs 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Could we have an option to not mark the build unstable if FxCop has warnings? Though ideally I need to fix this, with project time constraints I do not have time right now, but the FxCop results file produced is still useful.

        Ryan Davis added a comment - - edited

        @Pete, that might be a different error. Did you try the FxCopCmd.exe.config changes from the "Common problems" section on https://wiki.jenkins-ci.org/display/JENKINS/FxCop+Runner+Plugin?

        The root issue is that the FxCopCmd.exe program is returning error codes when it actually succeeded. Jenkins looks to that return code to figure out if the program was OK or not, and that's a hard to work around without a lot of extra effort for the FxCop-Runner plugin.

        Ryan Davis added a comment - - edited @Pete, that might be a different error. Did you try the FxCopCmd.exe.config changes from the "Common problems" section on https://wiki.jenkins-ci.org/display/JENKINS/FxCop+Runner+Plugin? The root issue is that the FxCopCmd.exe program is returning error codes when it actually succeeded. Jenkins looks to that return code to figure out if the program was OK or not, and that's a hard to work around without a lot of extra effort for the FxCop-Runner plugin.

        Pete W added a comment -

        @Ryan Yes I tried those tips, didn't seem to help. Unfortunately I don't have time to investigate further to solve my FxCop warnings, so as a workaround I just run FxCop as a "Exceute Windows batch command" and add a "exit 0" line at the end... bit of a cheat but gives me some data at least for now...

        Pete W added a comment - @Ryan Yes I tried those tips, didn't seem to help. Unfortunately I don't have time to investigate further to solve my FxCop warnings, so as a workaround I just run FxCop as a "Exceute Windows batch command" and add a "exit 0" line at the end... bit of a cheat but gives me some data at least for now...

        Andrew Gray added a comment -

        Is this going to be fixed? I am still getting this problem occur and it is 2016.

        Andrew Gray added a comment - Is this going to be fixed? I am still getting this problem occur and it is 2016.

          Unassigned Unassigned
          mdkf Michael Fowler
          Votes:
          1 Vote for this issue
          Watchers:
          4 Start watching this issue

            Created:
            Updated: