-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
84 lines (66 loc) · 3.33 KB
/
build.xml
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<!--
msbuild build.xml => compile and run unit tests
msbuild build.xml /t:CoverageReport => compile, test anf generate coverage report
msbuild build.xml /t:Sonar => run sonarqube analysis
-->
<PropertyGroup Condition="'$(Configuration)'==''">
<Configuration>Debug</Configuration>
</PropertyGroup>
<PropertyGroup>
<!--
You need to install following nuget packages in your solution first:
Nunit.Runners
OpenCover
ReportGenerator
versions may change
-->
<NUnit-ToolPath>packages\NUnit.ConsoleRunner.3.4.1\tools\</NUnit-ToolPath>
<OpenCover-ToolPath>packages\OpenCover.4.6.519\tools\</OpenCover-ToolPath>
<ReportGenerator-ToolPath>packages\ReportGenerator.2.4.5.0\tools\</ReportGenerator-ToolPath>
<!-- your app sln file -->
<SolutionFile>SharpScan.sln</SolutionFile>
<!-- assembly filter for opencover -->
<OpenCover-AssemblyFilter>+[SharpScan]*</OpenCover-AssemblyFilter>
<!-- patterns may change depending of your solution layout -->
<CoverageFilesPattern>.build\*.coverage.xml</CoverageFilesPattern>
<TestAssembliesPattern>$(MSBuildProjectDirectory)\SharpScanTests\bin\$(Configuration)\*Tests.dll</TestAssembliesPattern>
</PropertyGroup>
<UsingTask TaskName="ReportGenerator" AssemblyFile="$(ReportGenerator-ToolPath)\ReportGenerator.exe" />
<ItemGroup>
<SourceDirectories Include="$(MSBuildProjectDirectory)" />
</ItemGroup>
<Target Name="Clean">
<RemoveDir Directories=".build" />
<MSBuild Projects="$(SolutionFile)" Targets="Clean" />
</Target>
<Target Name="Compile">
<MSBuild Projects="$(SolutionFile)" Targets="Build" />
</Target>
<Target Name="Test" DependsOnTargets="Clean;Compile">
<ItemGroup>
<TestAssemblies Include="$(TestAssembliesPattern)" />
</ItemGroup>
<MakeDir Directories=".build" />
<Exec Command="$(NUnit-ToolPath)nunit3-console.exe %(TestAssemblies.Identity) /result=.build\%(TestAssemblies.filename)-test-results.xml;format=nunit2" />
</Target>
<Target Name="Build" DependsOnTargets="Test" />
<Target Name="Coverage" DependsOnTargets="Clean;Compile;Test">
<ItemGroup>
<TestAssemblies Include="$(TestAssembliesPattern)" />
</ItemGroup>
<MakeDir Directories=".build" />
<!-- /domain=single is not support by the NUnit msbuild task, and it is required for OpenCover coverage test -->
<Exec Command="$(OpenCover-ToolPath)OpenCover.Console.exe -register:user -target:"$(NUnit-ToolPath)nunit3-console.exe" -targetargs:"%(TestAssemblies.Identity)" -filter:"$(OpenCover-AssemblyFilter)" -output:.build\%(TestAssemblies.FileName).coverage.xml" />
</Target>
<!--
Run ReportGenerator - local coverage history
-->
<Target Name="CoverageReport" DependsOnTargets="Coverage">
<ItemGroup>
<CoverageFiles Include="$(CoverageFilesPattern)" />
</ItemGroup>
<ReportGenerator ReportFiles="@(CoverageFiles)" TargetDirectory=".build\report" ReportTypes="Html" SourceDirectories="@(SourceDirectories)" HistoryDirectory=".coverageHistory" />
<Message Text="Coverage report has been generated: $(MSBuildProjectDirectory)\report\index.htm" />
</Target>
</Project>