Code Analysis (FxCop) support

James Skimming's Avatar

James Skimming

15 Sep, 2014 09:20 PM

I have seen in a previous discuss that Code Analysis is not supported.

This is something we use but given it an impact on build times, on one huge project we've limited it only to release builds, and therefore it was only picked up on our build server (then TeamCity).

Now that we've moved to AppVeyor for both our CI build and deployment, we pretty much never build release builds and as a result the Code Analysis issues are not being picked up.

Is this something that can be added easily?

  1. Support Staff 1 Posted by Feodor Fitsner on 15 Sep, 2014 10:06 PM

    Feodor Fitsner's Avatar

    Hi James,

    We could provide FxCop 10.0 which is a part of Windows SDK. Would it work for you?

  2. 2 Posted by James Skimming on 16 Sep, 2014 08:37 AM

    James Skimming's Avatar

    Hi Feodor, it looks like v12 is the one that bundles with VS 2013 (presumably matching the VS version)

    I've not tried it from the Windows SDK version, will it still run as part build or would we need to add separate build steps for AppVeyor?

    Is the reason it's not already present because its not part of the express variant of Visual Studio?

  3. Support Staff 3 Posted by Feodor Fitsner on 18 Sep, 2014 05:14 PM

    Feodor Fitsner's Avatar

    Right, FxCop 12 is part of Code Analysis tools which are the part of VS Ultimate edition.

  4. 4 Posted by gep13 on 22 Sep, 2014 12:37 PM

    gep13's Avatar

    Fedeor, did you decide if you were going to add FxCop 10.0? Or is it already available on the Build Worker?


  5. Support Staff 5 Posted by Feodor Fitsner on 22 Sep, 2014 05:03 PM

    Feodor Fitsner's Avatar

    It's not yet available. Will install it today.

  6. 6 Posted by gep13 on 22 Sep, 2014 05:17 PM

    gep13's Avatar

    Sweet! Looking forward to trying it out!

    Sent from my Windows Phone

  7. Support Staff 7 Posted by Feodor Fitsner on 23 Sep, 2014 04:49 AM

    Feodor Fitsner's Avatar

    FxCop 10.0 has been installed into: C:\Program Files (x86)\Microsoft Fxcop 10.0

    There is FxCopCmd.exe to run from command line.

  8. 8 Posted by gep13 on 23 Sep, 2014 07:58 PM

    gep13's Avatar

    Just wanted to confirm that I was able to get Code Analysis to run, including on a .Net 4.5 project. Turns out, Code Analysis is now included in the Express Editions of Visual Studio, so no need for an updated SDK to include it, as it is already there.


  9. Support Staff 9 Posted by Feodor Fitsner on 23 Sep, 2014 08:00 PM

    Feodor Fitsner's Avatar

    Have you used any special syntax/build step to make it work? Or it's just VS 2013 project with code analysis on?

  10. 10 Posted by gep13 on 23 Sep, 2014 08:43 PM

    gep13's Avatar

    Nope, nothing really special.

    I added the Build.FxCop nuget package, which adds the necessary Code Analysis settings to each project. The only thing I had to do in addition to this was to create an additional Import Statement to set the output file location that I wanted.

    From there, I invoked MSBuild from my psake script, and Code Analysis was then executed.

    You can see the changes that I made here:

    and the resulting build here:

    Which failed due to 226 Code Analysis violations, which I now need to fix :-)

  11. Support Staff 11 Posted by Feodor Fitsner on 23 Sep, 2014 09:28 PM

    Feodor Fitsner's Avatar

    Cool, thanks for the guide! I'll move this thread to KB section. Seamless FxCop support is great value for AV platform.

  12. 12 Posted by gep13 on 08 Oct, 2014 09:24 PM

    gep13's Avatar

    For those that might be interested, I have just finished completing some tests which allow me to analyse the output of a Code Analysis test, and if there are any violations, report them as errors in the Tests section of the AppVeyor Build page.

    If breaks down as follows:

    function analyseCodeAnalysisResults( [Parameter(ValueFromPipeline=$true)]$codeAnalysisResultsFile ) {
      $codeAnalysisErrors = [xml](Get-Content $codeAnalysisResultsFile);
      foreach ($codeAnalysisError in $codeAnalysisErrors.SelectNodes("//Message")) {
        $issueNode = $codeAnalysisError.SelectSingleNode("Issue");
        Write-Host "Violation of Rule $($codeAnalysisError.CheckId): $($codeAnalysisError.TypeName) Line Number: $($issueNode.Line) FileName: $($issueNode.Path)\$($codeAnalysisError.Issue.File) ErrorMessage: $($issueNode.InnerXml)";
        if(isAppVeyor) {
          Add-AppveyorTest "Violation of Rule $($codeAnalysisError.CheckId): $($codeAnalysisError.TypeName) Line Number: $($issueNode.Line)" -Outcome Failed -FileName "$($issueNode.Path)\$($codeAnalysisError.Issue.File)" -ErrorMessage $($issueNode.InnerXml);
      if(isAppVeyor) {
        Push-AppveyorArtifact $codeAnalysisResultsFile;

    Hopefully this will help anyone who is looking to do something similar.

    You can see an example of the test errors reported here:

    NOTE: The missing line number is due to the particular CA error not actually reporting the line number where the error occured.

  13. 13 Posted by Bruno Juchli on 10 Nov, 2014 08:03 AM

    Bruno Juchli's Avatar

    you've mentioned a Build.FxCop nuget package. I couldn't find it and i think you were referring to BuildTools.FxCop:
    (just in case someone else is going to look for it).

  14. 14 Posted by gep13 on 10 Nov, 2014 08:07 AM

    gep13's Avatar

    Yes, my mistake. I was typing the nuget package name from memory, I should have looked it up. The package that you have linked to is the one that I have used.

  15. James Skimming closed this discussion on 27 Dec, 2015 10:54 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

13 Apr, 2024 04:43 PM
12 Apr, 2024 04:56 PM
11 Apr, 2024 11:16 PM
09 Apr, 2024 10:59 PM
08 Apr, 2024 07:50 AM


06 Apr, 2024 04:06 AM
05 Apr, 2024 01:26 PM
05 Apr, 2024 10:39 AM
04 Apr, 2024 03:41 PM
31 Mar, 2024 05:51 PM
30 Mar, 2024 01:59 PM