Welcome to mirror list, hosted at ThFree Co, Russian Federation.

build.proj « tests « src - github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c292d42fe4cf12f865129d121bda56304c8bd76d (plain)
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
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
<Project DefaultTargets="Build">
  <Import Project="Common\dirs.proj" />
  <Import Project="Directory.Build.targets" />
  <Import Project="xunit-wrappers.targets" />

  <PropertyGroup>
    <XunitTestBinBase Condition="'$(XunitTestBinBase)'==''" >$(BaseOutputPathWithConfig)</XunitTestBinBase>
    <XunitWrapperGeneratedCSDirBase>$(XunitTestBinBase)\TestWrappers\</XunitWrapperGeneratedCSDirBase>
    <MSBuildEnableAllPropertyFunctions>1</MSBuildEnableAllPropertyFunctions>
    <Language>C#</Language>
    <RuntimeIdentifier>$(OutputRid)</RuntimeIdentifier>
  </PropertyGroup>

  <ItemGroup>
    <DisabledTestDir Include="bin" />
    <DisabledTestDir Include="Common" />
    <DisabledTestDir Include="Tests" />
    <DisabledTestDir Include="TestWrappers" />
    <_SkipTestDir Include="@(DisabledTestDir)" />
  </ItemGroup>

  <ItemGroup>
    <RestoreProjects Include="Common\test_dependencies_fs\test_dependencies.fsproj" />
    <RestoreProjects Include="Common\test_dependencies\test_dependencies.csproj" />
    <RestoreProjects Include="Common\CoreCLRTestLibrary\CoreCLRTestLibrary.csproj" />
    <RestoreProjects Include="Common\XUnitWrapperGenerator\XUnitWrapperGenerator.csproj" />
    <RestoreProjects Include="Common\XUnitWrapperLibrary\XUnitWrapperLibrary.csproj" />
    <RestoreProjects Include="Common\XHarnessRunnerLibrary\XHarnessRunnerLibrary.csproj" />
    <RestoreProjects Include="Common\external\external.csproj" />
    <RestoreProjects Include="Common\ilasm\ilasm.ilproj" />
  </ItemGroup>

  <ItemGroup>
    <TestBuildSteps Include="RestorePackages" />
    <TestBuildSteps Include="ManagedBuild" />
    <TestBuildSteps Include="CheckTestBuildStep" />
    <TestBuildSteps Include="GenerateLayout" />
    <TestBuildSteps Include="BuildTestWrappers" />
    <TestBuildSteps Include="CrossgenFramework" />
    <TestBuildSteps Include="CreateAndroidApps" />
    <TestBuildSteps Include="CreateIosApps" />
    <TestBuildSteps Include="BuildMonoAot" />
  </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)" />
    </ItemGroup>

    <ItemGroup Condition="'@(LegacyRunnableTestPaths)' != ''">
      <TopLevelDirectories Include="@(NonExcludedTestDirectories)" />
      <SecondLevel Include="$([System.IO.Directory]::GetDirectories(%(TopLevelDirectories.Identity)))" />
      <SecondLevelDirectories Include="@(SecondLevel)">
        <Path>$([System.IO.Path]::GetFullPath(%(LegacyRunnableTestPaths.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>@(LegacyRunnableTestPaths->Count())</TestCount>
    </PropertyGroup>

    <Message Text="Found $(TestCount) built tests"/>

    <ItemGroup>
      <Error Condition="'$(CLRTestPriorityToBuild)' == '0' and '$(TestCount)' &lt;= 2000" Text="Unexpected test count. Expected &gt; 2000, found $(TestCount).'" />
      <Error Condition="'$(CLRTestPriorityToBuild)' == '0' and '$(TestCount)' &gt;= 3000" Text="Unexpected test count. Expected &lt; 3000, found $(TestCount).'" />
      <Error Condition="'$(CLRTestPriorityToBuild)' == '1' and '$(TestCount)' &lt;= 9000" Text="Unexpected test count. Expected &gt; 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="MonoAotCompileTests" DependsOnTargets="GetListOfTestCmds;FindCmdDirectories">
    <ItemGroup>
      <AllTestScripts Condition="'@(TestDirectories)' != ''" Include="%(TestDirectories.Identity)\**\*.sh" />
      <AllTestScripts Condition="'@(MergedRunnableTestPaths)' != ''" Include="%(MergedRunnableTestPaths.RootDir)%(MergedRunnableTestPaths.Directory)*.dll" />
      <AllTestScripts Condition="'@(OutOfProcessTestPaths)' != ''" Include="%(OutOfProcessTestPaths.RootDir)%(OutOfProcessTestPaths.Directory)*.sh" />
      <TestExclusions Include="@(ExcludeList->Metadata('FullPath'))" Condition="$(HaveExcludes)" />
      <TestScripts Include="@(AllTestScripts)" Exclude="@(TestExclusions)" />

      <TestAssemblyPaths Include="$([System.IO.Path]::ChangeExtension('%(TestScripts.Identity)', 'dll'))" />
      <TestAssemblies Include="%(TestAssemblyPaths.Identity)" Condition="Exists(%(TestAssemblyPaths.Identity))" />
      <TestDirsWithDuplicates Include="$([System.IO.Path]::GetDirectoryName('%(TestAssemblies.Identity)'))" />
    </ItemGroup>
    <RemoveDuplicates Inputs="@(TestDirsWithDuplicates)">
      <Output TaskParameter="Filtered" ItemName="TestDirs" />
    </RemoveDuplicates>
    <ItemGroup>
      <TestsAndAssociatedAssemblies Include="%(TestDirs.Identity)/*.dll" Exclude="@(NoMonoAotAssemblyPaths)" />
      <CoreRootDlls Include="$(CORE_ROOT)/*.dll" Exclude="$(CORE_ROOT)/xunit.performance.api.dll" />
      <AllDlls Condition="'$(MonoFullAot)' == 'true'" Include="@(TestsAndAssociatedAssemblies);@(CoreRootDlls)" />
      <AllDlls Condition="'$(MonoFullAot)' != 'true'" Include="@(TestsAndAssociatedAssemblies)" />
    </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/$(OutputRid)/mono-aot-cross</AotCompiler>
      <MonoLlvmPath>$(MonoBinDir)/cross/$(OutputRid)</MonoLlvmPath>
    </PropertyGroup>

    <ItemGroup>
      <MonoAotOption Condition="'$(MonoFullAot)' == 'true'" Include="full" />
      <MonoAotOption Condition="'$(MonoFullAot)' == 'true'" Include="nimt-trampolines=2000" />
      <MonoAotOption Condition="'$(MonoFullAot)' == 'true'" Include="ntrampolines=10000" />
      <MonoAotOption Condition="'$(MonoFullAot)' == 'true'" Include="nrgctx-fetch-trampolines=256" />
      <MonoAotOption Condition="'$(MonoFullAot)' == 'true'" Include="ngsharedvt-trampolines=4400" />
      <MonoAotOption Condition="'$(MonoFullAot)' == 'true'" Include="nftnptr-arg-trampolines=4000" />
      <MonoAotOption Condition="'$(MonoFullAot)' == 'true'" Include="nrgctx-trampolines=21000" />
      <MonoAotOption Include="llvm" />
      <MonoAotOption Include="llvm-path=$(MonoLlvmPath)" />
      <MonoAotOption Condition="'$(__MonoToolPrefix)' != ''" Include="tool-prefix=$(__MonoToolPrefix)" />
    </ItemGroup>
    <ItemGroup Condition="'$(TargetArchitecture)' == 'arm64'">
      <MonoAotOption Include="mattr=crc" />
      <MonoAotOption Include="mattr=crypto" />
    </ItemGroup>
    <ItemGroup Condition="'$(TargetArchitecture)' == 'x64'">
      <MonoAotOption Include="mattr=sse4.2" />
      <MonoAotOption Include="mattr=popcnt" />
      <MonoAotOption Include="mattr=lzcnt" />
      <MonoAotOption Include="mattr=bmi" />
      <MonoAotOption Include="mattr=bmi2" />
      <MonoAotOption Include="mattr=pclmul" />
      <MonoAotOption Include="mattr=aes" />
    </ItemGroup>
    <PropertyGroup>
      <MonoAotOptions>@(MonoAotOption->'%(Identity)', ',')</MonoAotOptions>
      <MonoPath>$(CORE_ROOT)</MonoPath>
    </PropertyGroup>

    <Message Importance="High" Text="Mono AOT options: $(MonoAotOptions)" />
    <Message Importance="High" Text="Mono AOT MONO_PATH: $(MonoPath)" />

    <ItemGroup>
      <AotProject Include="../mono/msbuild/aot-compile.proj">
        <Properties>_AotCompiler=$(AotCompiler);_TestDll=%(AllDlls.Identity);_MonoPath=$(MonoPath);_MonoAotOptions=$(MonoAotOptions)</Properties>
      </AotProject>
    </ItemGroup>
    <MSBuild
      Projects="@(AotProject)"
      Targets="AotCompile"
      Condition="@(AllDlls->Count()) &gt; 0"
      BuildInParallel="true"
      />
  </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>
      <RuntimeComponents>diagnostics_tracing</RuntimeComponents>
      <DiagnosticPorts>127.0.0.1:9000,nosuspend,listen</DiagnosticPorts>
      <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>
      <MonoInterp>false</MonoInterp>
      <MonoInterp Condition="'$(RuntimeVariant)' == 'monointerpreter'">true</MonoInterp>
    </PropertyGroup>

    <RemoveDir Directories="$(AppDir)" />
    <MakeDir Directories="$(BuildDir)"/>

    <ItemGroup>
      <AllCMDsPresent Include="$(_CMDDIR)\**\*.$(TestScriptExtension)" Exclude="$(_CMDDIR)\**\AppBundle\*.$(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" />
      <TestTargetingPathLibs Include="$(TargetingPackPath)/*.dll" />
    </ItemGroup>

    <Copy
        SourceFiles="@(TestAssemblies)"
        DestinationFolder="$(BuildDir)" />

    <Copy
        SourceFiles="@(AssembliesInTestDirs)"
        DestinationFolder="$(BuildDir)" />

    <Copy
        SourceFiles="@(RuntimePackNativeLibs)"
        DestinationFolder="$(BuildDir)" />

    <Copy
        SourceFiles="@(RuntimePackLibs)"
        DestinationFolder="$(BuildDir)" />

    <Copy
        SourceFiles="@(TestTargetingPathLibs)"
        DestinationFolder="$(BuildDir)" />

    <AndroidAppBuilderTask
        RuntimeIdentifier="$(RuntimeIdentifier)"
        ProjectName="$(Category)"
        MonoRuntimeHeaders="$(MicrosoftNetCoreAppRuntimePackDir)/native/include/mono-2.0"
        RuntimeComponents="$(RuntimeComponents)"
        DiagnosticPorts="$(DiagnosticPorts)"
        StripDebugSymbols="$(StripDebugSymbols)"
        ForceInterpreter="$(MonoInterp)"
        AppDir="$(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)"/>
    <Message Importance="High" Text="MonoInterp: $(MonoInterp)"/>
    <!-- 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)"
      Condition="'@(TestDirectories)' != ''" />
  </Target>

  <UsingTask TaskName="AppleAppBuilderTask" AssemblyFile="$(AppleAppBuilderTasksAssemblyPath)" />
  <UsingTask TaskName="MonoAOTCompiler" AssemblyFile="$(MonoAOTCompilerTasksAssemblyPath)" />

  <Target Name="BuildiOSApp">
    <PropertyGroup>
      <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>
      <XUnitWrapperFileName>$([System.String]::Copy('$(CategoryWithSlash)').Replace('/', '.')).XUnitWrapper.dll</XUnitWrapperFileName>
      <XUnitWrapperDll>$(CMDDIR_GrandParent)/$(CategoryWithSlash)/$(XUnitWrapperFileName)</XUnitWrapperDll>
      <BuildDir>$(IntermediateOutputPath)\iOSApps\$(Category)</BuildDir>
      <FinalPath>$(XUnitTestBinBase)$(CategoryWithSlash)\$(Category).app</FinalPath>
      <RuntimeComponents>diagnostics_tracing</RuntimeComponents>
    </PropertyGroup>

    <PropertyGroup>
      <AssemblyName>$(Category)</AssemblyName>
      <MicrosoftNetCoreAppRuntimePackDir>$(ArtifactsBinDir)microsoft.netcore.app.runtime.iossimulator-$(TargetArchitecture)/$(Configuration)/runtimes/iossimulator-$(TargetArchitecture)</MicrosoftNetCoreAppRuntimePackDir>
      <MicrosoftNetCoreAppRuntimePackNativeDir>$(MicrosoftNetCoreAppRuntimePackDir)/native</MicrosoftNetCoreAppRuntimePackNativeDir>
    </PropertyGroup>
    <ItemGroup>
      <AllTestScripts Include="$(_CMDDIR)\**\*.sh" Exclude="$(_CMDDIR)\**\AppBundle\*.sh" />
    </ItemGroup>
    <ItemGroup>
      <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))" />
      <AssembliesInTestDirs Include="%(AllCMDsPresent.RelativeDir)*.dll" Exclude="@(TestAssemblies)"/>
      <RuntimePackLibs Include="$(MicrosoftNetCoreAppRuntimePackDir)lib/**/*.dll" />
      <TestTargetingPathLibs Include="$(TargetingPackPath)/*.dll" />
    </ItemGroup>
    <ItemGroup>
      <ExtraDlls Include="%(TestDlls.RelativeDir)*.dll" Exclude="@(TestDlls)">
        <TestDllFilename>@(TestDlls->'%(Filename)')</TestDllFilename>
      </ExtraDlls>
    </ItemGroup>
    <PropertyGroup>
      <BundleDir>$([MSBuild]::NormalizeDirectory('$(BuildDir)', 'AppBundle'))</BundleDir>
    </PropertyGroup>
    <ItemGroup>
      <RuntimePackNativeLibs Include="$(MicrosoftNetCoreAppRuntimePackDir)/**/*.dll;$(MicrosoftNetCoreAppRuntimePackDir)/native/**/*.a;$(MicrosoftNetCoreAppRuntimePackDir)/native/**/*.dylib" />
    </ItemGroup>

    <RemoveDir Directories="$(BundleDir)" />
    <RemoveDir Directories="$(BuildDir)" />

    <MakeDir Directories="$(BuildDir)" />
    <MakeDir Directories="$(BuildDir)/testdir-%(TestDlls.Filename)" />

    <Copy
        SourceFiles="@(RuntimePackNativeLibs)"
        DestinationFolder="$(BuildDir)" />
    <Copy
        SourceFiles="@(RuntimePackLibs)"
        DestinationFolder="$(BuildDir)" />

    <Copy
        SourceFiles="@(TestTargetingPathLibs)"
        DestinationFolder="$(BuildDir)" />
    <Copy
        SourceFiles="%(TestDlls.Identity)"
        DestinationFolder="$(BuildDir)/testdir-%(TestDlls.Filename)" />
    <Copy
        SourceFiles="%(ExtraDlls.Identity)"
        DestinationFolder="$(BuildDir)/testdir-%(ExtraDlls.TestDllFilename)" />

    <AppleAppBuilderTask
        TargetOS="$(TargetOS)"
        Arch="$(TargetArchitecture)"
        ProjectName="$(AssemblyName)"
        MonoRuntimeHeaders="$(MicrosoftNetCoreAppRuntimePackNativeDir)/include/mono-2.0"
        RuntimeComponents="$(RuntimeComponents)"
        Assemblies="@(BundleAssemblies)"
        ForceInterpreter="$(MonoForceInterpreter)"
        EnableAppSandbox="$(EnableAppSandbox)"
        UseConsoleUITemplate="True"
        GenerateXcodeProject="True"
        BuildAppBundle="True"
        Optimized="True"
        DevTeamProvisioning="$(DevTeamProvisioning)"
        OutputDirectory="$(BundleDir)"
        AppDir="$(BuildDir)"
        InvariantGlobalization="true"
    >
      <Output TaskParameter="AppBundlePath" PropertyName="AppBundlePath" />
      <Output TaskParameter="XcodeProjectPath" PropertyName="XcodeProjectPath" />
    </AppleAppBuilderTask>

    <!-- Apparently MSBuild cannot move directories and recursively copying a
         a directory requires writing some sort of recursive traversal
         logic yourself. -->
    <ItemGroup>
      <RecursiveCopyHack Include="$(AppBundlePath)/**/*.*" />
    </ItemGroup>
    <MakeDir Directories="$(FinalPath)" />
    <Copy SourceFiles="@(RecursiveCopyHack)" DestinationFolder="$(FinalPath)/%(RecursiveDir)" />
    <RemoveDir Directories="$(AppBundlePath)" />
    <Message Importance="High" Text="App: $(FinalPath)" />
  </Target>

  <Target Name="BuildAlliOSApp" DependsOnTargets="GetListOfTestCmds;FindCmdDirectories">
    <ItemGroup>
      <RunProj Include="$(MSBuildProjectFile)">
        <Properties>_CMDDIR=%(TestDirectories.Identity)</Properties>
      </RunProj>
    </ItemGroup>
    <MSBuild
      Projects="@(RunProj)"
      Targets="BuildiOSApp"
      BuildInParallel="true"
      Condition="'@(TestDirectories)' != ''"
      />
  </Target>

  <Target Name="GetListOfTestCmds">
    <ItemGroup>
      <AllRunnableTestPaths Include="$(XunitTestBinBase)\**\*.$(TestScriptExtension)"/>
      <AllRunnableTestPaths Remove="$(XunitTestBinBase)\**\run-v8.sh" Condition="'$(TargetArchitecture)' == 'wasm'" />
      <MergedAssemblyMarkerPaths Include="$(XunitTestBinBase)\**\*.MergedTestAssembly"/>
      <MergedAssemblyFolders Include="$([System.IO.Path]::GetDirectoryName('%(MergedAssemblyMarkerPaths.Identity)'))" />
      <MergedAssemblyParentFolders Include="$([System.IO.Path]::GetDirectoryName('%(MergedAssemblyFolders.Identity)'))" />
      <AllRunnableTestPaths Remove="%(MergedAssemblyParentFolders.Identity)\**\*.$(TestScriptExtension)" />
      <MergedRunnableTestPaths Include="$([System.IO.Path]::ChangeExtension('%(MergedAssemblyMarkerPaths.Identity)', '.$(TestScriptExtension)'))" />
      <OutOfProcessTestMarkerPaths Include="$(XunitTestBinBase)\**\*.OutOfProcessTest"/>
      <OutOfProcessTestPaths Include="$([System.IO.Path]::ChangeExtension('%(OutOfProcessTestMarkerPaths.Identity)', '.$(TestScriptExtension)'))" />
      <NoMonoAotMarkerPaths Include="$(XunitTestBinBase)\**\*.NoMonoAot" />
      <NoMonoAotAssemblyPaths Include="$([System.IO.Path]::ChangeExtension('%(NoMonoAotMarkerPaths.Identity)', '.dll'))" />
    </ItemGroup>
    <!-- Remove the cmd/sh scripts for merged test runner app bundles from our list. -->
    <PropertyGroup Condition="'$(TargetsMobile)' == 'true'">
      <MergedRunnableTestAppBundleScriptPathsPattern>@(MergedAssemblyMarkerPaths->'%(RootDir)%(Directory)AppBundle/**/*.$(TestScriptExtension)')</MergedRunnableTestAppBundleScriptPathsPattern>
    </PropertyGroup>
    <ItemGroup>
      <LegacyRunnableTestPaths Include="@(AllRunnableTestPaths)" Exclude="@(MergedRunnableTestPaths);@(OutOfProcessTestPaths);$(MergedRunnableTestAppBundleScriptPathsPattern)" />
    </ItemGroup>
  </Target>

  <Import Project="$(RepoRoot)/src/tests/Common/tests.targets" />
  <Import Project="$(RepoRoot)/src/tests/Common/publishdependency.targets" />

  <Target Name="CreateTestOverlay" DependsOnTargets="CopyDependencyToCoreRoot" />

  <Target Name="Clean">
    <RemoveDir Condition=" '$(BuildWrappers)'=='true'" Directories="$(MSBuildThisFileDirectory)../$(XunitWrapperGeneratedCSDirBase);" ContinueOnError="WarnAndContinue" />
  </Target>

  <Target Name="TestBuild" DependsOnTargets="@(TestBuildSteps)" />

  <Target Name="BuildTargetingPack" AfterTargets="BatchRestorePackages">
    <Message Text="$(MsgPrefix)Building Targeting Pack" Importance="High" />
    <MSBuild Projects="Common\external\external.csproj"
             Targets="Build" />
  </Target>

  <Target Name="BatchRestorePackages">
    <Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Restoring all packages..." />

    <!-- restore all csproj's with PackageReferences in one pass -->
    <MSBuild Projects="build.proj"
             Properties="RestoreProj=%(RestoreProjects.Identity)"
             Targets="RestorePackage" />

    <Message Importance="High" Text="[$([System.DateTime]::Now.ToString('HH:mm:ss.ff'))] Restoring all packages...Done." />
  </Target>

  <Target Name="RestorePackage">
    <PropertyGroup>
      <_ConfigurationProperties>/p:TargetOS=$(TargetOS) /p:TargetArchitecture=$(TargetArchitecture) /p:Configuration=$(Configuration) /p:CrossBuild=$(CrossBuild)</_ConfigurationProperties>
      <DotnetRestoreCommand Condition="'$(__DistroRid)' == ''">"$(DotNetTool)" restore $(RestoreProj) $(PackageVersionArg) /p:SetTFMForRestore=true $(_ConfigurationProperties)</DotnetRestoreCommand>
      <DotnetRestoreCommand Condition="'$(__DistroRid)' != ''">"$(DotNetTool)" restore -r $(__DistroRid) $(RestoreProj) $(PackageVersionArg) /p:SetTFMForRestore=true $(_ConfigurationProperties)</DotnetRestoreCommand>
    </PropertyGroup>
    <Exec Command="$(DotnetRestoreCommand)"/>
  </Target>

  <!-- Override RestorePackages from dir.traversal.targets and do a batch restore -->
  <Target Name="RestorePackages"
      DependsOnTargets="BatchRestorePackages"
      Condition="'$(__SkipRestorePackages)' != '1'" />

  <Target Name="ManagedBuild"
      DependsOnTargets="BuildManagedTestGroups"
      Condition="'$(__BuildTestWrappersOnly)' != '1' and '$(__GenerateLayoutOnly)' != '1' and '$(__SkipManaged)' != '1' and !$(MonoAot) and !$(MonoFullAot)" />

  <Target Name="BuildManagedTestGroups" DependsOnTargets="RestorePackages;ResolveDisabledProjects;BuildNativeAotFrameworkObjects">
    <Message Importance="High" Text="$(MsgPrefix)Building managed test components" />
    <!-- Execute msbuild test build in stages - workaround for excessive data retention in MSBuild ConfigCache -->
    <!-- See https://github.com/Microsoft/msbuild/issues/2993 -->

    <!-- We need to build group #1 manually as it doesn't have a _GroupStartsWith item associated with it, see the comment in Common\dirs.proj -->
    <MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="BuildManagedTestGroup" Properties="__TestGroupToBuild=1;__SkipRestorePackages=1" />
    <MSBuild Projects="$(MSBuildThisFileFullPath)" Targets="BuildManagedTestGroup" Properties="__TestGroupToBuild=%(_GroupStartsWith.GroupNumber);__SkipRestorePackages=1" />
  </Target>

  <Target Name="BuildManagedTestGroup"
      DependsOnTargets="ResolveDisabledProjects"
      Condition="'$(__SkipManaged)' != '1'" >

    <PropertyGroup>
      <TargetToBuild>Build</TargetToBuild>
      <!-- In split pipeline mode (in the lab) we're using the native component copying step to generate the test execution scripts -->
      <TargetToBuild Condition="'$(__CopyNativeTestBinaries)' == '1'">CopyAllNativeTestProjectBinaries</TargetToBuild>

      <GroupBuildCmd>$(DotNetCli) msbuild</GroupBuildCmd>
      <GroupBuildCmd>$(GroupBuildCmd) $(MSBuildThisFileFullPath)</GroupBuildCmd>
      <GroupBuildCmd>$(GroupBuildCmd) /t:$(TargetToBuild)</GroupBuildCmd>
      <GroupBuildCmd>$(GroupBuildCmd) "/p:TargetArchitecture=$(TargetArchitecture)"</GroupBuildCmd>
      <GroupBuildCmd>$(GroupBuildCmd) "/p:Configuration=$(Configuration)"</GroupBuildCmd>
      <GroupBuildCmd>$(GroupBuildCmd) "/p:LibrariesConfiguration=$(LibrariesConfiguration)"</GroupBuildCmd>
      <GroupBuildCmd>$(GroupBuildCmd) "/p:TargetOS=$(TargetOS)"</GroupBuildCmd>
      <GroupBuildCmd>$(GroupBuildCmd) "/p:RuntimeOS=$(RuntimeOS)"</GroupBuildCmd>
      <GroupBuildCmd>$(GroupBuildCmd) "/p:RuntimeFlavor=$(RuntimeFlavor)"</GroupBuildCmd>
      <GroupBuildCmd>$(GroupBuildCmd) "/p:RuntimeVariant=$(RuntimeVariant)"</GroupBuildCmd>
      <GroupBuildCmd>$(GroupBuildCmd) "/p:CLRTestBuildAllTargets=$(CLRTestBuildAllTargets)"</GroupBuildCmd>
      <GroupBuildCmd>$(GroupBuildCmd) "/p:__TestGroupToBuild=$(__TestGroupToBuild)"</GroupBuildCmd>
      <GroupBuildCmd>$(GroupBuildCmd) "/p:__SkipRestorePackages=1"</GroupBuildCmd>
      <GroupBuildCmd>$(GroupBuildCmd) /nodeReuse:false</GroupBuildCmd>
      <GroupBuildCmd>$(GroupBuildCmd) /maxcpucount</GroupBuildCmd>
      <GroupBuildCmd>$(GroupBuildCmd) /bl:$(ArtifactsDir)/log/$(Configuration)/InnerManagedTestBuild.$(__TestGroupToBuild).binlog</GroupBuildCmd>
      <GroupBuildCmd Condition="'$(TestBuildMode)' == 'nativeaot'">$(GroupBuildCmd) "/p:DefaultBuildAllTarget=BuildNativeAot"</GroupBuildCmd>
      <GroupBuildCmd Condition="'$(IlcMultiModule)' == 'true'">$(GroupBuildCmd) "/p:IlcMultiModule=true"</GroupBuildCmd>
      <GroupBuildCmd Condition="'$(BuildNativeAotFrameworkObjects)' == 'true'">$(GroupBuildCmd) "/p:BuildNativeAotFrameworkObjects=true"</GroupBuildCmd>
    </PropertyGroup>

    <Message Importance="High" Text="$(MsgPrefix)Building managed test group $(__TestGroupToBuild): $(GroupBuildCmd)" />

    <Exec Command="$(GroupBuildCmd)" />
  </Target>

  <Target Name="CheckTestBuildStep"
      DependsOnTargets="CheckTestBuild"
      Condition="'$(__BuildTestWrappersOnly)' != '1' and '$(__GenerateLayoutOnly)' != '1' and '$(__CopyNativeTestBinaries)' != '1' and !$(MonoAot) and !$(MonoFullAot)" />

  <Target Name="GenerateLayout"
      DependsOnTargets="CreateTestOverlay"
      AfterTargets="ManagedBuild;RestorePackages"
      Condition="'$(__BuildTestWrappersOnly)' != '1' and '$(__CopyNativeTestBinaries)' != '1' and '$(__SkipGenerateLayout)' != '1' and !$(MonoAot) and !$(MonoFullAot)">

    <MSBuild
      Projects="$(MSBuildProjectFile)"
      Targets="EmitTestExclusionList"
      Properties="XunitTestBinBase=$(XunitTestBinBase)" />
  </Target>

  <Target Name="BuildTestWrappers"
      DependsOnTargets="CreateAllWrappers"
      AfterTargets="ManagedBuild;RestorePackages"
      Condition="'$(__GenerateLayoutOnly)' != '1' and '$(__CopyNativeTestBinaries)' != '1' and !$(MonoAot) and !$(MonoFullAot) and ('$(__BuildTestWrappersOnly)' == '1' or ('$(__SkipTestWrappers)' != '1' and '$(__SkipManaged)' != '1'))" />

  <Target Name="CrossgenFramework"
      DependsOnTargets="GenerateLayout"
      Condition="'$(__BuildTestWrappersOnly)' != '1' and '$(__CopyNativeTestBinaries)' != '1' and '$(__TestBuildMode)' == 'crossgen2' and !$(MonoAot) and !$(MonoFullAot)" >

    <PropertyGroup>
      <CrossgenDir>$(__BinDir)</CrossgenDir>
      <CrossgenDir Condition="'$(TargetArchitecture)' == 'arm'">$(CrossgenDir)\x64</CrossgenDir>
      <CrossgenDir Condition="'$(TargetArchitecture)' == 'arm64'">$(CrossgenDir)\x64</CrossgenDir>
      <CrossgenDir Condition="'$(TargetArchitecture)' == 'x86'">$(CrossgenDir)\x64</CrossgenDir>

      <CrossgenOutputDir>$(__TestIntermediatesDir)\crossgen.out</CrossgenOutputDir>

      <CrossgenCmd>$(DotNetCli)</CrossgenCmd>
      <CrossgenCmd>$(CrossgenCmd) "$(CORE_ROOT)\R2RTest\R2RTest.dll"</CrossgenCmd>
      <CrossgenCmd>$(CrossgenCmd) compile-framework</CrossgenCmd>
      <CrossgenCmd>$(CrossgenCmd) -cr "$(CORE_ROOT)"</CrossgenCmd>
      <CrossgenCmd>$(CrossgenCmd) --output-directory "$(CrossgenOutputDir)"</CrossgenCmd>
      <CrossgenCmd>$(CrossgenCmd) --release</CrossgenCmd>
      <CrossgenCmd>$(CrossgenCmd) --nocleanup</CrossgenCmd>
      <CrossgenCmd>$(CrossgenCmd) --target-arch $(TargetArchitecture)</CrossgenCmd>
      <CrossgenCmd>$(CrossgenCmd) -dop $(NUMBER_OF_PROCESSORS)</CrossgenCmd>
      <CrossgenCmd>$(CrossgenCmd) -m "$(CORE_ROOT)\StandardOptimizationData.mibc"</CrossgenCmd>

      <CrossgenCmd Condition="'$(__CreatePdb)' != ''">$(CrossgenCmd) --pdb</CrossgenCmd>
      <CrossgenCmd Condition="'$(__CreatePerfmap)' != ''">$(CrossgenCmd) --perfmap --perfmap-format-version 1</CrossgenCmd>
      <CrossgenCmd Condition="'$(__CompositeBuildMode)' != ''">$(CrossgenCmd) --composite</CrossgenCmd>
      <CrossgenCmd Condition="'$(__CompositeBuildMode)' == ''">$(CrossgenCmd) --crossgen2-parallelism 1</CrossgenCmd>

      <CrossgenCmd>$(CrossgenCmd) --verify-type-and-field-layout</CrossgenCmd>
      <CrossgenCmd>$(CrossgenCmd) --crossgen2-path "$(CrossgenDir)\crossgen2\crossgen2.dll"</CrossgenCmd>
    </PropertyGroup>

    <Message Importance="High" Text="$(MsgPrefix)Compiling framework using Crossgen2: $(CrossgenCmd)" />
    <Exec Command="$(CrossgenCmd)" />

    <ItemGroup>
      <CrossgenOutputFiles Include="$(CrossgenOutputDir)\*.dll" />
      <CrossgenOutputFiles Include="$(CrossgenOutputDir)\*.ni.pdb" Condition="'$(__CreatePdb)' != ''" />
      <CrossgenOutputFiles Include="$(CrossgenOutputDir)\*.ni.r2rmap" Condition="'$(__CreatePerfmap)' != ''" />
    </ItemGroup>

    <Move SourceFiles="@(CrossgenOutputFiles)" DestinationFolder="$(CORE_ROOT)" />
  </Target>

  <Target Name="CreateAndroidApps"
      DependsOnTargets="BuildAllAndroidApp"
      AfterTargets="ManagedBuild"
      Condition="'$(__BuildTestWrappersOnly)' != '1' and '$(__GenerateLayoutOnly)' != '1' and '$(__CopyNativeTestBinaries)' != '1' and $(RunWithAndroid)" />

  <Target Name="CreateIosApps"
      DependsOnTargets="BuildAlliOSApp"
      AfterTargets="ManagedBuild"
      Condition="'$(__BuildTestWrappersOnly)' != '1' and '$(__GenerateLayoutOnly)' != '1' and '$(__CopyNativeTestBinaries)' != '1' and ('$(TargetOS)' == 'iOS' or '$(TargetOS)' == 'iOSSimulator')" />

  <Target Name="BuildMonoAot"
      DependsOnTargets="MonoAotCompileTests"
      AfterTargets="ManagedBuild"
      Condition="'$(__BuildTestWrappersOnly)' != '1' and '$(__GenerateLayoutOnly)' != '1' and '$(__CopyNativeTestBinaries)' != '1' and ($(MonoAot) or $(MonoFullAot))" />

  <Target Name="BuildNativeAotFrameworkObjects"
          Condition="'$(BuildNativeAotFrameworkObjects)' == 'true' and '$(TestBuildMode)' == 'nativeaot'">
    <ItemGroup>
      <CreateLibProperty Include="IlcToolsPath=$(IlcToolsPath)" />
      <CreateLibProperty Include="IlcBuildTasksPath=$(IlcBuildTasksPath)" />
      <CreateLibProperty Include="IlcSdkPath=$(IlcSdkPath)" />
      <CreateLibProperty Include="IlcFrameworkPath=$(IlcFrameworkPath)" />
      <CreateLibProperty Include="FrameworkLibPath=$(IlcSdkPath)" />
      <CreateLibProperty Include="FrameworkObjPath=$(IntermediateOutputPath)/NativeAOTFX" />
      <CreateLibProperty Condition="'$(Configuration)' == 'Checked' or '$(Configuration)' == 'Release'" Include="Optimize=true" />
      <CreateLibProperty Include="NETCoreSdkVersion=6.0.0" />
    </ItemGroup>
    <MSBuild Projects="$(CoreCLRBuildIntegrationDir)/BuildFrameworkNativeObjects.proj"
      Targets="CreateLib"
      Properties="@(CreateLibProperty)" />
  </Target>

  <Target Name="EmitTestExclusionList">
    <PropertyGroup>
      <TestExclusionListPath>$(CORE_ROOT)\TestExclusionList.txt</TestExclusionListPath>
    </PropertyGroup>

    <ItemGroup>
      <FilteredExcludeList
        Include="$([System.IO.Path]::GetRelativePath('$(XunitTestBinBase)', '%(ExcludeList.FullPath)'))"
        Condition="'%(ExcludeList.Extension)' == '.dll'" />
    </ItemGroup>

    <WriteLinesToFile
        File="$(TestExclusionListPath)"
        Lines="@(FilteredExcludeList)"
        Overwrite="true"
        Encoding="Unicode" />
  </Target>
</Project>