I am trying to build a solution using MSBuild and I would like to fire off code analysis for each project and have all of the output placed into a certain directory. The command I am running is:
msbuild.exe MySolution.sln /p:RunCodeAnalysis=True;CodeAnalysisLogFile=c:\BuildOutput\code-analysis.xml
The problem I am having is that the code analysis overwrites the xml file for each project in the solution, so I only get the output for the last project that is built. Is there a way I can tell MSBuild to append the output for code analysis or to generate a unique file for each output?
Note: I would prefer not having to update each CSProj files with the CodeAnalysisLogFile xml tag, but if there is no other way, then that is what I will do.
Create a or use an existing common "Imports.Props" file imported , and in it include a definition for CodeAnalysisLog.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CodeAnalysisLogFile>$(OutputPath)\CodeAnalysis\$(AssemblyName).$(Platform).$(Configuration).xml</CodeAnalysisLogFile>
</PropertyGroup>
</Project>
Then in your project files import this common props file:
<Import Project="$(PropertyOfSourceFolder)\CodeAnalysis.props" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With