|
1 | 1 | <?xml version="1.0" encoding="utf-8"?>
|
2 | 2 | <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
3 | 3 |
|
4 |
| - <Target Name="PrepareNUnitRunner"> |
5 |
| - <!-- |
6 |
| - Look for the NUnit tools directory. |
7 |
| - LastMatch is used so that we get the highest version of runner available. |
8 |
| - --> |
9 |
| - <ItemGroup> |
10 |
| - <NUnitPaths Include="packages\Nunit*\tools\nunit3-console.exe" /> |
11 |
| - <NUnitPaths Include="packages\Nunit*\*\tools\nunit3-console.exe" /> |
12 |
| - </ItemGroup> |
13 |
| - <FindInList List="@(NUnitPaths)" FindLastMatch="true" ItemSpecToFind="%(NUnitPaths.Identity)" > |
14 |
| - <Output TaskParameter="ItemFound" PropertyName="NUnitRunnerPath"/> |
15 |
| - </FindInList> |
16 |
| - <Message Text="NUnit runner paths: @(NUnitPaths)" /> |
17 |
| - <Error Condition="'$(NUnitRunnerPath)' == ''" Text="Could not find NUnit runner executable." /> |
18 |
| - <Error Condition="!Exists('$(NUnitRunnerPath)')" Text="Could not find NUnit runner executable." /> |
19 |
| - |
20 |
| - <Message Text="Using NUnit at: $(NUnitRunnerPath)" /> |
21 |
| - |
22 |
| - <PropertyGroup> |
23 |
| - <NumberOfParallelAgents>$(NUMBER_OF_PROCESSORS)</NumberOfParallelAgents> |
24 |
| - <NumberOfParallelAgents Condition="'$(NumberOfParallelAgents)' == ''">4</NumberOfParallelAgents> |
25 |
| - </PropertyGroup> |
26 |
| - <Message Text="Limit NUnit agent concurrency to $(NumberOfParallelAgents)" /> |
27 |
| - </Target> |
28 |
| - |
29 |
| - <Target Name="PrepareTeamCityVSTestAdapterPath" Condition="'$(UseTeamCityLogging)' == 'True'"> |
30 |
| - <ItemGroup> |
31 |
| - <TeamCityVSTestAdapterPaths Include="packages\teamcity.vstest.testadapter\*\build\_common\vstest*\TeamCity.VSTest.TestAdapter.dll" /> |
32 |
| - </ItemGroup> |
33 |
| - <ItemGroup> |
34 |
| - <TeamCityVSTestAdapterDirectories Include="@(TeamCityVSTestAdapterPaths->'%(RelativeDir)')" /> |
35 |
| - </ItemGroup> |
36 |
| - <FindInList List="@(TeamCityVSTestAdapterDirectories)" FindLastMatch="true" ItemSpecToFind="%(TeamCityVSTestAdapterDirectories.Identity)" Condition="'@(TeamCityVSTestAdapterDirectories)' != ''" > |
37 |
| - <Output TaskParameter="ItemFound" PropertyName="TeamCityVSTestAdapterPath"/> |
38 |
| - </FindInList> |
39 |
| - <Message Text="TeamCity VSTest adapter paths: @(TeamCityVSTestAdapterPaths)" /> |
40 |
| - |
41 |
| - <Message Text="Using TeamCity VSTest adapter at: $(TeamCityVSTestAdapterPath)" /> |
42 |
| - </Target> |
43 |
| - |
44 |
| - <Target Name="PrepareDotCover" Condition="'$(DotCoverConfigurationFile)' != ''"> |
45 |
| - <!-- |
46 |
| - Look for the dotCover command line runner. |
47 |
| - LastMatch is used so that we get the highest version of runner available. |
48 |
| - --> |
49 |
| - <ItemGroup> |
50 |
| - <DotCoverPaths Condition="'$(agent_home_dir)' != ''" Include="$(agent_home_dir)\tools\**\dotCover.exe" /> |
51 |
| - <DotCoverPaths Include="packages\JetBrains.dotCover.CommandLineTools*\tools\dotCover.exe" /> |
52 |
| - <DotCoverPaths Include="packages\JetBrains.dotCover.CommandLineTools\*\tools\dotCover.exe" /> |
53 |
| - </ItemGroup> |
54 |
| - <ItemGroup> |
55 |
| - <DotCoverDirectories Include="@(DotCoverPaths->'%(RootDir)%(Directory)')" /> |
56 |
| - </ItemGroup> |
57 |
| - <FindInList List="@(DotCoverDirectories)" FindLastMatch="true" ItemSpecToFind="%(DotCoverDirectories.Identity)" Condition="'@(DotCoverDirectories)' != ''"> |
58 |
| - <Output TaskParameter="ItemFound" PropertyName="DotCoverRunnerDirectory"/> |
59 |
| - </FindInList> |
60 |
| - <Message Text="dotCover runner paths: @(DotCoverPaths)" /> |
61 |
| - <Message Text="dotCover runner directories: @(DotCoverDirectories)" /> |
62 |
| - <Message Condition="'$(DotCoverRunnerDirectory)' == ''" Text="Could not find dotCover runner executable." /> |
63 |
| - <PropertyGroup> |
64 |
| - <DotCoverRunnerPath Condition="'$(DotCoverRunnerDirectory)' != ''">$(DotCoverRunnerDirectory)dotCover.exe</DotCoverRunnerPath> |
65 |
| - </PropertyGroup> |
66 |
| - <Error Condition="'$(DotCoverRunnerPath)' != '' And !Exists('$(DotCoverRunnerPath)')" Text="Could not find dotCover runner executable." /> |
67 |
| - |
68 |
| - <Message Text="##teamcity[dotNetCoverage dotcover_home='$(DotCoverRunnerDirectory)']" Condition="'$(DotCoverRunnerPath)' != ''" /> |
69 |
| - <Message Text="Using dotCover at: $(DotCoverRunnerPath)" Condition="'$(DotCoverRunnerPath)' != ''" /> |
70 |
| - </Target> |
71 |
| - |
72 |
| - <Target Name="BuildNUnitTestAssemblies" Condition="'@(NUnitProjects)' != ''"> |
73 |
| - <MSBuild Projects="@(NUnitProjects)" Targets="DispatchToInnerBuilds" ToolsVersion="$(PreferredMSBuildToolsVersion)" BuildInParallel="true" Properties="@(_BuildProperties);InnerTargets=Build" > |
74 |
| - <Output TaskParameter="TargetOutputs" ItemName="NUnitProjectAssemblies" /> |
75 |
| - </MSBuild> |
76 |
| - <Error Condition="'@(NUnitProjectAssemblies)' == ''" Text="NUnit projects were found, but the build produced no assemblies." /> |
77 |
| - |
78 |
| - <ConvertToAbsolutePath Paths="@(NUnitProjects)"> |
79 |
| - <Output TaskParameter="AbsolutePaths" ItemName="NUnitProjectsAbsolute" /> |
80 |
| - </ConvertToAbsolutePath> |
81 |
| - <ItemGroup> |
82 |
| - <NUnitProjectsOutputs Include="%(NUnitProjectAssemblies.MSBuildSourceProjectFile)"> |
83 |
| - <TargetPath>%(NUnitProjectAssemblies.Identity)</TargetPath> |
84 |
| - <TargetFrameworkIdentifier>%(NUnitProjectAssemblies.TargetFrameworkIdentifier)</TargetFrameworkIdentifier> |
85 |
| - </NUnitProjectsOutputs> |
86 |
| - <NUnitTestProjectsWithDependsOn Include="%(Identity)" Condition="'@(NUnitProjectsAbsolute->'%(DependsOn)')' != ''" > |
87 |
| - <DependsOn>@(NUnitProjectsAbsolute->'%(DependsOn)')</DependsOn> |
88 |
| - </NUnitTestProjectsWithDependsOn> |
89 |
| - <NUnitTestAssemblies Include="@(NUnitProjectsOutputs->'%(TargetPath)')"> |
90 |
| - <OriginalProject>%(NUnitProjectsOutputs.Identity)</OriginalProject> |
91 |
| - <DotCoverSnapshot>%(TargetPath).dcvr</DotCoverSnapshot> |
92 |
| - <UseDotNetTest Condition="'%(TargetFrameworkIdentifier)' == '.NETCoreApp'">True</UseDotNetTest> |
93 |
| - </NUnitTestAssemblies> |
94 |
| - </ItemGroup> |
95 |
| - </Target> |
96 |
| - |
97 |
| - <Target Name="_SelectCoverageTool" DependsOnTargets="PrepareDotCover"> |
98 |
| - <PropertyGroup> |
99 |
| - <CoverageToolName Condition="'$(DotCoverRunnerPath)' != ''">DotCover</CoverageToolName> |
100 |
| - <CoverageToolName Condition="'$(CoverageToolName)' == ''">*NONE*</CoverageToolName> |
101 |
| - </PropertyGroup> |
102 |
| - <Message Text="Coverage tool: $(CoverageToolName)" /> |
103 |
| - </Target> |
104 |
| - |
105 |
| - <Target Name="RunNUnitTests" Condition="'@(NUnitProjects)' != ''" DependsOnTargets="_SelectCoverageTool;RunNUnitTestsOnly;RunNUnitTestsWithDotCover"> |
106 |
| - </Target> |
107 |
| - |
108 |
| - <Target Name="RunNUnitTestsOnly" Condition="'$(CoverageToolName)' == '*NONE*'" DependsOnTargets="_RunNUnitTestsOnly"> |
109 |
| - </Target> |
110 |
| - |
111 |
| - <Target Name="_BuildNUnitTestsDependsOn" Inputs="@(NUnitTestProjectsWithDependsOn)" Outputs="%(Identity).skip" DependsOnTargets="PrepareNUnitRunner;BuildNUnitTestAssemblies"> |
112 |
| - <Message Text="%(NUnitTestProjectsWithDependsOn.Identity):" /> |
113 |
| - <Message Text=" Depends on: %(NUnitTestProjectsWithDependsOn.DependsOn)" /> |
114 |
| - |
115 |
| - <MSBuild Projects="%(NUnitTestProjectsWithDependsOn.Identity)" Targets="%(NUnitTestProjectsWithDependsOn.DependsOn)" /> |
116 |
| - </Target> |
117 |
| - |
118 |
| - <Target Name="_RunNUnitTestsOnly" Inputs="@(NUnitTestAssemblies)" Outputs="%(Identity).skip" DependsOnTargets="PrepareNUnitRunner;PrepareTeamCityVSTestAdapterPath;BuildNUnitTestAssemblies;_BuildNUnitTestsDependsOn"> |
119 |
| - <PropertyGroup> |
120 |
| - <NUnitTestAssemblies>@(NUnitTestAssemblies -> '"%(Identity)"', ' ')</NUnitTestAssemblies> |
121 |
| - </PropertyGroup> |
122 |
| - |
123 |
| - <ItemGroup> |
124 |
| - <_NUnitArguments Include='--teamcity' Condition="'$(UseTeamCityLogging)' == 'True'" /> |
125 |
| - <_NUnitArguments Include='--agents=$(NumberOfParallelAgents)' /> |
126 |
| - <_NUnitArguments Include='$(NUnitTestAssemblies)' /> |
127 |
| - </ItemGroup> |
128 |
| - |
129 |
| - <ItemGroup> |
130 |
| - <_DotNetTestArguments Include='--logger:teamcity --test-adapter-path:$(TeamCityVSTestAdapterPath)' Condition="'$(UseTeamCityLogging)' == 'True' And '$(TeamCityVSTestAdapterPath)' != ''" /> |
131 |
| - <_DotNetTestArguments Include='$(NUnitTestAssemblies)' /> |
132 |
| - </ItemGroup> |
133 |
| - |
134 |
| - <Exec Command="dotnet test @(_DotNetTestArguments, ' ')" Condition="'%(NUnitTestAssemblies.UseDotNetTest)' == 'True'" /> |
135 |
| - <Exec Command=""$(NUnitRunnerPath)" @(_NUnitArguments, ' ')" Condition="'%(NUnitTestAssemblies.UseDotNetTest)' != 'True'"/> |
136 |
| - </Target> |
137 |
| - |
138 |
| - <Target Name="RunNUnitTestsWithDotCover" Condition="'$(CoverageToolName)' == 'DotCover'" DependsOnTargets="_RunNUnitTestsWithDotCover"> |
139 |
| - <PropertyGroup> |
140 |
| - <DotCoverMergedSnapshotPath>_DotCoverMergedSnapshot.dcvr</DotCoverMergedSnapshotPath> |
141 |
| - </PropertyGroup> |
142 |
| - <Exec Command='"$(DotCoverRunnerPath)" merge /Source="@(DotCoverSnapshots)" /Output="$(DotCoverMergedSnapshotPath)"' /> |
143 |
| - |
144 |
| - <Exec Condition="'$(DotCoverXmlReportPath)' != ''" Command='"$(DotCoverRunnerPath)" report /Source="$(DotCoverMergedSnapshotPath)" /Output="$(DotCoverXmlReportPath)" /ReportType=XML' /> |
145 |
| - <Exec Condition="'$(DotCoverHtmlReportPath)' != ''" Command='"$(DotCoverRunnerPath)" report /Source="$(DotCoverMergedSnapshotPath)" /Output="$(DotCoverHtmlReportPath)" /ReportType=HTML' /> |
146 |
| - |
147 |
| - </Target> |
148 |
| - |
149 |
| - <Target Name="_RunNUnitTestsWithDotCover" Inputs="@(NUnitTestAssemblies)" Outputs="%(DotCoverSnapshot)" DependsOnTargets="PrepareNUnitRunner;PrepareTeamCityVSTestAdapterPath;PrepareDotCover;BuildNUnitTestAssemblies;_BuildNUnitTestsDependsOn"> |
150 |
| - <Message Text="DotCover + NUnit: %(NUnitTestAssemblies.Identity) -> %(NUnitTestAssemblies.DotCoverSnapshot)" /> |
151 |
| - |
152 |
| - <ItemGroup> |
153 |
| - <_NUnitArguments Include='--teamcity' Condition="'$(UseTeamCityLogging)' == 'True'" /> |
154 |
| - <_NUnitArguments Include='"%(NUnitTestAssemblies.Identity)"' /> |
155 |
| - </ItemGroup> |
156 |
| - <PropertyGroup> |
157 |
| - <_NUnitArgumentString>@(_NUnitArguments, ' ')</_NUnitArgumentString> |
158 |
| - </PropertyGroup> |
159 |
| - |
160 |
| - <ItemGroup> |
161 |
| - <!-- This does not work with dotCover: --> |
162 |
| - <!-- <_DotNetTestArguments Include='--logger:teamcity "--test-adapter-path:$(TeamCityVSTestAdapterPath)"' Condition="'$(UseTeamCityLogging)' == 'True' And '$(TeamCityVSTestAdapterPath)' != ''" />--> |
163 |
| - <_DotNetTestArguments Include='"%(NUnitTestAssemblies.Identity)"' /> |
164 |
| - </ItemGroup> |
165 |
| - <PropertyGroup> |
166 |
| - <_DotNetTestArgumentString>@(_DotNetTestArguments, ' ')</_DotNetTestArgumentString> |
167 |
| - </PropertyGroup> |
168 |
| - |
169 |
| - <ItemGroup> |
170 |
| - <_DotCoverCoverageArguments Include='"$(DotCoverConfigurationFile)"' /> |
171 |
| - <_DotCoverCoverageArguments Include='/Output="%(NUnitTestAssemblies.DotCoverSnapshot)"' /> |
172 |
| - <_DotCoverCoverageArguments Include='/TargetExecutable="$(NUnitRunnerPath)"' Condition="'%(NUnitTestAssemblies.UseDotNetTest)' != 'True'" /> |
173 |
| - </ItemGroup> |
174 |
| - <PropertyGroup> |
175 |
| - <_DotCoverCoverageArgumentString>@(_DotCoverCoverageArguments, ' ')</_DotCoverCoverageArgumentString> |
176 |
| - </PropertyGroup> |
177 |
| - |
178 |
| - <Exec Command=""$(DotCoverRunnerPath)" cover-dotnet $(_DotCoverCoverageArgumentString) -- $(_DotNetTestArgumentString)" Condition="'%(NUnitTestAssemblies.UseDotNetTest)' == 'True'" /> |
179 |
| - <Exec Command=""$(DotCoverRunnerPath)" cover $(_DotCoverCoverageArgumentString) -- $(_NUnitArgumentString)" Condition="'%(NUnitTestAssemblies.UseDotNetTest)' != 'True'" /> |
180 |
| - <Message Text="##teamcity[importData type='dotNetCoverage' tool='dotcover' path='%(NUnitTestAssemblies.DotCoverSnapshot)']" /> |
181 |
| - |
182 |
| - <ItemGroup> |
183 |
| - <DotCoverSnapshots Include="%(NUnitTestAssemblies.DotCoverSnapshot)" /> |
184 |
| - </ItemGroup> |
185 |
| - </Target> |
| 4 | + <Import Project="NUnitProjects.targets" /> |
186 | 5 |
|
187 | 6 | <Target Name="PrepareBuildProperties">
|
188 | 7 | <ItemGroup>
|
|
0 commit comments