.net - MSBuild File to Run Code Analysis Without Overlap -


i creating msbuild file combine tasks of things need on build server 1 step. part of process requires running code analysis. problem have running code analysis multiple top level projects each have same dependencies on other projects our utility library. means each run of code analysis duplicates code analysis run of utility library. here msbuild file:

<project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" defaulttargets="build" toolsversion="4.0">     <propertygroup>         <configuration condition=" '$(configuration)' == '' ">dev</configuration>         <platform condition=" '$(platform)' == '' ">anycpu</platform>         <runcodeanalysis>true</runcodeanalysis>         <codeanalysistargets>c:\program files (x86)\msbuild\microsoft\visualstudio\v11.0\codeanalysis\microsoft.codeanalysis.targets</codeanalysistargets>         <codeanalysistreatwarningsaserrors>true</codeanalysistreatwarningsaserrors>         <stylecoptreaterrorsaswarnings>false</stylecoptreaterrorsaswarnings>         <defineconstants>trace;debug;code_analysis</defineconstants>         <buildinparallel>true</buildinparallel>         <webprojecttargets>clean;build;package</webprojecttargets>         <otherprojecttargets>clean;build</otherprojecttargets>         <generateserializationassemblies>off</generateserializationassemblies>     </propertygroup>      <target name="build">         <!-- web projects -->         <msbuild             projects="$(msbuildprojectdirectory)\source\webprojects\webapp1\webapp1.csproj"             properties="                 configuration=$(configuration);                 packagelocation=$(msbuildprojectdirectory)\packages\webapp1.zip;                 runcodeanalysis=$(runcodeanalysis);                 codeanalysistargets=$(codeanalysistargets);                 codeanalysistreatwarningsaserrors=$(codeanalysistreatwarningsaserrors);                 stylecoptreaterrorsaswarnings=$(stylecoptreaterrorsaswarnings);                 defineconstants=$(defineconstants);                 buildinparallel=$(buildinparallel);                 generateserializationassemblies=$(generateserializationassemblies);                 "             targets="$(webprojecttargets)" />         <msbuild             projects="$(msbuildprojectdirectory)\source\webprojects\webapp2\webapp2.csproj"             properties="                 configuration=$(configuration);                 packagelocation=$(msbuildprojectdirectory)\packages\webapp2.zip;                 runcodeanalysis=$(runcodeanalysis);                 codeanalysistargets=$(codeanalysistargets);                 codeanalysistreatwarningsaserrors=$(codeanalysistreatwarningsaserrors);                 stylecoptreaterrorsaswarnings=$(stylecoptreaterrorsaswarnings);                 defineconstants=$(defineconstants);                 buildinparallel=$(buildinparallel);                 generateserializationassemblies=$(generateserializationassemblies);                 "             targets="$(webprojecttargets)" />         <msbuild             projects="$(msbuildprojectdirectory)\source\webprojects\administrator\administrator.csproj"             properties="                 configuration=$(configuration);                 packagelocation=$(msbuildprojectdirectory)\packages\administrator.zip;                 runcodeanalysis=$(runcodeanalysis);                 codeanalysistargets=$(codeanalysistargets);                 codeanalysistreatwarningsaserrors=$(codeanalysistreatwarningsaserrors);                 stylecoptreaterrorsaswarnings=$(stylecoptreaterrorsaswarnings);                 defineconstants=$(defineconstants);                 buildinparallel=$(buildinparallel);                 generateserializationassemblies=$(generateserializationassemblies);                 "             targets="$(webprojecttargets)" />         <msbuild             projects="$(msbuildprojectdirectory)\source\otherprojects\service\service.csproj"             properties="                 configuration=$(configuration);                 runcodeanalysis=$(runcodeanalysis);                 codeanalysistargets=$(codeanalysistargets);                 codeanalysistreatwarningsaserrors=$(codeanalysistreatwarningsaserrors);                 stylecoptreaterrorsaswarnings=$(stylecoptreaterrorsaswarnings);                 defineconstants=$(defineconstants);                 buildinparallel=$(buildinparallel);                 generateserializationassemblies=$(generateserializationassemblies);                 "             targets="$(otherprojecttargets)" />     </target> </project> 

any idea how prevent code analysis running on same assembly more once in situation?

usually, run code analysis command line tool, after "packing" binary distribution. msbuildcodemetrics "embryo" project running metrics inside build.

the idea break build if user commits method many lines or many cyclomatic complexity, project isn't maturity yet.

anyway, if want run metrics through command line, try:

http://msdn.microsoft.com/en-us/library/bb385914.aspx

of course you'll need magic copy assemblies temp dir (like final package) , run metrics based on directory.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -