Using FxCop with TeamCity 5.1.1 in the context of an MSBuild runner

I'm trying to run FxCop as part of a build from within a TeamCity configuration that is executing an MSBuild script via the MSBuild runner.

I am running FxCop in the MSBuild script via the FxCop task provided by the MSBuild community extensions.

From the teamcity log output:
[Project "Debug.proj.teamcity.patch.tcprojx" (IntegrationBuild target(s)):] D:\BuildAgent\work\77dee3ad57c7a0c\build\Scripts\Build.proj(89, 3): error MSB6006: "fxcopcmd.exe" exited with code 512.

Which doesn't exactly tell me much. So, I log on to the machine that's hosting the build agent, open a command prompt and paste the exact command line that was being run (I obtained that from the TeamCity build log):
D:\BuildAgent\work\77dee3ad57c7a0c\build\bin\fxcop\fxcopcmd.exe /aXsl /o:"D:\BuildAgent\work\77dee3ad57c7a0c\source\alea\run\buildreports\fxcop.html" /oXsl:"D:\BuildAgent\work\77dee3ad57c7a0c\build\bin\fxcop\Xml\FxCopReport.xsl" /p:"D:\BuildAgent\work\77dee3ad57c7a0c\source\alea\Alea.FxCop"

This produces the following output:

Microsoft (R) FxCop Command-Line Tool, Version 1.36 (9.0.20928.0)
Copyright (C) 2007 Microsoft Corporation.  All rights reserved.

Loading D:\BuildAgent\work\77dee3ad57c7a0c\source\alea\Alea.FxCop...
Loaded DesignRules.dll...
Loaded GlobalizationRules.dll...
Loaded InteroperabilityRules.dll...
Loaded MobilityRules.dll...
Loaded NamingRules.dll...
Loaded PerformanceRules.dll...
Loaded PortabilityRules.dll...
Loaded SecurityRules.dll...
Loaded UsageRules.dll...
Could not open output file : Access to the path 'D:\BuildAgent\work\77dee3ad57c7a0c\source\alea\run\buildreports\fxcop.html' is denied..

If I change the output filename to anything else, it can write the report out just fine. I need to open the command prompt using "run as an administrator" before it can write out to the file location that TeamCity or something else has locked somehow (although if I run process explorer and search for the file path, there are no processes with any handles or references to that file location). Although, if I use explorer to manually delete the file, I don't need to open the command prompt as administrator, so I don't think this is a privileges issue (the TeamCity build agent service is running logged in as an administrator anyway).

It seems to be only under the context of TeamCity that it cannot write out this report file...

I noticed also that any files that are checked out via TeamCity are marked as read only, so I tried writing the report file out to C:\Temp, but still the same result.

Anybody got any suggestions for this?


Comment actions Permalink

Please check D:\BuildAgent\work\77dee3ad57c7a0c\source\alea\run\buildreports patch exists on build agent before starting FXCOP

Comment actions Permalink

The build reports directory is created right at the start of the build.

Also, I mentioned that I hard coded the path to C:\Temp, which also already existed.


Comment actions Permalink

Please check the user account that is used to run build agent service have enough rights to mentioned folders.
What user account do you use?

Why cann't you use TeamCity provided FxCop runner?

Comment actions Permalink

I'm using an administrator account to run the TeamCity service, as I already mentioned. We always set it up that way.

I'm not using the FXCop runner because the purprose of this build is not to just run FxCop in isolation. It's a build that does everything: checks out the source, builds it, runs unit tests and UI tests, and finally deploys the application. At the end of it I want both the test reports and the FXCop reports to be available.

Therefore the FXCop runner on its own isn't appropriate.

Comment actions Permalink

Could you please try copy fxcop report file to some other file, and try reporting that copied file with TeamCity service message?
Do you have any code that may remove the file?


Please sign in to leave a comment.