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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
|
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="Directory.Build.props" />
<PropertyGroup>
<XunitTestBinBase Condition="'$(XunitTestBinBase)'==''" >$(BaseOutputPathWithConfig)</XunitTestBinBase>
<XunitWrapperGeneratedCSDirBase>$(XunitTestBinBase)\TestWrappers\</XunitWrapperGeneratedCSDirBase>
<MSBuildEnableAllPropertyFunctions>1</MSBuildEnableAllPropertyFunctions>
<TestScriptExtension Condition="'$(TestWrapperTargetsWindows)' != 'true' ">sh</TestScriptExtension>
<TestScriptExtension Condition="'$(TestWrapperTargetsWindows)' == 'true' ">cmd</TestScriptExtension>
</PropertyGroup>
<ItemGroup>
<DisabledTestDir Include="bin" />
<DisabledTestDir Include="Common" />
<DisabledTestDir Include="Tests" />
<DisabledTestDir Include="TestWrappers" />
<_SkipTestDir Include="@(DisabledTestDir)" />
</ItemGroup>
<Target Name="Rebuild" />
<Target Name="FindCmdDirectories" DependsOnTargets="GetListOfTestCmds">
<Error Condition="!Exists('$(XunitTestBinBase)')"
Text="$(XunitTestBinBase) does not exist. Please run src\tests\build / src/tests/build.sh from the repo root at least once to get the tests built." />
<ItemGroup>
<AllTestDirsNonCanonicalPaths Include="$([System.IO.Directory]::GetDirectories(`$(XunitTestBinBase)`))" />
<AllTestDirsPaths Include="@(AllTestDirsNonCanonicalPaths)" />
<AllTestDirsPaths Include="@(AllTestDirsNonCanonicalPaths)" >
<Path>$([System.IO.Path]::GetFullPath(%(Identity)))</Path>
</AllTestDirsPaths>
<SkipTestDirsPaths Include="$([System.IO.Path]::GetFullPath('$(XunitTestBinBase)%(_SkipTestDir.Identity)'))" />
<NonExcludedTestDirectories Include="@(AllTestDirsPaths -> '%(Path)')" Exclude="@(SkipTestDirsPaths)" />
<TopLevelDirectories Include="@(NonExcludedTestDirectories)" />
<SecondLevel Include="$([System.IO.Directory]::GetDirectories(%(TopLevelDirectories.Identity)))" />
<SecondLevelDirectories Include="@(SecondLevel)">
<Path>$([System.IO.Path]::GetFullPath(%(AllRunnableTestPaths.Identity)))</Path>
</SecondLevelDirectories>
<TestDirectoriesWithDup Include="@(SecondLevelDirectories -> '%(Identity)')" Condition="$([System.String]::new('%(Path)').StartsWith('%(Identity)'))" />
</ItemGroup>
<RemoveDuplicates Inputs="@(TestDirectoriesWithDup)">
<Output
TaskParameter="Filtered"
ItemName="TestDirectories"/>
</RemoveDuplicates>
</Target>
<!-- Target to check the test build, to see if it looks ok. We've had several cases where a change inadvertently and drastically changes
the set of tests that are built, and that change is unnoticed. The most common case is for a build of the Priority 1 tests
to only build the Priority 0 tests. This target is run after a test build to verify that the basic number of tests that were
built is basically what was expected. When this was written, there were about 2500 Priority 0 tests and about 10268 Priority 1
tests on Windows, 9976 on Ubuntu (it differs slightly based on platform). We currently check that the number of Priority 0 tests
is greater than 2000 and less than 3000, and the number of Priority 1 tests is greater than 9000.
-->
<Target Name="CheckTestBuild" DependsOnTargets="GetListOfTestCmds">
<Error Condition="!Exists('$(XunitTestBinBase)')"
Text="$(XunitTestBinBase) does not exist. Please run src\tests\build / src/tests/build.sh from the repo root at least once to get the tests built." />
<PropertyGroup>
<TestCount>@(AllRunnableTestPaths->Count())</TestCount>
</PropertyGroup>
<Message Text="Found $(TestCount) built tests"/>
<ItemGroup>
<Error Condition="'$(CLRTestPriorityToBuild)' == '0' and '$(TestCount)' <= 2000" Text="Unexpected test count. Expected > 2000, found $(TestCount).'" />
<Error Condition="'$(CLRTestPriorityToBuild)' == '0' and '$(TestCount)' >= 3000" Text="Unexpected test count. Expected < 3000, found $(TestCount).'" />
<Error Condition="'$(CLRTestPriorityToBuild)' == '1' and '$(TestCount)' <= 9000" Text="Unexpected test count. Expected > 9000, found $(TestCount).'" />
<Error Condition="'$(CLRTestPriorityToBuild)' != '0' and '$(CLRTestPriorityToBuild)' != '1'" Text="Unknown priority $(CLRTestPriorityToBuild)" />
</ItemGroup>
</Target>
<Import Project="$(__Exclude)" Condition="'$(__Exclude)' != '' AND '$(XunitTestBinBase)' != ''" />
<PropertyGroup>
<HaveExcludes>False</HaveExcludes>
<HaveExcludes Condition="'$(__Exclude)' != ''">True</HaveExcludes>
</PropertyGroup>
<Target Name="CreateXunitWrapper" DependsOnTargets="CreateXunitFacts">
<PropertyGroup>
<_XunitWrapperGen >
<![CDATA[
$(_XunitProlog)
@(AllXUnitFacts)
$(_XunitEpilog)
]]>
</_XunitWrapperGen>
<XunitWrapperGenCsProj>
<![CDATA[
<Project>
<Import Project="$(TestProjectDir)Common/dir.sdkbuild.props" />
<PropertyGroup>
<OutputPath>$(XUnitTestBinBase)\$(CategoryWithSlash)</OutputPath>
<RuntimeFrameworkVersion Condition="'$(__SkipFXRestore)' != 'true'">$(MicrosoftNETCoreAppVersion)</RuntimeFrameworkVersion>
<RunAnalyzers>false</RunAnalyzers>
</PropertyGroup>
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />
<ItemGroup>
<Compile Include="$(XunitWrapper).cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(TestProjectDir)Common\Coreclr.TestWrapper\Coreclr.TestWrapper.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="xunit" Version="$(XUnitVersion)" />
<PackageReference Include="$(MicrosoftDotNetXUnitConsoleRunnerPackage)" Version="$(MicrosoftDotNetXUnitConsoleRunnerVersion)" />
</ItemGroup>
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />
</Project>
]]>
</XunitWrapperGenCsProj>
</PropertyGroup>
<!-- <Exec Command="md" -->
<MakeDir Directories="$(XunitWrapperGeneratedCSDirBase)$(Category)"/>
<!-- Write the file -->
<WriteLinesToFile
File="$(XunitWrapperSrcDir)\$(XunitWrapper).cs"
Lines="$(_XunitWrapperGen)"
Overwrite="true" />
<!-- Write the file -->
<WriteLinesToFile
File="$(XunitWrapperSrcDir)\$(XunitWrapper).csproj"
Lines="$(XunitWrapperGenCsProj)"
Overwrite="true" />
</Target>
<Target Name="BuildXunitWrapper">
<MSBuild Projects="$(XunitWrapperSrcDir)\$(XunitWrapper).csproj" Targets="Restore;Build" />
</Target>
<Import Project="$(MSBuildThisFileDirectory)Common/testgrouping.proj" />
<Target Name="CreateXunitFacts">
<!-- NOTE! semicolons must be escaped with %3B boooo -->
<PropertyGroup>
<_CMDDIR_Parent>$([System.IO.Path]::GetDirectoryName($(_CMDDIR)))</_CMDDIR_Parent>
<_CMDDIR_Grandparent>$([System.IO.Path]::GetDirectoryName($(_CMDDIR_Parent)))</_CMDDIR_Grandparent>
<CategoryWithSlash Condition="'$(RunningOnUnix)' != 'true'" >$([System.String]::Copy('$(_CMDDIR)').Replace("$(_CMDDIR_Grandparent)\",""))</CategoryWithSlash>
<CategoryWithSlash Condition="'$(RunningOnUnix)' == 'true'" >$([System.String]::Copy('$(_CMDDIR)').Replace("$(_CMDDIR_Grandparent)/",""))</CategoryWithSlash>
<Category Condition="'$(RunningOnUnix)' != 'true'" >$([System.String]::Copy('$(CategoryWithSlash)').Replace('\','.'))</Category>
<Category Condition="'$(RunningOnUnix)' == 'true'" >$([System.String]::Copy('$(CategoryWithSlash)').Replace('/','.'))</Category>
<XunitWrapper>$(Category).XUnitWrapper</XunitWrapper>
<XunitWrapperSrcDir>$(XunitWrapperGeneratedCSDirBase)$(Category)</XunitWrapperSrcDir>
</PropertyGroup>
<PropertyGroup>
<_XunitProlog Condition=" '$(_XunitProlog)'=='' ">
<![CDATA[
using Xunit%3B
using Xunit.Abstractions%3B
using System%3B
using System.Collections.Generic%3B
using System.Diagnostics%3B
using System.Reflection%3B
using System.Text.RegularExpressions%3B
using CoreclrTestLib%3B
using System.IO%3B
namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\","").Replace("-","_"))
{
internal class _Global
{
internal static bool runningInWindows%3B
internal static string reportBase%3B
internal static string testBinaryBase%3B
internal static string coreRoot%3B
internal static string category%3B
static _Global()
{
reportBase = System.Environment.GetEnvironmentVariable(%22XunitTestReportDirBase%22)%3B
testBinaryBase = System.IO.Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath)%3B
coreRoot = System.Environment.GetEnvironmentVariable(%22CORE_ROOT%22)%3B
category = "$([System.String]::Copy($(Category)).Replace(".","_").Replace("\","").Replace("-","_"))"%3B
if (String.IsNullOrEmpty(reportBase)) {
reportBase = System.IO.Path.Combine(testBinaryBase, "Reports")%3B
}
else
{
reportBase = System.IO.Path.GetFullPath(reportBase)%3B
}
if (String.IsNullOrEmpty(coreRoot)) {
throw new ArgumentException("Environment variable CORE_ROOT is not set")%3B
}
coreRoot = System.IO.Path.GetFullPath(coreRoot)%3B
string operatingSystem = System.Environment.GetEnvironmentVariable("OS")%3B
runningInWindows = (operatingSystem != null && operatingSystem.StartsWith("Windows"))%3B
}
}
]]>
</_XunitProlog>
<_XunitEpilog Condition=" '$(_XunitEpilog)'=='' ">
<![CDATA[
}
]]>
</_XunitEpilog>
</PropertyGroup>
<PropertyGroup>
<TestExecutableReplacement Condition="'$(TestWrapperTargetsWindows)' != 'true' ">testExecutable = testExecutable.Replace("\\", "/")%3B</TestExecutableReplacement>
</PropertyGroup>
<ItemGroup>
<AllCMDsPresent Include="$(_CMDDIR)\**\*.$(TestScriptExtension)" />
<AllCMDsPresent Remove="$(_CMDDIR)\**\run-v8.sh" Condition="'$(TargetArchitecture)' == 'wasm'" />
<TestGroupingDistinctWithCase Include="@(TestGrouping->Metadata('FullPath')->DistinctWithCase())" />
<TestGroupingNotRelevant Include="@(TestGroupingDistinctWithCase)" Exclude="@(AllCMDsPresent)" />
<GroupedCMDs Include="@(TestGroupingDistinctWithCase)" Exclude="@(TestGroupingNotRelevant)" />
<GroupedCMDs Include="@(AllCMDsPresent)" Exclude="@(GroupedCMDs)">
<TestGroup>$(Category)</TestGroup>
</GroupedCMDs>
<AllCMDExcludeFilter Include="@(ExcludeList->Metadata('FullPath'))" Condition="$(HaveExcludes)" />
<AllCMDs Include="@(GroupedCMDs)" Exclude="@(AllCMDExcludeFilter)">
<RelativeToCMDDIR>$([MSBuild]::MakeRelative($(_CMDDIR), %(FullPath)))</RelativeToCMDDIR>
</AllCMDs>
<AllCommands Include="@(AllCMDs)" Condition="@(AllCMDs->Count()) > 0">
<DisplayName>$([MSBuild]::MakeRelative($(XunitTestBinBase), %(AllCMDs.FullPath)))</DisplayName>
<FactName Condition="'$(RunningOnUnix)' != 'true'" >_$([MSBuild]::ValueOrDefault(%(AllCMDs.RelativeToCMDDIR),"").Replace(".","_").Replace("\","_").Replace("-","_"))</FactName>
<ClassName Condition="'$(RunningOnUnix)' != 'true'" >_$([MSBuild]::ValueOrDefault(%(AllCMDs.RelativeToCMDDIR),"").Replace($(TestScriptExtension),"").Replace(".","_").Replace("\","_").Replace("-","_"))</ClassName>
<FactName Condition="'$(RunningOnUnix)' == 'true'" >_$([MSBuild]::ValueOrDefault(%(AllCMDs.RelativeToCMDDIR),"").Replace(".","_").Replace("/","_").Replace("-","_"))</FactName>
<ClassName Condition="'$(RunningOnUnix)' == 'true'" >_$([MSBuild]::ValueOrDefault(%(AllCMDs.RelativeToCMDDIR), '').Replace($(TestScriptExtension),'').Replace('.','_').Replace('/','_').Replace('-','_'))</ClassName>
<TestGroup>%(AllCMDs.TestGroup)</TestGroup>
<XUnitFact >
<![CDATA[
public class %(AllCommands.ClassName)
{
private readonly ITestOutputHelper output%3B
public %(AllCommands.ClassName)(ITestOutputHelper output)
{
this.output = output%3B
}
[Fact(DisplayName=@"%(AllCommands.DisplayName)")]
[Trait("TestGroup", "%(AllCommands.TestGroup)")]
public void %(AllCommands.FactName)()
{
int ret = -100%3B
string outputFile = null%3B
string errorFile = null%3B
string testExecutable = null%3B
Exception infraEx = null%3B
try
{
CoreclrTestWrapperLib wrapper = new CoreclrTestWrapperLib()%3B
string testSubfolder = @"\$(Category)\$([System.String]::Copy('%(AllCMDs.RelativeDir)').Replace("$(_CMDDIR)$([System.IO.Path]::DirectorySeparatorChar)",''))"%3B
outputFile = System.IO.Path.GetFullPath(_Global.reportBase + testSubfolder + @"%(AllCMDs.FileName).output.txt")%3B
errorFile = System.IO.Path.GetFullPath(_Global.reportBase + testSubfolder + @"%(AllCMDs.FileName).error.txt")%3B
testExecutable = System.IO.Path.GetFullPath(_Global.testBinaryBase + @"$([System.String]::Copy('%(AllCMDs.FullPath)').Replace("$(_CMDDIR)",''))")%3B
$(TestExecutableReplacement)
if (!_Global.runningInWindows) {
testExecutable = testExecutable.Replace(".cmd", ".sh")%3B
}
System.IO.Directory.CreateDirectory(_Global.reportBase + testSubfolder)%3B
ret = wrapper.RunTest(testExecutable, outputFile, errorFile, _Global.category, _Global.testBinaryBase)%3B
}
catch (Exception ex)
{
infraEx = ex%3B
}
if (infraEx != null)
{
Assert.True(false, "Test Infrastructure Failure: " + infraEx.ToString())%3B
}
else
{
List<string> testOutput = new List<string>()%3B
try
{
testOutput.AddRange(System.IO.File.ReadAllLines(errorFile))%3B
}
catch (Exception ex)
{
testOutput.Add("Unable to read error file: " + errorFile)%3B
testOutput.Add(ex.ToString())%3B
}
testOutput.Add(string.Empty)%3B
testOutput.Add("Return code: " + ret)%3B
testOutput.Add("Raw output file: " + outputFile)%3B
testOutput.Add("Raw output:")%3B
try
{
testOutput.AddRange(System.IO.File.ReadAllLines(outputFile))%3B
}
catch(Exception ex)
{
testOutput.Add("Unable to read output file: " + outputFile)%3B
testOutput.Add(ex.ToString())%3B
}
testOutput.Add("To run the test:")%3B
testOutput.Add("> set CORE_ROOT=" + _Global.coreRoot)%3B
testOutput.Add("> " + testExecutable)%3B
var unicodeControlCharsRegex = new Regex("%5C%5Cp{C}+")%3B
// Remove all characters that have no visual or spatial representation.
for (int i = 0%3B i < testOutput.Count%3B i++)
{
string line = testOutput[i]%3B
line = unicodeControlCharsRegex.Replace(line, string.Empty)%3B
testOutput[i] = line%3B
}
foreach (string line in testOutput)
{
output.WriteLine(line)%3B
}
// Add Android app running log to testOutput
if (ret != CoreclrTestWrapperLib.EXIT_SUCCESS_CODE)
{
string androidLogFile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(testExecutable), "adb-logcat-net.dot." + _Global.category + ".log")%3B
if(File.Exists(androidLogFile))
{
testOutput.AddRange(System.IO.File.ReadAllLines(androidLogFile))%3B
}
}
Assert.True(ret == CoreclrTestWrapperLib.EXIT_SUCCESS_CODE, string.Join(Environment.NewLine, testOutput))%3B
}
}
}
]]>
</XUnitFact>
</AllCommands>
<AllXUnitFacts Include= "@(AllCommands->Metadata(XUnitFact))" />
</ItemGroup>
</Target>
<Target Name="MonoAotCompileTests" DependsOnTargets="GetListOfTestCmds;FindCmdDirectories">
<ItemGroup>
<AllTestScripts Include="%(TestDirectories.Identity)\**\*.sh" />
<TestExclusions Include="@(ExcludeList->Metadata('FullPath'))" Condition="$(HaveExcludes)" />
<TestScripts Include="@(AllTestScripts)" Exclude="@(TestExclusions)" />
<TestDllPaths Include="$([System.IO.Path]::ChangeExtension('%(TestScripts.Identity)', 'dll'))" />
<TestDlls Include="%(TestDllPaths.Identity)" Condition="Exists(%(TestDllPaths.Identity))" />
</ItemGroup>
<PropertyGroup Condition="'$(CROSSCOMPILE)' == ''">
<AotCompiler Condition="'$(RunningOnUnix)' == 'true'">$(CORE_ROOT)/corerun</AotCompiler>
<AotCompiler Condition="'$(RunningOnUnix)' != 'true'">$(CORE_ROOT)\corerun.exe</AotCompiler>
<MonoLlvmPath>$(MonoBinDir)</MonoLlvmPath>
</PropertyGroup>
<PropertyGroup Condition="'$(CROSSCOMPILE)' != ''">
<AotCompiler>$(MonoBinDir)/cross/mono-aot-cross</AotCompiler>
<MonoLlvmPath>$(MonoBinDir)/cross</MonoLlvmPath>
</PropertyGroup>
<ItemGroup>
<MonoAotOption Include="llvm" />
<MonoAotOption Include="llvm-path=$(MonoLlvmPath)" />
<MonoAotOption Condition="'$(__MonoToolPrefix)' != ''" Include="tool-prefix=$(__MonoToolPrefix)" />
</ItemGroup>
<PropertyGroup>
<MonoAotOptions>@(MonoAotOption->'%(Identity)', ',')</MonoAotOptions>
<MonoPath Condition="'$(CROSSCOMPILE)' != ''">$(CORE_ROOT)</MonoPath>
</PropertyGroup>
<ItemGroup>
<AotProject Include="../mono/msbuild/aot-compile.proj">
<Properties>_AotCompiler=$(AotCompiler);_TestDll=%(TestDlls.Identity);_MonoPath=$(MonoPath);_MonoAotOptions=$(MonoAotOptions)</Properties>
</AotProject>
</ItemGroup>
<MSBuild
Projects="@(AotProject)"
Targets="AotCompile"
Condition="@(TestDlls->Count()) > 0"
BuildInParallel="true"
/>
</Target>
<Target Name="CreateAllWrappers" DependsOnTargets="GetListOfTestCmds;FindCmdDirectories">
<MSBuild Projects="$(MSBuildProjectFile)" Targets="CreateXunitWrapper;BuildXunitWrapper" Properties="_CMDDIR=%(TestDirectories.Identity)" />
</Target>
<UsingTask TaskName="AndroidAppBuilderTask" AssemblyFile="$(AndroidAppBuilderTasksAssemblyPath)" Condition="'$(RunWithAndroid)'=='true'"/>
<Target Name="BuildAndroidApp">
<PropertyGroup>
<RuntimeIdentifier>android-$(TargetArchitecture)</RuntimeIdentifier>
<CMDDIR_Grandparent>$([System.IO.Path]::GetDirectoryName($([System.IO.Path]::GetDirectoryName($(_CMDDIR)))))</CMDDIR_Grandparent>
<CategoryWithSlash>$([System.String]::Copy('$(_CMDDIR)').Replace("$(CMDDIR_Grandparent)/",""))</CategoryWithSlash>
<Category>$([System.String]::Copy('$(CategoryWithSlash)').Replace('/','_'))</Category>
<BuildDir>$(IntermediateOutputPath)\AndroidApps\$(Category)</BuildDir>
<AppDir>$(BuildDir)\apk</AppDir>
<FinalApkPath>$(XUnitTestBinBase)$(CategoryWithSlash)\$(Category).apk</FinalApkPath>
<StripDebugSymbols>False</StripDebugSymbols>
<StripDebugSymbols Condition="'$(Configuration)' == 'Release'">True</StripDebugSymbols>
<MicrosoftNetCoreAppRuntimePackDir>$(ArtifactsBinDir)microsoft.netcore.app.runtime.android-$(TargetArchitecture)\$(Configuration)\runtimes\android-$(TargetArchitecture)\</MicrosoftNetCoreAppRuntimePackDir>
<AndroidAbi Condition="'$(TargetArchitecture)' == 'arm64'">arm64-v8a</AndroidAbi>
<AndroidAbi Condition="'$(TargetArchitecture)' == 'arm'">armeabi-v7a</AndroidAbi>
<AndroidAbi Condition="'$(TargetArchitecture)' == 'x64'">x86_64</AndroidAbi>
<AndroidAbi Condition="'$(TargetArchitecture)' == 'x86'">x86</AndroidAbi>
</PropertyGroup>
<RemoveDir Directories="$(AppDir)" />
<MakeDir Directories="$(BuildDir)"/>
<ItemGroup>
<AllCMDsPresent Include="$(_CMDDIR)\**\*.$(TestScriptExtension)"/>
<TestAssemblies Include="@(AllCMDsPresent->'%(RelativeDir)%(Filename).dll')" />
<TestAssemblyDirs Include="@(AllCMDsPresent->'%(RelativeDir)')" />
<AssembliesInTestDirs Include="%(AllCMDsPresent.RelativeDir)*.dll" Exclude="@(TestAssemblies)"/>
<RuntimePackLibs Include="$(MicrosoftNetCoreAppRuntimePackDir)lib/**/*.dll" />
<RuntimePackNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackDir)native/**/*.dll;$(MicrosoftNetCoreAppRuntimePackDir)native/**/*.a;$(MicrosoftNetCoreAppRuntimePackDir)native/**/*.so" />
</ItemGroup>
<Copy
SourceFiles="@(TestAssemblies)"
DestinationFolder="$(BuildDir)" />
<Copy
SourceFiles="@(AssembliesInTestDirs)"
DestinationFolder="$(BuildDir)" />
<Copy
SourceFiles="@(RuntimePackNativeLibs)"
DestinationFolder="$(BuildDir)" />
<Copy
SourceFiles="@(RuntimePackLibs)"
DestinationFolder="$(BuildDir)" />
<!-- TEMP: consume OpenSSL binaries from external sources via env. variables.-->
<Copy Condition="'$(ANDROID_OPENSSL_AAR)' != ''"
SourceFiles="$(ANDROID_OPENSSL_AAR)\prefab\modules\crypto\libs\android.$(AndroidAbi)\libcrypto.so"
DestinationFolder="$(BuildDir)" SkipUnchangedFiles="true"/>
<Copy Condition="'$(ANDROID_OPENSSL_AAR)' != ''"
SourceFiles="$(ANDROID_OPENSSL_AAR)\prefab\modules\ssl\libs\android.$(AndroidAbi)\libssl.so"
DestinationFolder="$(BuildDir)" SkipUnchangedFiles="true"/>
<AndroidAppBuilderTask
RuntimeIdentifier="$(RuntimeIdentifier)"
ProjectName="$(Category)"
MonoRuntimeHeaders="$(MicrosoftNetCoreAppRuntimePackDir)/native/include/mono-2.0"
StripDebugSymbols="$(StripDebugSymbols)"
SourceDir="$(BuildDir)"
OutputDir="$(AppDir)">
<Output TaskParameter="ApkBundlePath" PropertyName="ApkBundlePath" />
<Output TaskParameter="ApkPackageId" PropertyName="ApkPackageId" />
</AndroidAppBuilderTask>
<Move SourceFiles="$(ApkBundlePath)" DestinationFiles="$(FinalApkPath)" />
<Message Importance="High" Text="Apk: $(FinalApkPath)"/>
<Message Importance="High" Text="PackageId: $(ApkPackageId)"/>
<!-- delete the BuildDir in CI builds to save disk space on build agents since they're no longer needed -->
<RemoveDir Condition="'$(ContinuousIntegrationBuild)' == 'true'" Directories="$(BuildDir)" />
</Target>
<Target Name="BuildAllAndroidApp" DependsOnTargets="GetListOfTestCmds;FindCmdDirectories">
<MSBuild Projects="$(MSBuildProjectFile)" Targets="BuildAndroidApp" Properties="_CMDDIR=%(TestDirectories.Identity)" />
</Target>
<Target Name="GetListOfTestCmds">
<ItemGroup>
<AllRunnableTestPaths Include="$(XunitTestBinBase)\**\*.$(TestScriptExtension)"/>
<AllRunnableTestPaths Remove="$(XunitTestBinBase)\**\run-v8.sh" Condition="'$(TargetArchitecture)' == 'wasm'" />
</ItemGroup>
</Target>
<Import Project="$(RepoRoot)/src/tests/Common/tests.targets" />
<Import Project="$(RepoRoot)/src/tests/Common/publishdependency.targets" />
<Target Name="CreateTestOverlay">
<MSBuild Projects="$(MSBuildProjectFile)"
Targets="CopyDependencyToCoreRoot"
Properties="Language=C#;PackageRID=$(PackageRID);RuntimeIdentifier=$(PackageRID)" />
</Target>
<Target Name="Build">
<!-- generate project.lock.json file corresponding to above json file -->
<MSBuild Projects="$(RepoRoot)/src/tests/Common/test_dependencies/test_dependencies.csproj"
Condition=" '$(BuildWrappers)'=='true' " />
<MSBuild Projects="$(MSBuildProjectFile)"
Targets="BuildAllAndroidApp"
Condition=" '$(RunWithAndroid)'=='true' " />
<!-- Default for building -->
<MSBuild Projects="$(MSBuildProjectFile)"
Targets="CreateAllWrappers"
Properties="_CMDDIR=%(TestDirectories.Identity)"
Condition=" '$(BuildWrappers)'=='true' " />
<!-- Execution -->
<MSBuild Projects="$(MSBuildProjectFile)"
Targets="CreateTestOverlay"
Condition=" '$(GenerateRuntimeLayout)'=='true' "/>
<MSBuild Projects="$(MSBuildProjectFile)" Targets="RunTests"
Condition=" '$(RunTests)'=='true' "/>
</Target>
<Target Name="Clean">
<RemoveDir Condition=" '$(BuildWrappers)'=='true'" Directories="$(MSBuildThisFileDirectory)../$(XunitWrapperGeneratedCSDirBase);" ContinueOnError="WarnAndContinue" />
</Target>
</Project>
|