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

CloudTest.targets « Tools-Override - github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0933afd5b73e86e8bb64ea11d28a40c8e689b84c (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
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <UsingTask TaskName="CreateAzureContainer" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.CloudTestTasks.dll"/>
  <UsingTask TaskName="CreateAzureFileShare" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.CloudTestTasks.dll"/>
  <UsingTask TaskName="GetPerfTestAssemblies" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.CloudTestTasks.dll"/>
  <UsingTask TaskName="SendJsonToDocumentDb" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.CloudTestTasks.dll"/>
  <UsingTask TaskName="SendToHelix" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.CloudTestTasks.dll"/>
  <UsingTask TaskName="UploadToAzure" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.CloudTestTasks.dll"/>
  <UsingTask TaskName="WriteItemsToJson" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.CloudTestTasks.dll"/>
  <UsingTask TaskName="WriteTestBuildStatsJson" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.CloudTestTasks.dll"/>
  <UsingTask TaskName="ZipFileCreateFromDirectory" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
  <UsingTask TaskName="ZipFileCreateFromDependencyLists" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
  <UsingTask TaskName="FilterForUpload" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.CloudTestTasks.dll"/>

  <!-- set Helix environment vars based on target platform -->
  <PropertyGroup Condition="'$(TargetsWindows)' == 'true'">
    <HelixPythonPath>%HELIX_PYTHONPATH%</HelixPythonPath>
    <HelixScriptRoot>%HELIX_SCRIPT_ROOT%\</HelixScriptRoot>
    <TestRunnerScript>%HELIX_CORRELATION_PAYLOAD%\RunnerScripts\scriptrunner\scriptrunner.py</TestRunnerScript>
  </PropertyGroup>
  <PropertyGroup Condition="'$(TargetsWindows)' != 'true'">
    <HelixPythonPath>$HELIX_PYTHONPATH</HelixPythonPath>
    <HelixScriptRoot>$HELIX_SCRIPT_ROOT/</HelixScriptRoot>
    <TestRunnerScript>$HELIX_CORRELATION_PAYLOAD/RunnerScripts/scriptrunner/scriptrunner.py</TestRunnerScript>
  </PropertyGroup>

  <PropertyGroup>
    <ContainerName>build-$([System.Guid]::NewGuid().ToString("N"))</ContainerName>
    <ContainerName>$(ContainerName.ToLower())</ContainerName>
    <FuncTestListFilename>FuncTests.$(BuildConfiguration).json</FuncTestListFilename>
    <PerfTestListFilename>PerfTests.$(BuildConfiguration).json</PerfTestListFilename>
    <!-- Test builds consist of the tests that are platform specific in one root, plus others in AnyOS. -->
    <AnyOSPlatformConfig>AnyOS.AnyCPU.$(ConfigurationGroup)</AnyOSPlatformConfig>
    <AnyOsArchivesRoot>$(TestWorkingDir)$(AnyOSPlatformConfig)/archive/</AnyOsArchivesRoot>
    <AnyOSTestArchivesRoot>$(AnyOsArchivesRoot)tests/</AnyOSTestArchivesRoot>
    <!-- Additionally, *NIX variations may need to include their own root folders -->
    <UnixPlatformConfig>Unix.$(Platform).$(ConfigurationGroup)</UnixPlatformConfig>
    <UnixArchivesRoot>$(TestWorkingDir)$(UnixPlatformConfig)/archive/</UnixArchivesRoot>
    <UnixTestArchivesRoot>$(UnixArchivesRoot)tests/</UnixTestArchivesRoot>
    <!-- Finally, these archives represent the zips of tests that are OSPlatform specific -->
    <ArchivesRoot>$(TestWorkingDir)$(OSPlatformConfig)/archive/</ArchivesRoot>
    <TestArchivesRoot>$(ArchivesRoot)tests/</TestArchivesRoot>
    <PackagesArchiveFilename>Packages.zip</PackagesArchiveFilename>
    <PackagesArchiveFile>$(ArchivesRoot)$(PackagesArchiveFilename)</PackagesArchiveFile>
    <TestRuntimeArchiveFilename>test-runtime-$(BuildConfiguration).zip</TestRuntimeArchiveFilename>
    <TestRuntimeArchiveFile>$(ArchivesRoot)$(TestRuntimeArchiveFilename)</TestRuntimeArchiveFile>
    <FuncTestListFile>$(TestWorkingDir)$(OSPlatformConfig)/$(FuncTestListFilename)</FuncTestListFile>
    <PerfTestListFile>$(TestWorkingDir)$(OSPlatformConfig)/$(PerfTestListFilename)</PerfTestListFile>
    <BuildStatsJsonFile>$(TestWorkingDir)$(OSPlatformConfig)/BuildStats.json</BuildStatsJsonFile>
    <RunnerScript Condition="'$(RunnerScript)' == ''">$(TestRunnerScript)</RunnerScript>
    <SupplementalPayloadDir Condition="'$(SupplementalPayloadDir)' == ''">$(TestWorkingDir)SupplementalPayload/</SupplementalPayloadDir>
    <SupplementalPayloadFilename>SupplementalPayload.zip</SupplementalPayloadFilename>
    <SupplementalPayloadFile>$(ArchivesRoot)$(SupplementalPayloadFilename)</SupplementalPayloadFile>

    <!-- Workaround to bring the whole Test ILC folder if required  -->
    <TestILCVersion>1.4.24208-prerelease</TestILCVersion>
    <TestILCFolder>$(PackagesDir)Microsoft.DotNet.TestILC\$(TestILCVersion)\contentFiles\any\any\TestILC</TestILCFolder>

    <TestILCZipFileName>TestILC.zip</TestILCZipFileName>
    <TestILCZipFile>$(ArchivesRoot)$(TestILCZipFileName)</TestILCZipFile>
    <OverwriteOnUpload Condition="'$(OverwriteOnUpload)' == ''">false</OverwriteOnUpload>
    <TimeoutInSeconds Condition="'$(TimeoutInSeconds)' == ''">600</TimeoutInSeconds>
    
    <IsOfficial Condition="'$(OfficialBuildId)'!=''">true</IsOfficial>
    <CurrentDate>$([System.DateTime]::Now.ToString(yyyyMMdd.mmss))</CurrentDate>
    <HelixJobType Condition="'$(FilterToTestTFM)'=='netcore50' and !$(TestNugetRuntimeId.Contains('aot'))">test/functional/uwp/</HelixJobType>
    <HelixJobType Condition="'$(FilterToTestTFM)'=='netcore50' and $(TestNugetRuntimeId.Contains('aot'))">test/functional/ilc/</HelixJobType>
    <HelixJobType Condition="$(FilterToTestTFM.Contains('net46'))">test/functional/desktop/cli/</HelixJobType>
    <HelixJobType Condition="'$(HelixJobType)'=='' And '$(Performance)'=='true'">test/functional/perf/cli/</HelixJobType>
    <HelixJobType Condition="'$(HelixJobType)'==''">test/functional/cli/</HelixJobType>    
    <HelixSource Condition="'$(HelixSource)'=='' And '$(IsOfficial)'!='' And '$(TestProduct)'!='' And '$(Branch)'!=''">official/$(TestProduct)/$(Branch)/</HelixSource>
    <HelixSource Condition="'$(HelixSource)'=='' And '$(IsOfficial)'=='' And '$(TestProduct)'!='' And '$(Branch)'!=''">pr/$(TestProduct)/$(Branch)/</HelixSource>
    <HelixSource Condition="'$(HelixSource)'==''">pr/unknown/</HelixSource>
    <HelixApiEndpoint>https://helix.dot.net/api/2016-06-28/jobs</HelixApiEndpoint>
  </PropertyGroup>

  <Import Project="$(MSBuildThisFileDirectory)CloudTest.Perf.targets" Condition="'$(Performance)' == 'true'" />

  <!-- main entrypoint -->
  <Target Name="CloudBuild"
          AfterTargets="Build"
          DependsOnTargets="VerifyInputs;PreCloudBuild;CreateTestListJson;UploadContent" />

  <Target Name="VerifyInputs">
    <!-- verify all required properties have been specified -->
    <Error Condition="'$(Creator)' == '' and '$(HelixApiAccessKey)' == ''" Text="Missing required property Creator." />
    <Error Condition="'$(TargetQueue)' == ''" Text="Missing required property TargetQueue." />
    <Error Condition="'$(TestProduct)' == ''" Text="Missing required property TestProduct." />
    <Error Condition="'$(BuildMoniker)' == ''" Text="Missing required property BuildMoniker." />
    <Error Condition="'$(Branch)' == ''" Text="Missing required property Branch." />

    <Error Condition="'$(CloudDropAccountName)' == ''" Text="Missing required property CloudDropAccountName." />
    <Error Condition="'$(CloudResultsAccountName)' == ''" Text="Missing required property CloudResultsAccountName." />
    <Error Condition="'$(CloudDropAccessToken)' == ''" Text="Missing required property CloudDropAccessToken." />
    <Error Condition="'$(CloudResultsAccessToken)' == ''" Text="Missing required property CloudResultsAccessToken." />

    <Warning Condition="'$(EventHubPath)' != '' or '$(EventHubSharedAccessKey)' != '' or '$(EventHubSharedAccessKeyName)' != ''" Text="EventHubPath and EventHubAccessKeys are ignored, use HelixApiAccessKey instead" />
    <Error Condition="'$(SkipNotifyEvent)' != 'true' and '$(HelixApiAccessKey)' == ''" Text="HelixApiAccessKey must be set to start Helix jobs" />

    <!-- gather the test archives for this build -->
    <ItemGroup>
      <OSPlatformTestArchives Include="$(TestArchivesRoot)**/*.zip" >
        <OSPlatformConfig>$(OSPlatformConfig)</OSPlatformConfig>
      </OSPlatformTestArchives>
      <AnyOSPlatformTestArchives Include="$(AnyOSTestArchivesRoot)**/*.zip" >
        <OSPlatformConfig>$(AnyOSPlatformConfig)</OSPlatformConfig>
      </AnyOSPlatformTestArchives>
      <!-- Only include Unix folders if supported by the current target OS -->
      <UnixPlatformTestArchives Condition="'$(TargetsUnix)' == 'true'" Include="$(UnixTestArchivesRoot)**/*.zip" >
        <OSPlatformConfig>$(UnixPlatformConfig)</OSPlatformConfig>
      </UnixPlatformTestArchives>
    </ItemGroup>

    <PropertyGroup>
        <OSPlatformTestArchivesListFile>$(TestArchivesRoot)/$(OSPlatformConfig)-Test-Archive-List.txt</OSPlatformTestArchivesListFile>
        <AnyOSPlatformTestArchivesListFile>$(AnyOSTestArchivesRoot)/$(AnyOSPlatformConfig)-Test-Archive-List.txt</AnyOSPlatformTestArchivesListFile>
        <UnixPlatformTestArchivesListFile>$(UnixTestArchivesRoot)/$(UnixPlatformConfig)-Test-Archive-List.txt</UnixPlatformTestArchivesListFile>
    </PropertyGroup>

    <!-- This is where we craft our archive Lists. These will sit at the base of the uploaded package. -->
    <WriteLinesToFile 
        File="$(OSPlatformTestArchivesListFile)"
        Lines="@(OSPlatformTestArchives -> '%(Filename)%(Extension)')"
        Overwrite="true"
        Condition="Exists('$(TestArchivesRoot)')"
        Encoding="Unicode" />
    
    <WriteLinesToFile 
        File="$(AnyOSPlatformTestArchivesListFile)"
        Lines="@(AnyOSPlatformTestArchives -> '%(Filename)%(Extension)')"
        Overwrite="true"
        Condition="Exists('$(AnyOSTestArchivesRoot)')"
        Encoding="Unicode" />

    <WriteLinesToFile 
        File="$(UnixPlatformTestArchivesListFile)"
        Lines="@(UnixPlatformTestArchives -> '%(Filename)%(Extension)')"
        Overwrite="true"
        Condition="Exists('$(UnixTestArchivesRoot)')"
        Encoding="Unicode" />
   
    <ItemGroup>
      <ForUpload Include="$(OSPlatformTestArchivesListFile)" Condition="Exists('$(OSPlatformTestArchivesListFile)')"/>
      <ForUpload Include="$(AnyOSPlatformTestArchivesListFile)" Condition="Exists('$(AnyOSPlatformTestArchivesListFile)')"/>
      <ForUpload Include="$(UnixPlatformTestArchivesListFile)" Condition="Exists('$(UnixPlatformTestArchivesListFile)')" />
    </ItemGroup>

   <!-- The unfiltered tests is the union of all of the tests archives we've selected -->
    <ItemGroup>   
      <UnfilteredTestArchives Include="@(OSPlatformTestArchives);@(AnyOSPlatformTestArchives);@(UnixPlatformTestArchives)" />
    </ItemGroup>

    <Message Text="Full, Unfiltered Test Archive Collection :: @(UnfilteredTestArchives)" Importance="Low" />

    <!-- If we wish to filter tests that we upload, then altering the FilterToTestTFM and FilterToOSGroup is where to do it at. 
    
    Disabled for now; We most likely no longer need this, but with the removal of the FilterToTestTFM and FilterTOOSGroup variables, 
    this is breaking build.  For now, the old method of including the zips for upload should work.
    
    In the near future, this specific knowledge (for instance that the files for upload come from three folders, Regular, AnyOS, and Unix
    Needs to be in CoreFX specific code, and CloudTest should just take a list of files generated in an external task.
   
    <FilterForUpload UnfilteredUploadItems="@(UnfilteredTestArchives)"
             FilterToTestTFM="$(FilterToTestTFM)"
             FilterToOSGroup="$(FilterToOSGroup)" 
             BinDir="$(BinDir)">
        <Output TaskParameter="FilteredUploadItems" PropertyName="ForUploadList" />
    </FilterForUpload>

    <CreateItem Include="$(ForUploadList)">
      <Output TaskParameter="Include" ItemName="ForUpload"/>
    </CreateItem>
    -->
    <ItemGroup>
       <ForUpload Include="@(UnfilteredTestArchives)" />
    </ItemGroup>
    <!-- To work around the removal of the build task, also need to turn the list of test archives to a property 
         like the previous build task would have output --> 
    <PropertyGroup>
      <ForUploadList>@(UnfilteredTestArchives)</ForUploadList>
    </PropertyGroup>

    <Message Condition="'$(FilterToTestTFM)' != ''" Text="Using test archives for TFM: $(FilterToTestTFM)" />
    <Message Text="Using OS-Specific test archives from: $(TestArchivesRoot)" />
    <Message Text="Using AnyOS test archives from: $(AnyOSTestArchivesRoot)" />
    <Message Condition="'$(TargetsUnix)' == 'true'"  Text="Using Unix test archives from: $(UnixTestArchivesRoot)" />

    <!-- Deprecated property, should clean up / remove when refactoring CloudTest-->
    <PropertyGroup>
      <RelativeBlobPathFolderContainingTests Condition="'$(FilterToTestTFM)' != ''" >Tests/$(FilterToTestTFM)</RelativeBlobPathFolderContainingTests>
      <RelativeBlobPathFolderContainingTests Condition="'$(FilterToTestTFM)' == ''" >Tests</RelativeBlobPathFolderContainingTests>
    </PropertyGroup>

    <!-- verify the test archives were created -->
    <Warning Condition="'@(ForUpload->Count())' == '0'" Text="Didn't find any test archives in supplied folders!!! Review logs to see where test archive(s) were placed and fix." />
    <!-- add relative blob path metadata -->
    <ItemGroup>
      <ForUpload>
        <RelativeBlobPath>$(Platform)$(ConfigurationGroup)/Tests/$([System.String]::Copy('%(RecursiveDir)').Replace('\', '/'))%(Filename)%(Extension)</RelativeBlobPath>
      </ForUpload>
    </ItemGroup>
  </Target>

  <!-- provided as an extensibility point for targets to run before the real work begins -->
  <Target Name="PreCloudBuild">
    <!-- copy runner scripts so they can be uploaded as supplemental payload -->
    <ItemGroup>
      <RunnerScripts Include="$(ToolsDir)RunnerScripts/**/*.py" />
      <RunnerScripts Include="$(ToolsDir)RunnerScripts/**/*.sh" />
      <RunnerScripts Include="$(ToolsDir)RunnerScripts/**/*.txt" />
    </ItemGroup>
    
    <Copy SourceFiles="@(RunnerScripts)"
          DestinationFiles="@(RunnerScripts->'$(SupplementalPayloadDir)RunnerScripts/%(RecursiveDir)%(Filename)%(Extension)')"
          SkipUnchangedFiles="true" />
    <!-- compress the supplemental payload directory for upload -->
    <ZipFileCreateFromDirectory
        SourceDirectory="$(SupplementalPayloadDir)"
        DestinationArchive="$(SupplementalPayloadFile)"
        OverwriteDestination="true" />
    <ItemGroup>
      <SupplementalPayload Include="$(SupplementalPayloadFile)">
        <RelativeBlobPath>$(SupplementalPayloadFilename)</RelativeBlobPath>
      </SupplementalPayload>
    </ItemGroup>

    <ZipFileCreateFromDirectory
      Condition="'$(UseDotNetNativeToolchain)' == 'true'"
      SourceDirectory="$(TestILCFolder)"
      DestinationArchive="$(TestILCZipFile)"
      IncludeBaseDirectory="true"
      OverwriteDestination="true" />
    <ItemGroup Condition="'$(UseDotNetNativeToolchain)' == 'true'" >
      <SupplementalPayload Include="$(TestILCZipFile)">
        <RelativeBlobPath>$([System.IO.Path]::GetFileName('$(TestILCZipFile)'))</RelativeBlobPath>
      </SupplementalPayload>
    </ItemGroup>
  </Target>

  <!-- create Azure containers and file shares -->
  <Target Name="CreateAzureStorage">
    <CreateAzureContainer
      AccountKey="$(CloudDropAccessToken)"
      AccountName="$(CloudDropAccountName)"
      ContainerName="$(ContainerName)"
      ReadOnlyTokenDaysValid="30">
      <Output TaskParameter="StorageUri" PropertyName="DropUri" />
      <Output TaskParameter="ReadOnlyToken" PropertyName="DropUriReadOnlyToken" />
    </CreateAzureContainer>
    <!-- now that we have a drop URI create the list of correlation payloads -->
    <ItemGroup>
      <CorrelationPayloadUri Include="$(DropUri)$(Platform)$(ConfigurationGroup)/$(TestRuntimeArchiveFilename)$(DropUriReadOnlyToken)" />
      <CorrelationPayloadUri Include="@(SupplementalPayload->'$(DropUri)%(RelativeBlobPath)$(DropUriReadOnlyToken)')" />
    </ItemGroup>
    <!-- flatten it into a property as msbuild chokes on @(CorrelationPayloadUri) in FunctionalTest.CorrelationPayloadUris :( -->
    <PropertyGroup>
      <CorrelationPayloadUris>@(CorrelationPayloadUri)</CorrelationPayloadUris>
      <CloudResultsReadTokenValidDays Condition="'$(CloudResultsReadTokenValidDays)' == ''">30</CloudResultsReadTokenValidDays>
      <CloudResultsWriteTokenValidDays Condition="'$(CloudResultsWriteTokenValidDays)' == ''">4</CloudResultsWriteTokenValidDays>
    </PropertyGroup>
    <CreateAzureContainer
      AccountKey="$(CloudResultsAccessToken)"
      AccountName="$(CloudResultsAccountName)"
      ContainerName="$(ContainerName)"
      ReadOnlyTokenDaysValid="$(CloudResultsReadTokenValidDays)"
      WriteOnlyTokenDaysValid="$(CloudResultsWriteTokenValidDays)">
      <Output TaskParameter="StorageUri" PropertyName="ResultsUri" />
      <Output TaskParameter="ReadOnlyToken" PropertyName="ResultsReadOnlyToken" />
      <Output TaskParameter="WriteOnlyToken" PropertyName="ResultsWriteOnlyToken" />
    </CreateAzureContainer>
  </Target>

  <Target Name="CreateTestListJson"
          DependsOnTargets="CreateFuncTestListJson;CreatePerfTestListJson" />

  <!-- allow skipping this target if perf testing is enabled -->
  <Target Name="CreateFuncTestListJson"
          DependsOnTargets="CreateAzureStorage"
          Condition="'$(Performance)' != 'true' or '$(FuncTestsDisabled)' != 'true'">
    <!-- create item group of functional tests 
         Due to recent refactoring, calculating the right paths for Uris is challenging, so just reuse the previous
         include approach to get a full list. 
         This allows us to use RecursiveDir as the path to the zip instead of guessing and generating it again.
    -->
    <ItemGroup>
      <FunctionalTest Include="$(TestArchivesRoot)**/*.zip" />
      <FunctionalTest Include="$(AnyOSTestArchivesRoot)**/*.zip" />
      <!-- Only include Unix folders if supported by the current target OS -->
      <FunctionalTest Condition="'$(TargetsUnix)' == 'true'" Include="$(UnixTestArchivesRoot)**/*.zip" />
    </ItemGroup>

    <PropertyGroup>
      <OtherRunnerScriptArgs Condition="'$(FilterToTargetGroup)' == 'net46'">$(OtherRunnerScriptArgs) --xunit-test-type=desktop </OtherRunnerScriptArgs>
      <XunitArgs Condition="'$(FilterToTargetGroup)' == 'net46'"> -noshadow $(XunitArgs)</XunitArgs>
    </PropertyGroup>

    <ItemGroup>
      <FunctionalTest>
        <Command Condition="'$(TargetsWindows)' == 'true'">$(HelixPythonPath) $(RunnerScript) --script RunTests.cmd %HELIX_CORRELATION_PAYLOAD%</Command>
        <Command Condition="'$(TargetsWindows)' != 'true'"> chmod +x $HELIX_WORKITEM_PAYLOAD/RunTests.sh &amp;&amp; $(HelixPythonPath) $(RunnerScript) --script RunTests.sh $HELIX_CORRELATION_PAYLOAD</Command>
        <CorrelationPayloadUris>[$(CorrelationPayloadUris)]</CorrelationPayloadUris>
        <PayloadUri>$(DropUri)$(Platform)$(ConfigurationGroup)/Tests/$([System.String]::Copy('%(RecursiveDir)').Replace('\', '/'))%(Filename)%(Extension)$(DropUriReadOnlyToken)</PayloadUri>
        <WorkItemId>%(Filename)</WorkItemId>
        <TimeoutInSeconds>$(TimeoutInSeconds)</TimeoutInSeconds>
      </FunctionalTest>
    </ItemGroup>
    <WriteItemsToJson JsonFileName="$(FuncTestListFile)" Items="@(FunctionalTest)" />
          
    <!-- add test lists to the list of items for upload -->
    <ItemGroup>
      <ForUpload Include="$(FuncTestListFile)">
        <RelativeBlobPath>$(FuncTestListFilename)</RelativeBlobPath>
      </ForUpload>
    </ItemGroup>
    <!-- for completion event -->
    <ItemGroup>
      <TestListFile Include="$(FuncTestListFile)">
        <CorrelationId>$([System.Guid]::NewGuid())</CorrelationId>
        <BuildCompleteJson>$(TestWorkingDir)$(OSPlatformConfig)/FuncBuildComplete.json</BuildCompleteJson>
        <OfficialBuildJson>$(TestWorkingDir)$(OSPlatformConfig)/FuncOfficialBuild.json</OfficialBuildJson>
        <HelixJobUploadCompletePath>$(TestWorkingDir)$(OSPlatformConfig)/helixjobuploadcomplete.sem</HelixJobUploadCompletePath>
      </TestListFile>
    </ItemGroup>
  </Target>

  <Target Name="CreatePerfTestListJson" DependsOnTargets="CreateAzureStorage" Condition="'$(Performance)' == 'true'">
    <PropertyGroup Condition="'$(TargetsWindows)' == 'true' AND '$(UseLegacyXunitPerfRunner)'!='true'">
      <OtherRunnerScriptArgs>--script RunTests.cmd %HELIX_CORRELATION_PAYLOAD%</OtherRunnerScriptArgs>
    </PropertyGroup>
    
    <PropertyGroup Condition="'$(TargetsWindows)' != 'true' AND '$(UseLegacyXunitPerfRunner)'!='true'">
      <OtherRunnerScriptArgs>--script RunTests.sh $HELIX_CORRELATION_PAYLOAD</OtherRunnerScriptArgs>
    </PropertyGroup>

    <!-- now gather the perf tests -->
    <ItemGroup>
      <TestBinary Include="$(BinDir)$(OSPlatformConfig)/**/*.dll" />
      <TestBinary Include="$(BinDir)$(OSPlatformConfig)/**/*.exe" />
      <TestBinary Include="$(BinDir)$(AnyOSPlatformConfig)/**/*.dll" />
      <TestBinary Include="$(BinDir)$(AnyOSPlatformConfig)/**/*.exe" />
    </ItemGroup>
    <ItemGroup Condition="'$(TargetsUnix)' == 'true'" >
      <TestBinary Include="$(BinDir)$(UnixPlatformConfig)/**/*.dll" />
      <TestBinary Include="$(BinDir)$(UnixPlatformConfig)/**/*.exe" />
    </ItemGroup>
    <GetPerfTestAssemblies TestBinaries="@(TestBinary)" GetFullPaths="false">
      <Output TaskParameter="PerfTestAssemblies" ItemName="PerfTestAssembly" />
    </GetPerfTestAssemblies>

    <!-- don't add any items to the group if no perf tests were found -->
    <ItemGroup Condition="'@(PerfTestAssembly->Count())' != '0'">
      <PerfTest Condition="Exists('$(TestArchivesRoot)$(FilterToTestTFM)/%(PerfTestAssembly.Identity).zip')" Include="$(TestArchivesRoot)$(FilterToTestTFM)/%(PerfTestAssembly.Identity).zip" />
      <PerfTest Condition="Exists('$(AnyOSTestArchivesRoot)$(FilterToTestTFM)/%(PerfTestAssembly.Identity).zip')" Include="$(AnyOSTestArchivesRoot)$(FilterToTestTFM)/%(PerfTestAssembly.Identity).zip" />
      <PerfTest Condition="'$(TargetsUnix)' == 'true' And Exists('$(UnixTestArchivesRoot)$(FilterToTestTFM)/%(PerfTestAssembly.Identity).zip')" Include="$(UnixTestArchivesRoot)$(FilterToTestTFM)/%(PerfTestAssembly.Identity).zip" />
    </ItemGroup>

    <PropertyGroup Condition="'$(TargetsUnix)' == 'true' AND '$(UseLegacyXunitPerfRunner)'!='true'">
      <PrefixPerfCommand>chmod +x $HELIX_WORKITEM_PAYLOAD/RunTests.sh &amp;&amp;</PrefixPerfCommand>
    </PropertyGroup>

    <!-- This is to temporarily support execution through legacy xunit perf runner -->
    <PropertyGroup Condition="'$(UseLegacyXunitPerfRunner)'=='true' AND '$(TargetsWindows)' == 'true'">
      <PerfRunner>Microsoft.DotNet.xunit.performance.runner.Windows</PerfRunner>
      <UseDotNetCli>false</UseDotNetCli>
    </PropertyGroup>
    <PropertyGroup Condition="'$(UseLegacyXunitPerfRunner)'=='true' AND '$(TargetsWindows)' != 'true'">
      <PerfRunner>Microsoft.DotNet.xunit.performance.runner.cli</PerfRunner>
      <UseDotNetCli>true</UseDotNetCli>
    </PropertyGroup>
    <PropertyGroup Condition="'$(UseLegacyXunitPerfRunner)'=='true'">
      <OtherRunnerScriptArgs>--perf-runner $(PerfRunner) --use-dotnetcli $(UseDotNetCli) $(OtherRunnerScriptArgs)</OtherRunnerScriptArgs>
    </PropertyGroup>


    <ItemGroup Condition="'@(PerfTestAssembly->Count())' != '0'">
      <PerfTest>
        <Command Condition="'$(UseLegacyXunitPerfRunner)'!='true'">$(PrefixPerfCommand) $(HelixPythonPath) $(RunnerScript) $(OtherRunnerScriptArgs)</Command>
        <Command Condition="'$(UseLegacyXunitPerfRunner)'=='true'">$(HelixPythonPath) $(RunnerScript) --dll %(Filename).dll $(OtherRunnerScriptArgs) -- $(XunitArgs)</Command>
        <CorrelationPayloadUris>[$(CorrelationPayloadUris)]</CorrelationPayloadUris>
        <PayloadUri>$(DropUri)$(Platform)$(ConfigurationGroup)/$(RelativeBlobPathFolderContainingTests)/%(Filename)%(Extension)$(DropUriReadOnlyToken)</PayloadUri>
        <WorkItemId>PerfTest.%(Filename)</WorkItemId>
        <TimeoutInSeconds>$(TimeoutInSeconds)</TimeoutInSeconds>
      </PerfTest>
    </ItemGroup>
    <WriteItemsToJson JsonFileName="$(PerfTestListFile)" Items="@(PerfTest)" />
    <!-- add test lists to the list of items for upload depending on whether FilterToTestTFM was specified or not-->
    <ItemGroup>
      <!-- Removing all zips and allowing only perf test assemblies to be uploaded -->
      <ForUpload Condition="'$(Performance)' == 'true'" Remove="@(ForUpload)"/>
      <ForUpload Condition="'$(Performance)' == 'true'" Include="@(PerfTest)">
        <RelativeBlobPath>$(Platform)$(ConfigurationGroup)/$(RelativeBlobPathFolderContainingTests)/$([System.String]::Copy('%(RecursiveDir)').Replace('\', '/'))%(Filename)%(Extension)</RelativeBlobPath>
      </ForUpload>
    </ItemGroup>
    <!-- add test lists to the list of items for upload -->
    <ItemGroup>
      <ForUpload Include="$(PerfTestListFile)">
        <RelativeBlobPath>$(PerfTestListFilename)</RelativeBlobPath>
      </ForUpload>
    </ItemGroup>
    <!-- for completion event -->
    <ItemGroup>
      <TestListFile Include="$(PerfTestListFile)">
        <CorrelationId>$([System.Guid]::NewGuid())</CorrelationId>
        <BuildCompleteJson>$(TestWorkingDir)$(OSPlatformConfig)/PerfBuildComplete.json</BuildCompleteJson>
        <OfficialBuildJson>$(TestWorkingDir)$(OSPlatformConfig)/PerfOfficialBuild.json</OfficialBuildJson>
        <HelixJobUploadCompletePath>$(TestWorkingDir)$(OSPlatformConfig)/helixjobuploadcomplete.sem</HelixJobUploadCompletePath>
      </TestListFile>
    </ItemGroup>
  </Target>

  <!-- compress the required files from the packages dir in preparation for uploading -->
  <Target Name="CompressPackagesDir" Condition="'$(SkipArchive)' != 'true'">
    <ItemGroup>
      <ExcludeFromArchive Include="nupkg$" />
      <ExcludeFromArchive Include="Microsoft.DotNet.BuildTools" />
      <ExcludeFromArchive Include="TestData" />
      <TestDependencyListFile Include="$(BinDir)/TestDependencies/*.dependencylist.txt" />
    </ItemGroup>

    <ZipFileCreateFromDependencyLists
      DependencyListFiles="@(TestDependencyListFile)"
      DestinationArchive="$(PackagesArchiveFile)"
      RelativePathBaseDirectory="$(PackagesDir)"
      OverwriteDestination="true" />
    <ItemGroup>
      <ForUpload Include="$(PackagesArchiveFile)">
        <RelativeBlobPath>$(Platform)$(ConfigurationGroup)/$(PackagesArchiveFilename)</RelativeBlobPath>
      </ForUpload>
    </ItemGroup>
  </Target>

  <Target Name="CompressRuntimeDir" Condition="'$(SkipArchive)' != 'true'">
    <ZipFileCreateFromDirectory
        SourceDirectory="$(TestHostRootPath)"
        DestinationArchive="$(TestRuntimeArchiveFile)"
        OverwriteDestination="true" />
    <ItemGroup>
      <ForUpload Include="$(TestRuntimeArchiveFile)">
        <RelativeBlobPath>$(Platform)$(ConfigurationGroup)/$(TestRuntimeArchiveFilename)</RelativeBlobPath>
      </ForUpload>
    </ItemGroup>
  </Target>

  <!-- upload content to Azure -->
  <Target Name="UploadContent" DependsOnTargets="CompressRuntimeDir" Condition="'$(SkipUpload)' != 'true'">
    <UploadToAzure
      AccountKey="$(CloudDropAccessToken)"
      AccountName="$(CloudDropAccountName)"
      ContainerName="$(ContainerName)"
      Items="@(ForUpload)"
      Overwrite="$(OverwriteOnUpload)" />
    <UploadToAzure
      AccountKey="$(CloudDropAccessToken)"
      AccountName="$(CloudDropAccountName)"
      ContainerName="$(ContainerName)"
      Items="@(SupplementalPayload)"
      Overwrite="$(OverwriteOnUpload)"
      Condition="'@(SupplementalPayload)' != ''" />
  </Target>

  <!-- write event hub notification JSON files -->
  <Target Name="WriteCompletionEvent"
          AfterTargets="UploadContent"
          Inputs="%(TestListFile.Identity)"
          Outputs="%(TestListFile.BuildCompleteJson)">
    <!-- signal that the build is ready for testing -->
    <ItemGroup>
      <BuildCompleteTemplateV2 Include="%(TestListFile.BuildCompleteJson)">
        <DropContainerSAS>$(DropUriReadOnlyToken)</DropContainerSAS>
        <ListUri>$(DropUri)%(TestListFile.Filename)%(TestListFile.Extension)$(DropUriReadOnlyToken)</ListUri>
        <QueueId>$(TargetQueue)</QueueId>
        <ResultsUri>$(ResultsUri)/%(TestListFile.CorrelationId)</ResultsUri>
        <ResultsUriRSAS>$(ResultsReadOnlyToken)</ResultsUriRSAS>
        <ResultsUriWSAS>$(ResultsWriteOnlyToken)</ResultsUriWSAS>
        <Build>$(CurrentDate)</Build>
        <Build Condition="'$(IsOfficial)'=='true'">$(OfficialBuildId)</Build>
        <Type>$(HelixJobType)</Type>
        <Source>$(HelixSource)</Source>
        <Properties>{ &quot;architecture&quot; : &quot;$(ArchGroup)&quot;, &quot;configuration&quot;: &quot;$(ConfigurationGroup)&quot;, &quot;operatingSystem&quot; : &quot;$(TargetQueue)&quot; }</Properties>
      </BuildCompleteTemplateV2>
      <BuildComplete Include="@(BuildCompleteTemplateV2)"/>
    </ItemGroup>
    <WriteItemsToJson JsonFileName="%(TestListFile.BuildCompleteJson)" Items="@(BuildComplete)" />
  </Target>

  <!-- Send completion event.  All start messages are now sent to Helix API; Event Hub direct sending is now deprecated. -->
  <Target Name="SendCompletionEvent"
          AfterTargets="WriteCompletionEvent"
          Inputs="%(TestListFile.BuildCompleteJson)"
          Outputs="%(TestListFile.HelixJobUploadCompletePath)"
          Condition="'$(SkipNotifyEvent)' != 'true'">
    <SendToHelix Condition=" '$(HelixApiAccessKey)' != '' "
      AccessToken="$(HelixApiAccessKey)"
      ApiEndpoint="$(HelixApiEndpoint)"
      EventDataPath="%(TestListFile.BuildCompleteJson)">
      <Output TaskParameter="JobId" PropertyName="GeneratedCorrelationId" />
    </SendToHelix>
    <WriteLinesToFile File="%(TestListFile.HelixJobUploadCompletePath)" Overwrite="true" Lines="Correlation Id : $(GeneratedCorrelationId)"/>
    <Message Condition="'$(HelixApiAccessKey)' == ''" Importance="High" Text="Started Helix job: CorrelationId = $(GeneratedCorrelationId)"/>
    
    <!-- Upload the Correlation Id to the test drop container for tracking purposes-->
    <PropertyGroup>
      <CorrelationFileName>correlation_id-$(ConfigurationGroup)-$(TestNugetRuntimeId).txt</CorrelationFileName>
    </PropertyGroup>
    <ItemGroup>
      <CorrelationFile Include="$(TestArchivesRoot)$(CorrelationFileName)">
        <RelativeBlobPath>Tracking/$(CorrelationFileName)</RelativeBlobPath>
      </CorrelationFile>
    </ItemGroup>
    <MakeDir Directories="$(TestArchivesRoot)" />
    <WriteLinesToFile
        File="@(CorrelationFile)"
        Lines="$(GeneratedCorrelationId)"
        Overwrite="true" />
    <UploadToAzure Condition=" '$(HelixApiAccessKey)' != '' "
        AccountKey="$(CloudDropAccessToken)"
        AccountName="$(CloudDropAccountName)"
        ContainerName="$(ContainerName)"
        Items="@(CorrelationFile)"
        Overwrite="true" />
  </Target>
</Project>