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

Today a new error popped up in Team Build. One we've never seen before and one that doesn't happen in Visual Studio during the build.

The error was:


MSBUILD : error : Unable to read Code Analysis output
report. Make sure that the directory is writable (default is the project output
directory).
[MyProjectA.csproj]

A quick search pointed to a few possible solutions, luckily we weren't the first to experience this:

  1. Reduce the path length to be below 260 characters. As the old Windows API imposes a restriction of the total length a file name is allowed to be.
  2. Remove the

<CodeAnalysisLogFile>bin\Release\MyProjectA.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>

lines from the .csproj file
3. Clean the Team Build workspace to ensure that an older version of this file isn't causing any issues.

For us it turned out that a combination of 2 & 3 solved the issue. After removing the lines from the project file and running a build which clears the TFS workspace we're no longer experiencing the errors.

Leave a comment.