PageRenderTime 159ms CodeModel.GetById 155ms app.highlight 2ms RepoModel.GetById 0ms app.codeStats 0ms

/tools/StyleCop/Microsoft.StyleCop.Targets

http://github.com/agross/netopenspace
MSBuild | 109 lines | 76 code | 15 blank | 18 comment | 0 complexity | 386de2bffc2d24401dab611e4992c512 MD5 | raw file
  1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  2  <!-- Specify where tasks are implemented. -->
  3  <UsingTask AssemblyFile="Microsoft.StyleCop.dll" TaskName="StyleCopTask"/>
  4
  5  <PropertyGroup>
  6    <BuildDependsOn>$(BuildDependsOn);StyleCop</BuildDependsOn>
  7    <RebuildDependsOn>StyleCopForceFullAnalysis;$(RebuildDependsOn)</RebuildDependsOn>
  8  </PropertyGroup>
  9
 10  <!-- Define StyleCopForceFullAnalysis property. -->
 11  <PropertyGroup Condition="('$(SourceAnalysisForceFullAnalysis)' != '') and ('$(StyleCopForceFullAnalysis)' == '')">
 12    <StyleCopForceFullAnalysis>$(SourceAnalysisForceFullAnalysis)</StyleCopForceFullAnalysis>
 13  </PropertyGroup>
 14  <PropertyGroup Condition="'$(StyleCopForceFullAnalysis)' == ''">
 15    <StyleCopForceFullAnalysis>false</StyleCopForceFullAnalysis>
 16  </PropertyGroup>
 17
 18  <!-- Define StyleCopCacheResults property. -->
 19  <PropertyGroup Condition="('$(SourceAnalysisCacheResults)' != '') and ('$(StyleCopCacheResults)' == '')">
 20    <StyleCopCacheResults>$(SourceAnalysisCacheResults)</StyleCopCacheResults>
 21  </PropertyGroup>
 22  <PropertyGroup Condition="'$(StyleCopCacheResults)' == ''">
 23    <StyleCopCacheResults>true</StyleCopCacheResults>
 24  </PropertyGroup>
 25
 26  <!-- Define StyleCopTreatErrorsAsWarnings property. -->
 27  <PropertyGroup Condition="('$(SourceAnalysisTreatErrorsAsWarnings)' != '') and ('$(StyleCopTreatErrorsAsWarnings)' == '')">
 28    <StyleCopTreatErrorsAsWarnings>$(SourceAnalysisTreatErrorsAsWarnings)</StyleCopTreatErrorsAsWarnings>
 29  </PropertyGroup>
 30  <PropertyGroup Condition="'$(StyleCopTreatErrorsAsWarnings)' == ''">
 31    <StyleCopTreatErrorsAsWarnings>true</StyleCopTreatErrorsAsWarnings>
 32  </PropertyGroup>
 33
 34  <!-- Define StyleCopEnabled property. -->
 35  <PropertyGroup Condition="('$(SourceAnalysisEnabled)' != '') and ('$(StyleCopEnabled)' == '')">
 36    <StyleCopEnabled>$(SourceAnalysisEnabled)</StyleCopEnabled>
 37  </PropertyGroup>
 38  <PropertyGroup Condition="'$(StyleCopEnabled)' == ''">
 39    <StyleCopEnabled>true</StyleCopEnabled>
 40  </PropertyGroup>
 41
 42  <!-- Define StyleCopOverrideSettingsFile property. -->
 43  <PropertyGroup Condition="('$(SourceAnalysisOverrideSettingsFile)' != '') and ('$(StyleCopOverrideSettingsFile)' == '')">
 44    <StyleCopOverrideSettingsFile>$(SourceAnalysisOverrideSettingsFile)</StyleCopOverrideSettingsFile>
 45  </PropertyGroup>
 46  <PropertyGroup Condition="'$(StyleCopOverrideSettingsFile)' == ''">
 47    <StyleCopOverrideSettingsFile> </StyleCopOverrideSettingsFile>
 48  </PropertyGroup>
 49
 50  <!-- Define StyleCopOutputFile property. -->
 51  <PropertyGroup Condition="('$(SourceAnalysisOutputFile)' != '') and ('$(StyleCopOutputFile)' == '')">
 52    <StyleCopOutputFile>$(SourceAnalysisOutputFile)</StyleCopOutputFile>
 53  </PropertyGroup>
 54  <PropertyGroup Condition="'$(StyleCopOutputFile)' == ''">
 55    <StyleCopOutputFile>$(IntermediateOutputPath)StyleCopViolations.xml</StyleCopOutputFile>
 56  </PropertyGroup>
 57
 58  <!-- Define all new properties which do not need to have both StyleCop and SourceAnalysis variations. -->
 59  <PropertyGroup>
 60    <!-- Specifying 0 will cause StyleCop to use the default violation count limit.
 61         Specifying any positive number will cause StyleCop to use that number as the violation count limit.
 62         Specifying any negative number will cause StyleCop to allow any number of violations without limit. -->
 63    <StyleCopMaxViolationCount Condition="'$(StyleCopMaxViolationCount)' == ''">0</StyleCopMaxViolationCount>
 64  </PropertyGroup>
 65
 66  <!-- Define target: StyleCopForceFullAnalysis -->
 67  <Target Name="StyleCopForceFullAnalysis">
 68    <CreateProperty Value="true">
 69      <Output TaskParameter="Value" PropertyName="StyleCopForceFullAnalysis" />
 70    </CreateProperty>
 71  </Target>
 72
 73  <!-- Define target: StyleCop -->
 74  <Target Name="StyleCop" Condition="'$(StyleCopEnabled)' != 'false'">
 75    <!-- Determine what files should be checked. Take all Compile items, but exclude those that have
 76        set ExcludeFromStyleCop=true or ExcludeFromSourceAnalysis=true. -->
 77    <CreateItem Include="@(Compile)" Condition="('%(Compile.ExcludeFromStyleCop)' != 'true') and ('%(Compile.ExcludeFromSourceAnalysis)' != 'true')">
 78      <Output TaskParameter="Include" ItemName="StyleCopFiles"/>
 79    </CreateItem>
 80
 81    <Message Text="Forcing full StyleCop reanalysis." Condition="'$(StyleCopForceFullAnalysis)' == 'true'" Importance="Low" />
 82
 83    <Message Text="Analyzing @(StyleCopFiles)" Importance="Low" />
 84
 85    <!-- Run the StyleCop MSBuild task. -->
 86    <StyleCopTask
 87      ProjectFullPath="$(MSBuildProjectFile)"
 88      SourceFiles="@(StyleCopFiles)"
 89      AdditionalAddinPaths="@(StyleCopAdditionalAddinPaths)"
 90      ForceFullAnalysis="$(StyleCopForceFullAnalysis)"
 91      DefineConstants="$(DefineConstants)"
 92      TreatErrorsAsWarnings="$(StyleCopTreatErrorsAsWarnings)"
 93      CacheResults="$(StyleCopCacheResults)"
 94      OverrideSettingsFile="$(StyleCopOverrideSettingsFile)"
 95      OutputFile="$(StyleCopOutputFile)"
 96      MaxViolationCount="$(StyleCopMaxViolationCount)"
 97            />
 98
 99    <!-- Make output files cleanable -->
100    <CreateItem Include="$(StyleCopOutputFile)">
101      <Output TaskParameter="Include" ItemName="FileWrites"/>
102    </CreateItem>
103
104    <!-- Add the StyleCop.cache file to the list of files we've written - so they can be cleaned up on a Build Clean. -->
105    <CreateItem Include="StyleCop.Cache" Condition="'$(StyleCopCacheResults)' == 'true'">
106      <Output TaskParameter="Include" ItemName="FileWrites"/>
107    </CreateItem>
108  </Target>
109</Project>