This repository has been archived by the owner on Jul 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.Test.Unit.msbuild
96 lines (83 loc) · 5.36 KB
/
Build.Test.Unit.msbuild
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
85
86
87
88
89
90
91
92
93
94
95
96
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0"
DefaultTargets="Run"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- Build configuration -->
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<Platform Condition=" '$(Platform)' == ''">Any CPU</Platform>
<PlatformTranslated>$(Platform.Replace(" ",""))</PlatformTranslated>
<!-- Directories -->
<DirWorkspace>$(MSBuildProjectDirectory)</DirWorkspace>
<DirPackages>$(DirWorkspace)\packages</DirPackages>
<DirTools>$(DirWorkspace)\tools</DirTools>
<DirBuild>$(DirWorkspace)\build</DirBuild>
<DirBuildBin>$(DirBuild)\bin\$(PlatformTranslated)\$(Configuration)</DirBuildBin>
<DirBuildLogs>$(DirBuild)\logs</DirBuildLogs>
<DirBuildTemp>$(DirBuild)\temp</DirBuildTemp>
<!-- Tools -->
<MsBuildExtensionsPath>$(DirTools)\msbuild.extensions</MsBuildExtensionsPath>
</PropertyGroup>
<Import Project="$(MsBuildExtensionsPath)\FindToolDirectoryFromPackages.msbuild"
Condition="Exists('$(MsBuildExtensionsPath)\FindToolDirectoryFromPackages.msbuild')" />
<Import Project="$(MsBuildExtensionsPath)\OpenCover.msbuild"
Condition="Exists('$(MsBuildExtensionsPath)\OpenCover.msbuild')"/>
<Import Project="$(MsBuildExtensionsPath)\ReportGenerator.msbuild"
Condition="Exists('$(MsBuildExtensionsPath)\ReportGenerator.msbuild')"/>
<Import Project="$(MsBuildExtensionsPath)\ReportGeneratorOutputToCsv.msbuild"
Condition="Exists('$(MsBuildExtensionsPath)\ReportGeneratorOutputToCsv.msbuild')"/>
<Target Name="Run" DependsOnTargets="_ExecuteUnitTestsWithCoverage">
<!-- Do nothing here -->
</Target>
<!-- Display info -->
<Target Name="_DisplayInfo">
<Message Text="Running unit tests ..." />
</Target>
<PropertyGroup>
<FileNUnitExe>nunit-console-x86.exe</FileNUnitExe>
</PropertyGroup>
<PropertyGroup>
<FileOpenCoverReport>$(DirBuildLogs)\opencover.xml</FileOpenCoverReport>
<FileOpenCoverExe>opencover.console.exe</FileOpenCoverExe>
<FileReportGeneratorExe>ReportGenerator.exe</FileReportGeneratorExe>
<ReportGeneratorOutputDir>$(DirBuildLogs)\coverage</ReportGeneratorOutputDir>
<ReportGeneratorXmlSummaryFile>$(ReportGeneratorOutputDir)\Summary.xml</ReportGeneratorXmlSummaryFile>
<CoverageCsvFile>$(DirBuildLogs)\coverage.csv</CoverageCsvFile>
</PropertyGroup>
<Target Name="_ExecuteUnitTestsWithCoverage" Condition="$(ShouldHaveCoverage) AND '$(Configuration)' != 'Deploy'" DependsOnTargets="_DisplayInfo">
<MakeDir Directories="$(DirBuildTemp)" Condition="!Exists('$(DirBuildTemp)')" />
<MakeDir Directories="$(DirBuildLogs)" Condition="!Exists('$(DirBuildLogs)')" />
<MakeDir Directories="$(ReportGeneratorOutputDir)" Condition="!Exists('$(ReportGeneratorOutputDir)')" />
<FindToolDirectoryFromPackages PackagesDir="$(DirPackages)" FileToLocate="$(FileNUnitExe)">
<Output TaskParameter="Path" PropertyName="PathNUnitDir" />
</FindToolDirectoryFromPackages>
<FindToolDirectoryFromPackages PackagesDir="$(DirPackages)" FileToLocate="$(FileOpenCoverExe)">
<Output TaskParameter="Path" PropertyName="PathOpenCoverDir" />
</FindToolDirectoryFromPackages>
<FindToolDirectoryFromPackages PackagesDir="$(DirPackages)" FileToLocate="$(FileReportGeneratorExe)">
<Output TaskParameter="Path" PropertyName="PathReportGeneratorDir" />
</FindToolDirectoryFromPackages>
<ItemGroup>
<NUnitTestAssemblies Include="$(DirBuildBin)\**\test.unit.*.dll" />
</ItemGroup>
<ItemGroup>
<OpenCoverIgnoreAttributes Include="System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute" />
<OpenCoverIgnoreAttributes Include="System.Runtime.CompilerServices.CompilerGeneratedAttribute" />
</ItemGroup>
<OpenCover OpenCoverExe="$(FileOpenCoverExe)"
OpenCoverDir="$(PathOpenCoverDir)"
OpenCoverOutput="$(FileOpenCoverReport)"
OpenCoverFilters="+[Nuclei]* +[Nuclei.*]* -[Nuclei.Examples*]* -[*Test.Unit*]* -[NUnit]* -[NUnit.*]*"
OpenCoverExcludeAttributes="@(OpenCoverIgnoreAttributes)"
UnitTestDir="$(PathNUnitDir)"
UnitTestExe="$(FileNUnitExe)"
UnitTestArguments="/framework:net-4.5 /result:"nunit-console.xml" /work:"$(DirBuildLogs)" /noshadow /domain:single @(NUnitTestAssemblies->'%22%(FullPath)%22', ' ')"
BinDir="$(DirBuildBin)" />
<ReportGenerator ReportGeneratorExe="$(FileReportGeneratorExe)"
ReportGeneratorDir="$(PathReportGeneratorDir)"
OpenCoverOutputFile="$(FileOpenCoverReport)"
OutputDir="$(ReportGeneratorOutputDir)" />
<ReportGeneratorOutputToCsv InputFile="$(ReportGeneratorXmlSummaryFile)"
OutputFile="$(CoverageCsvFile)" />
</Target>
</Project>