PageRenderTime 23ms CodeModel.GetById 14ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/WCFWebApi/Tools/StyleCop/4.4.0/Microsoft.StyleCop.Targets

#
MSBuild | 117 lines | 80 code | 17 blank | 20 comment | 0 complexity | 4230fa2235780d560d47dd5414189573 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    <Message Text="Forcing full StyleCop reanalysis." Condition="'$(StyleCopForceFullAnalysis)' == 'true'" Importance="Low" />
 76
 77    <!-- Determine what files should be checked. Take all Compile items, but exclude those that have
 78        set ExcludeFromStyleCop=true or ExcludeFromSourceAnalysis=true. -->
 79    <CreateItem Include="@(Compile)" Condition="('%(Compile.ExcludeFromStyleCop)' != 'true') and ('%(Compile.ExcludeFromSourceAnalysis)' != 'true')">
 80      <Output TaskParameter="Include" ItemName="StyleCopFiles"/>
 81    </CreateItem>
 82
 83    <Message Text="Analyzing @(StyleCopFiles)" Importance="Low" />
 84
 85    <!-- Show list of what files should be excluded. checked. Take all Compile items, but exclude those that have
 86        set ExcludeFromStyleCop=true or ExcludeFromSourceAnalysis=true. -->
 87    <CreateItem Include="@(Compile)" Condition="('%(Compile.ExcludeFromStyleCop)' == 'true') or ('%(Compile.ExcludeFromSourceAnalysis)' == 'true')">
 88      <Output TaskParameter="Include" ItemName="StyleCopExcludedFiles"/>
 89    </CreateItem>
 90
 91    <Message Text="Excluding @(StyleCopExcludedFiles)" Importance="Normal" />
 92
 93    <!-- Run the StyleCop MSBuild task. -->
 94    <StyleCopTask
 95      ProjectFullPath="$(MSBuildProjectDirectory)"
 96      SourceFiles="@(StyleCopFiles)"
 97      AdditionalAddinPaths="@(StyleCopAdditionalAddinPaths)"
 98      ForceFullAnalysis="$(StyleCopForceFullAnalysis)"
 99      DefineConstants="$(DefineConstants)"
100      TreatErrorsAsWarnings="$(StyleCopTreatErrorsAsWarnings)"
101      CacheResults="$(StyleCopCacheResults)"
102      OverrideSettingsFile="$(StyleCopOverrideSettingsFile)"
103      OutputFile="$(StyleCopOutputFile)"
104      MaxViolationCount="$(StyleCopMaxViolationCount)"
105            />
106
107    <!-- Make output files cleanable -->
108    <CreateItem Include="$(StyleCopOutputFile)">
109      <Output TaskParameter="Include" ItemName="FileWrites"/>
110    </CreateItem>
111
112    <!-- Add the StyleCop.cache file to the list of files we've written - so they can be cleaned up on a Build Clean. -->
113    <CreateItem Include="StyleCop.Cache" Condition="'$(StyleCopCacheResults)' == 'true'">
114      <Output TaskParameter="Include" ItemName="FileWrites"/>
115    </CreateItem>
116  </Target>
117</Project>