-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathRunStyleCop.proj
60 lines (52 loc) · 1.85 KB
/
RunStyleCop.proj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="StyleCop" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask AssemblyFile="$(MSBuildExtensionsPath)\..\StyleCop 4.7\StyleCop.dll" TaskName="StyleCopTask"/>
<ItemGroup>
<_ProjectFile
Include=".\**\*.csproj"
Exclude="packages\**\*.csproj"
>
<!-- Collect all StyleCop results in a single folder -->
<ResultsFile>$(MSBuildProjectDirectory)\%(Filename).StyleCopViolations.xml</ResultsFile>
</_ProjectFile>
</ItemGroup>
<!-- Runs once for each project file discovered by the _ProjectFile item group -->
<Target Name="StyleCop" Returns="%(_ProjectFile.Identity)">
<ItemGroup>
<_SourceFile Remove="@(_SourceFile)" />
</ItemGroup>
<!-- Clean up existing results file, if necessary. -->
<PropertyGroup>
<_ResultsFile>%(_ProjectFile.ResultsFile)</_ResultsFile>
</PropertyGroup>
<Delete Files="$(_ResultsFile)" Condition="Exists('$(_ResultsFile)')" />
<!-- This target gets us all the source files in a C# project -->
<MSBuild Projects="@(_ProjectFile)" Targets="SourceFilesProjectOutputGroup" Properties="Configuration=Release;Platform=AnyCPU">
<Output
TaskParameter="TargetOutputs"
ItemName="_SourceFile" />
</MSBuild>
<Message
Importance="high"
Text="Excluding '%(_SourceFile.Identity)' from StyleCop analysis..."
Condition=" '%(_SourceFile.ExcludeFromStyleCop)' == 'true' "
/>
<ItemGroup>
<_SourceFile
Remove="@(_SourceFile)"
Condition=" '%(_SourceFile.ExcludeFromStyleCop)' == 'true' "
/>
</ItemGroup>
<Message
Importance="normal"
Text="Running StyleCop for project '@(_ProjectFile)'..."
/>
<StyleCopTask
ProjectFullPath="@(_ProjectFile)"
SourceFiles="@(_SourceFile)"
ForceFullAnalysis="true"
CacheResults="false"
OutputFile="$(_ResultsFile)"
/>
</Target>
</Project>