-
Notifications
You must be signed in to change notification settings - Fork 10.3k
/
Copy pathHelix.targets
234 lines (205 loc) · 12.7 KB
/
Helix.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
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
<Project>
<ItemGroup Condition="'$(TestDependsOnJava)' == 'true'">
<HelixPreCommand Condition="'$(IsWindowsHelixQueue)' == 'true'" Include="call RunPowershell.cmd InstallJdk.ps1 11.0.3 %25HELIX_CORRELATION_PAYLOAD%25\jdk && set %22JAVA_HOME=%25HELIX_CORRELATION_PAYLOAD%25\jdk%22" />
<HelixPreCommand Condition="'$(IsWindowsHelixQueue)' != 'true' AND '$(IsMacHelixQueue)' != 'true'" Include="./installjdk.sh 10.0.2 x64 && if [ "%24JAVA_HOME" = "" ]%3B then export JAVA_HOME=%24PWD/java%3B fi" />
</ItemGroup>
<ItemGroup Condition="'$(TestDependsOnMssql)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true' AND '$(IsArm64HelixQueue)' != 'true'">
<HelixPreCommand Include="call RunPowershell.cmd mssql\InstallSqlServerLocalDB.ps1 || exit /b 1" />
</ItemGroup>
<PropertyGroup>
<_TestingArchitecture>x64</_TestingArchitecture>
<_TestingArchitecture Condition=" '$(IsArm64HelixQueue)' == 'true' ">arm64</_TestingArchitecture>
<TestDependsOnPlaywright Condition="'$(TestDependsOnPlaywright)' == ''">false</TestDependsOnPlaywright>
</PropertyGroup>
<PropertyGroup Condition="'$(TestDependsOnPlaywright)' == 'true'">
<SkipHelixQueues>
$(HelixQueueAlmaLinux8);
$(HelixQueueAlpine316);
$(HelixQueueDebian11);
$(HelixQueueFedora34);
$(HelixQueueMariner);
Ubuntu.2004.Amd64.Open;
</SkipHelixQueues>
<SkipHelixArm>true</SkipHelixArm>
</PropertyGroup>
<ItemGroup Condition="'$(TestDependsOnPlaywright)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true'">
<HelixPreCommand Include="call RunPowershell.cmd installPlaywrightReqs.ps1 || exit /b 1" />
</ItemGroup>
<ItemGroup Condition="'$(TestDependsOnIIS)' == 'true' AND '$(IsWindowsOnlyTest)' == 'true'">
<HelixContent Include="$(RepoRoot)src\Servers\IIS\tools\update_schema.ps1" />
<HelixContent Include="$(RepoRoot)src\Servers\IIS\tools\UpdateIISExpressCertificate.ps1" />
<HelixContent Include="$(RepoRoot)src\Servers\IIS\tools\TestCert.pfx" />
<HelixContent Include="$(RepoRoot)src\Servers\IIS\AspNetCoreModuleV2\AspNetCore\aspnetcore_schema_v2.xml" />
<HelixPreCommand Include="call RunPowershell.cmd update_schema.ps1 || exit /b 1" />
<HelixPreCommand Include="call RunPowershell.cmd UpdateIISExpressCertificate.ps1 || exit /b 1" />
</ItemGroup>
<ItemGroup Condition="'$(TestDependsOnNode)' == 'true' AND '$(IsWindowsHelixQueue)' == 'false'">
<HelixPreCommand Include="./installnode.sh $(NodeVersion) $(_TestingArchitecture)" />
</ItemGroup>
<ItemGroup Condition="'$(TestDependsOnNode)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true'">
<HelixPreCommand Include="call RunPowershell.cmd InstallNode.ps1 $(NodeVersion) || exit /b 1" />
</ItemGroup>
<!-- $(TestDependsOnAspNetPackages) implies $(TestDependsOnAspNetRuntime). -->
<PropertyGroup Condition=" $(TestDependsOnAspNetPackages) AND !$(TestDependsOnAspNetRuntime) ">
<TestDependsOnAspNetRuntime>true</TestDependsOnAspNetRuntime>
</PropertyGroup>
<!--
Note wildcards mean work items may be submitted without necessary packages when using RunHelix.ps1. Without
the packages, the RunHelix.ps1 build won't fail fast and tests will fail on the Helix agents.
Similarly, the artifacts/packages/ folder may contain old packages e.g. some built on
another local branch when using RunHelix.ps1, invalidating tests to some extent.
-->
<ItemGroup>
<!-- Grab all shipping packages. -->
<HelixContent Include="$(ArtifactsShippingPackagesDir)*$(SharedFxVersion).nupkg"
Condition=" $(TestDependsOnAspNetPackages) "/>
<!-- Grab just the App.Ref and App.Runtime packages. -->
<HelixContent Include="$(ArtifactsShippingPackagesDir)Microsoft.AspNetCore.App.*$(SharedFxVersion).nupkg"
Condition=" $(TestDependsOnAspNetAppPackages) "/>
</ItemGroup>
<ItemGroup>
<!-- Java test projects do not use xUnit. -->
<HelixContent Include="$(OutputPath)Microsoft.VisualStudio.TestPlatform.Extension.Xunit.Xml.TestAdapter.dll"
Condition=" EXISTS('$(OutputPath)Microsoft.VisualStudio.TestPlatform.Extension.Xunit.Xml.TestLogger.dll') " />
<HelixContent Include="$(OutputPath)Microsoft.VisualStudio.TestPlatform.Extension.Xunit.Xml.TestLogger.dll"
Condition=" EXISTS('$(OutputPath)Microsoft.VisualStudio.TestPlatform.Extension.Xunit.Xml.TestLogger.dll') " />
</ItemGroup>
<!-- Item group has to be defined here because Helix.props is evaluated before xunit.runner.console.props -->
<ItemGroup Condition="$(BuildHelixPayload)">
<Content Include="@(HelixContent)" Visible="false" />
<Content Include="$(RepoRoot)eng\scripts\Download.ps1" Visible="false" />
<Content Include="$(RepoRoot)NuGet.config" Visible="false" />
<Content Include="$(RepoRoot)global.json" Visible="false" />
<ContentWithTargetPath Include="
$(RepoRoot)eng\common\pipeline-logging-functions.*;
$(RepoRoot)eng\common\tools.*">
<TargetPath>eng\common\%(Filename)%(Extension)</TargetPath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</ContentWithTargetPath>
</ItemGroup>
<!--
This target is meant to be used when invoking helix tests on one project at a time.
Usage: dotnet msbuild /t:Helix src/MyTestProject.csproj
-->
<Target Name="Helix">
<MSBuild Projects="$(MSBuildThisFileDirectory)..\helix\helix.proj"
Properties="Configuration=$(Configuration);
ProjectToBuild=$(MSBuildProjectFullPath);
RepoRoot=$(RepoRoot)" />
</Target>
<!-- Build the actual helix work items to send to helix queues -->
<Target Name="CreateHelixPayload" Returns="@(HelixWorkItem)">
<ItemGroup>
<_TargetFrameworks Remove="@(_TargetFrameworks)" />
<_TargetFrameworks Include="$(TargetFrameworks);$(TargetFramework)" />
</ItemGroup>
<MSBuild Projects="$(MSBuildProjectFullPath)"
Targets="_CreateHelixPayloadInner"
Properties="TargetFramework=%(_TargetFrameworks.Identity);">
<Output TaskParameter="TargetOutputs" ItemName="HelixWorkItem" />
</MSBuild>
</Target>
<ItemGroup>
<PackageReference Include="XunitXml.TestLogger" Version="2.1.26" />
</ItemGroup>
<Choose>
<When Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' OR '$(IsWindowsOnlyTest)' == 'true' ">
<ItemGroup>
<HelixProjectPlatform Include="Windows" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<HelixProjectPlatform Include="@(HelixAvailablePlatform)" />
</ItemGroup>
</Otherwise>
</Choose>
<Target Name="_SetCreateHelixPayload">
<PropertyGroup>
<_SelectedPlatforms>@(HelixProjectPlatform)</_SelectedPlatforms>
</PropertyGroup>
<ItemGroup Condition="'$(_UseHelixOpenQueues)' != 'true'">
<_Temp Include="@(HelixAvailableTargetQueue)" />
<HelixAvailableTargetQueue Remove="@(HelixAvailableTargetQueue)" />
<HelixAvailableTargetQueue Include="@(_Temp->'%(Identity)'->Replace('.Open','')->Replace('.open',''))" />
</ItemGroup>
<ItemGroup>
<!-- Include default queues based on platform -->
<_HelixProjectTargetQueue Include="%(HelixAvailableTargetQueue.Identity)" Condition="'%(HelixAvailableTargetQueue.Identity)' != '' AND '$(_SelectedPlatforms.Contains(%(Platform)))' == 'true'" />
<_HelixApplicableTargetQueue Include="%(_HelixProjectTargetQueue.Identity)" Condition="'%(Identity)' == '$(HelixTargetQueue)'" />
</ItemGroup>
<PropertyGroup>
<!-- Check HelixTargetQueues to allow RunHelix.ps1 to submit jobs anywhere. -->
<BuildHelixPayload
Condition=" '$(HelixTargetQueues)' == '' AND @(_HelixApplicableTargetQueue->Count()) == 0 ">false</BuildHelixPayload>
<BuildHelixPayload Condition="'$(IsArm64HelixQueue)' == 'true' AND '$(SkipHelixArm)' == 'true'">false</BuildHelixPayload>
<BuildHelixPayload Condition="$(HelixTargetQueue.StartsWith('%28Alpine.')) AND '$(SkipHelixAlpine)' == 'true'">false</BuildHelixPayload>
<BuildHelixPayload Condition="$(SkipHelixQueues.Contains('$(HelixTargetQueue)'))">false</BuildHelixPayload>
</PropertyGroup>
</Target>
<Target Name="_CreateHelixWorkItem" Condition="$(BuildHelixPayload)">
<PropertyGroup>
<!-- Extract the effective queue name from this format "(name)host@dockerimage". This is sometimes used in test code to skip tests. -->
<_HelixFriendlyNameTargetQueue>$(HelixTargetQueue)</_HelixFriendlyNameTargetQueue>
<_HelixFriendlyNameTargetQueue Condition="$(HelixTargetQueue.Contains('@'))">$(HelixTargetQueue.Substring(1, $([MSBuild]::Subtract($(HelixTargetQueue.LastIndexOf(')')), 1))))</_HelixFriendlyNameTargetQueue>
</PropertyGroup>
<!-- Important: If HelixTargetQueue is not removed here, then Publish will occur for every single queue type. And since Publish shouldn't depend on the queue we can just publish once -->
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="Publish" RemoveProperties="HelixTargetQueue;TestRunId" />
<!-- Isolate Helix tests from whatever happens to be in a parent directory. -->
<Copy SourceFiles="$(RepoRoot)eng\helix\content\Directory.Build.empty.in"
DestinationFiles="$(PublishDir)Directory.Build.props"
Condition="! EXISTS('$(PublishDir)Directory.Build.props') AND '$(TestDependsOnAspNetRuntime)' != 'true'"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
SkipUnchangedFiles="$(SkipCopyUnchangedFiles)" />
<Copy SourceFiles="$(RepoRoot)eng\helix\content\Directory.Build.empty.in"
DestinationFiles="$(PublishDir)Directory.Build.targets"
Condition="! EXISTS('$(PublishDir)Directory.Build.targets') AND '$(TestDependsOnAspNetRuntime)' != 'true'"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
SkipUnchangedFiles="$(SkipCopyUnchangedFiles)" />
<!--
Use the shared framework and ref/ assemblies copied to the Helix agents and expanded by HelixTestRunner.
Unfortunately, tests of Microsoft.NET.Sdk.Web templates will not reference the just-built
Microsoft.NET.Sdk.Razor. Adding a package reference for that would confuse tests of Microsoft.NET.Sdk templates.
-->
<Copy SourceFiles="$(ArtifactsBinDir)GenerateFiles\Directory.Build.props"
DestinationFiles="$(PublishDir)Directory.Build.props"
Condition="! EXISTS('$(PublishDir)Directory.Build.props') AND '$(TestDependsOnAspNetRuntime)' == 'true'"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
SkipUnchangedFiles="$(SkipCopyUnchangedFiles)" />
<Copy SourceFiles="$(ArtifactsBinDir)GenerateFiles\Directory.Build.targets"
DestinationFiles="$(PublishDir)Directory.Build.targets"
Condition="! EXISTS('$(PublishDir)Directory.Build.targets') AND '$(TestDependsOnAspNetRuntime)' == 'true'"
OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
SkipUnchangedFiles="$(SkipCopyUnchangedFiles)" />
<ConvertToAbsolutePath Paths="$(PublishDir)">
<Output TaskParameter="AbsolutePaths" PropertyName="PublishAbsoluteDir" />
</ConvertToAbsolutePath>
<ItemGroup>
<HelixWorkItem Include="$(HelixTestName)">
<PayloadDirectory>$(PublishAbsoluteDir)</PayloadDirectory>
<TestAssembly>$(TargetFileName)</TestAssembly>
<PreCommands>@(HelixPreCommand)</PreCommands>
<PostCommands>@(HelixPostCommand)</PostCommands>
<!--
When the targeting pack builds, it has exactly the same version as the shared framework. Passing
SharedFxVersion because that's needed even when the targeting pack isn't building.
-->
<Command Condition="$(IsWindowsHelixQueue)">call runtests.cmd $(TargetFileName) $(SharedFxVersion) $(_HelixFriendlyNameTargetQueue) $(_TestingArchitecture) $(RunQuarantinedTests) $(HelixTimeout) $(TestDependsOnPlaywright)</Command>
<Command Condition="!$(IsWindowsHelixQueue)">./runtests.sh $(TargetFileName) $(SharedFxVersion) $(_HelixFriendlyNameTargetQueue) $(_TestingArchitecture) $(RunQuarantinedTests) $(HelixTimeout) $(TestDependsOnPlaywright)</Command>
<Command Condition="'$(HelixCommand)' != ''">$(HelixCommand)</Command>
<Timeout>$(HelixTimeout)</Timeout>
</HelixWorkItem>
</ItemGroup>
</Target>
<Target Name="_CreateHelixPayloadInner" Returns="@(HelixWorkItem)"
DependsOnTargets="_SetCreateHelixPayload;_CreateHelixWorkItem"/>
</Project>