Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specifying the Code Analysis output file for multiple projects

Tags:

c#

.net

msbuild

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.

like image 583
John Koerner Avatar asked Feb 13 '14 03:02

John Koerner


1 Answers

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" />
like image 160
Nicodemeus Avatar answered Oct 20 '22 03:10

Nicodemeus