-
Notifications
You must be signed in to change notification settings - Fork 353
/
XHarnessRunner.targets
131 lines (113 loc) · 8.03 KB
/
XHarnessRunner.targets
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
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
<Project>
<PropertyGroup Condition=" '$(IncludeXHarnessCli)' == 'true' ">
<IncludeDotNetCli>true</IncludeDotNetCli>
<XHarnessTargetFramework Condition=" '$(XHarnessTargetFramework)' == '' ">net8.0</XHarnessTargetFramework>
<DotNetCliVersion Condition=" '$(XHarnessTargetFramework)' == 'net8.0' ">8.0.100</DotNetCliVersion>
<DotNetCliVersion Condition=" '$(XHarnessTargetFramework)' == 'net7.0' ">7.0.100</DotNetCliVersion>
<DotNetCliVersion Condition=" '$(XHarnessTargetFramework)' == 'net6.0' ">6.0.202</DotNetCliVersion>
<DotNetCliPackageType>sdk</DotNetCliPackageType>
</PropertyGroup>
<Target Name="AddXHarnessCli"
Condition=" '$(IncludeXHarnessCli)' == 'true' "
BeforeTargets="CoreTest"
AfterTargets="AddDotNetSdk">
<Error Condition=" '$(_XHarnessPackageVersion)' == '' " Text="XHarness CLI version not defined! Please specify it using the MicrosoftDotNetXHarnessCLIVersion property" />
<!-- When XHarnessNupkgPath is set, we send the .nupkg with the job and install the tool from there -->
<Message Condition=" '$(XHarnessNupkgPath)' != '' " Text="XHarnessNupkgPath is set so XHarnessPackageSource will be ignored" Importance="normal" />
<PropertyGroup Condition=" '$(XHarnessNupkgPath)' != '' ">
<XHarnessPackageSource>$([System.IO.Path]::GetDirectoryName($(XHarnessNupkgPath)))</XHarnessPackageSource>
<XHarnessNoCache>true</XHarnessNoCache>
</PropertyGroup>
<!--
We install the tool locally on the build machine, then, installed as-is, we zip it up and send as a correlation payload
We do this so that we avoid all of the machines installing the tool too and ddosing the NuGet feed
-->
<InstallDotNetTool Name="$(_XHarnessPackageName)"
DestinationPath="$(ArtifactsTmpDir)"
Version="$(_XHarnessPackageVersion)"
Source="$(XHarnessPackageSource)"
TargetFramework="$(XHarnessTargetFramework)"
WorkingDirectory="$(ArtifactsTmpDir)"
DotnetPath="$(DotNetTool)"
NoCache="$(XHarnessNoCache)">
<Output TaskParameter="ToolPath" PropertyName="_XHarnessCliPath" />
</InstallDotNetTool>
<!-- We grab the unpacked .NET command line application from the .NET tool store where it is installed -->
<PropertyGroup>
<_XHarnessCliPath>$(_XHarnessCliPath)\.store\microsoft.dotnet.xharness.cli\$(_XHarnessPackageVersion)\microsoft.dotnet.xharness.cli\$(_XHarnessPackageVersion)</_XHarnessCliPath>
</PropertyGroup>
<!-- There are files we don't need extracted inside of the extracted tool dir (such as the original .nupkg) that blow up the size 3x, so we remove them -->
<ItemGroup>
<_XHarnessExtraToolFiles Include="$(_XHarnessCliPath)\*.*" />
</ItemGroup>
<Delete Files="@(_XHarnessExtraToolFiles)" TreatErrorsAsWarnings="true" ContinueOnError="WarnAndContinue" />
<ItemGroup>
<HelixCorrelationPayload Include="$(_XHarnessCliPath)">
<Destination>microsoft.dotnet.xharness.cli</Destination>
<IncludeDirectoryName>true</IncludeDirectoryName>
</HelixCorrelationPayload>
</ItemGroup>
<!-- When using a dotnet 'tool' that is not installed globally, we must set DOTNET_ROOT.
This is because a framework dependent dotnet tool only searches in program files folders for runtimes.
When .NET is not already installed there, we set DOTNET_ROOT to help it find the right one. -->
<PropertyGroup Condition="$(IsPosixShell)">
<HelixPreCommands>$(HelixPreCommands);export PATH=$HELIX_CORRELATION_PAYLOAD/xharness-cli:$PATH</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);export XHARNESS_DISABLE_COLORED_OUTPUT=true</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);export XHARNESS_LOG_WITH_TIMESTAMPS=true</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);export XHARNESS_CLI_PATH=$HELIX_CORRELATION_PAYLOAD/microsoft.dotnet.xharness.cli/$(_XHarnessPackageVersion)/tools/$(XHarnessTargetFramework)/any/Microsoft.DotNet.XHarness.CLI.dll</HelixPreCommands>
<HelixPreCommands Condition=" '$(EnableXHarnessTelemetry)' == 'true' ">$(HelixPreCommands);export XHARNESS_DIAGNOSTICS_PATH=$HELIX_WORKITEM_ROOT/diagnostics.json</HelixPreCommands>
<HelixPostCommands Condition=" '$(EnableXHarnessTelemetry)' == 'true' ">"$HELIX_PYTHONPATH" -u "$HELIX_WORKITEM_PAYLOAD/xharness-event-processor.py";$(HelixPostCommands)</HelixPostCommands>
</PropertyGroup>
<PropertyGroup Condition="!$(IsPosixShell)">
<HelixPreCommands>$(HelixPreCommands);set PATH=%HELIX_CORRELATION_PAYLOAD%\xharness-cli%3B%PATH%</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);set XHARNESS_DISABLE_COLORED_OUTPUT=true</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);set XHARNESS_LOG_WITH_TIMESTAMPS=true</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);set XHARNESS_CLI_PATH=%HELIX_CORRELATION_PAYLOAD%\microsoft.dotnet.xharness.cli\$(_XHarnessPackageVersion)\tools\$(XHarnessTargetFramework)\any\Microsoft.DotNet.XHarness.CLI.dll</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);doskey xharness="dotnet exec %XHARNESS_CLI_PATH%"</HelixPreCommands>
<HelixPreCommands Condition=" '$(EnableXHarnessTelemetry)' == 'true' ">$(HelixPreCommands);set XHARNESS_DIAGNOSTICS_PATH=%HELIX_WORKITEM_ROOT%\diagnostics.json</HelixPreCommands>
<HelixPostCommands Condition=" '$(EnableXHarnessTelemetry)' == 'true' ">"%HELIX_PYTHONPATH%" -u "%HELIX_WORKITEM_PAYLOAD%\xharness-event-processor.py";$(HelixPostCommands)</HelixPostCommands>
</PropertyGroup>
</Target>
<Target Name="BuildXHarnessAndroidProjects"
Condition=" '@(XHarnessAndroidProject)' != '' "
BeforeTargets="CoreBuild"
Outputs="%(XHarnessAndroidProject.Identity)%(XHarnessAndroidProject.AdditionalProperties)">
<PropertyGroup>
<_CurrentXHarnessAndroidProject>%(XHarnessAndroidProject.Identity)</_CurrentXHarnessAndroidProject>
<_CurrentAdditionalProperties>%(XHarnessAndroidProject.AdditionalProperties)</_CurrentAdditionalProperties>
</PropertyGroup>
<MSBuild Projects="$(_CurrentXHarnessAndroidProject)" Targets="Build" Properties="$(_CurrentAdditionalProperties)">
<Output TaskParameter="TargetOutputs" ItemName="XHarnessApkToTest" />
</MSBuild>
</Target>
<Target Name="BuildXHarnessAppleProjects"
Condition=" '@(XHarnessAppleProject)' != '' "
BeforeTargets="CoreBuild"
Outputs="%(XHarnessAppleProject.Identity)%(XHarnessAppleProject.AdditionalProperties)">
<PropertyGroup>
<_CurrentXHarnessAppleProject>%(XHarnessAppleProject.Identity)</_CurrentXHarnessAppleProject>
<_CurrentAdditionalProperties>%(XHarnessAppleProject.AdditionalProperties)</_CurrentAdditionalProperties>
</PropertyGroup>
<MSBuild Projects="$(_CurrentXHarnessAppleProject)" Targets="Build" Properties="$(_CurrentAdditionalProperties)">
<Output TaskParameter="TargetOutputs" ItemName="XHarnessAppBundleToTest" />
</MSBuild>
</Target>
<Target Name="CreateAndroidWorkItems"
Condition=" '@(XHarnessApkToTest)' != '' "
BeforeTargets="CoreTest">
<CreateXHarnessAndroidWorkItems Apks="@(XHarnessApkToTest)" IsPosixShell="$(IsPosixShell)">
<Output TaskParameter="WorkItems" ItemName="HelixWorkItem"/>
</CreateXHarnessAndroidWorkItems>
</Target>
<Target Name="CreateAppleWorkItems"
Condition=" '@(XHarnessAppBundleToTest)' != '' "
BeforeTargets="CoreTest">
<CreateXHarnessAppleWorkItems AppBundles="@(XHarnessAppBundleToTest)"
XcodeVersion="$(XHarnessXcodeVersion)"
ProvisioningProfileUrl="$(XHarnessAppleProvisioningProfileUrl)"
TmpDir="$(ArtifactsTmpDir)">
<Output TaskParameter="WorkItems" ItemName="HelixWorkItem"/>
</CreateXHarnessAppleWorkItems>
</Target>
</Project>