Thursday, May 10, 2012

TFS Build: Unable to read Code Analysis output report. Make sure that the directory is writable (default is the project output directory)

Yes, the problem is  CodeAnalysisLogFile setting in your .proj file. 
Yes, removing this setting will fix your build.

Going back to my previous post, which is related to the same setting http://il-adan.blogspot.com/2012/04/tfs-build-code-analysis-no-result-files.html, I did some more to figure out HOW actually this settings ruins it all.

If CodeAnalysisLogFile  tag is set in project file, when code analysis is called - it sends in parameter /out. For example, see in .proj file:



That means  code analysis run wil get such parameter as /out:"bin\Debug\TestApp.dll.CodeAnalysisLog.xml". And it is a RELATIVE path from the place where FxCorp is run from. In case of TFS build, FxCorp is run from project file location. But as we remember, TFS build outputs files to $Binaries$ folder, not to $Project_location$\bin\Debug, so, since $Project_location$\bin\Debug doesn't exists - BANG!

Btw, if you want to avoid this nasty setting to appear in your porject files, when create new building configuration select Copy settings from <Empty>, this will keep your .proj file clean.

 


For those projects which already have this setting, I created a build activity which parses project files and remove this setting. Works as charm.

2 comments: