-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
workloads-testing.targets
224 lines (182 loc) · 12.3 KB
/
workloads-testing.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
<Project>
<PropertyGroup Condition="'$(TestUsingWorkloads)' == 'true'">
<!-- for non-ci builds, we install the sdk when tests are run -->
<InstallWorkloadForTesting Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(ArchiveTests)' == 'true'">true</InstallWorkloadForTesting>
</PropertyGroup>
<PropertyGroup Condition="'$(InstallWorkloadForTesting)' == 'true'">
<_SdkForWorkloadTestingBasePath>$(ArtifactsBinDir)</_SdkForWorkloadTestingBasePath>
<_SdkWithNoWorkloadPath>$([MSBuild]::NormalizeDirectory($(_SdkForWorkloadTestingBasePath), 'dotnet-none'))</_SdkWithNoWorkloadPath>
<_SdkWithNoWorkloadStampPath>$([MSBuild]::NormalizePath($(_SdkWithNoWorkloadPath), '.version-for-none-$(SdkVersionForWorkloadTesting).stamp'))</_SdkWithNoWorkloadStampPath>
<_DotNetPath>$([MSBuild]::NormalizePath($(_SdkWithNoWorkloadPath), 'dotnet'))</_DotNetPath>
<_DotNetPath Condition="$([MSBuild]::IsOSPlatform('windows'))">$(_DotNetPath).exe</_DotNetPath>
<PreparePackagesForWorkloadInstall Condition="'$(PreparePackagesForWorkloadInstall)' == ''">true</PreparePackagesForWorkloadInstall>
<InstallWorkloadUsingArtifactsDependsOn>
$(InstallWorkloadUsingArtifactsDependsOn);
_ProvisionDotNetForWorkloadTesting;
_InstallSharedFrameworksForWorkloadTesting;
_GetDotNetVersion;
_FirstDotNetRun;
_SetPackageVersionForWorkloadsTesting;
GetNuGetsToBuildForWorkloadTesting;
_PreparePackagesForWorkloadInstall;
GetWorkloadInputs;
_InstallWorkloads
</InstallWorkloadUsingArtifactsDependsOn>
</PropertyGroup>
<PropertyGroup>
<_DotNetInstallScriptName Condition="!$([MSBuild]::IsOSPlatform('windows'))">dotnet-install.sh</_DotNetInstallScriptName>
<_DotNetInstallScriptName Condition=" $([MSBuild]::IsOSPlatform('windows'))">dotnet-install.ps1</_DotNetInstallScriptName>
<_DotNetInstallScriptPath>$(ArtifactsObjDir)$(_DotNetInstallScriptName)</_DotNetInstallScriptPath>
</PropertyGroup>
<PropertyGroup Condition="'$(SdkVersionForWorkloadTesting)' != ''">
<_DotNetInstallCommand Condition="!$([MSBuild]::IsOSPlatform('windows'))"
>$(_DotNetInstallScriptPath) -i $(_SdkWithNoWorkloadPath) -v $(SdkVersionForWorkloadTesting)</_DotNetInstallCommand>
<_DotNetInstallCommand Condition="$([MSBuild]::IsOSPlatform('windows'))"
>$(_DotNetInstallScriptPath) -InstallDir $(_SdkWithNoWorkloadPath) -Version $(SdkVersionForWorkloadTesting)</_DotNetInstallCommand>
</PropertyGroup>
<PropertyGroup Condition="'$(SdkVersionForWorkloadTesting)' == ''">
<_DotNetInstallCommand Condition="!$([MSBuild]::IsOSPlatform('windows'))"
>$(_DotNetInstallScriptPath) -i $(_SdkWithNoWorkloadPath) -v latest -q daily --channel 9.0</_DotNetInstallCommand>
<_DotNetInstallCommand Condition="$([MSBuild]::IsOSPlatform('windows'))"
>$(_DotNetInstallScriptPath) -InstallDir $(_SdkWithNoWorkloadPath) -Quality daily -Channel 9.0</_DotNetInstallCommand>
</PropertyGroup>
<ItemGroup>
<!--<AdditionalSharedFrameworkToInstallArguments Include="-Version 8.0.0-rc.2.23457.7" />-->
<!-- Required for running apps built with 9.0 sdk, but the sdk does
not yet support *running* with 9.0 sdk -->
<AdditionalSharedFrameworkToInstallArguments Condition="!$([MSBuild]::IsOSPlatform('windows'))" Include="-Version latest -c 8.0 -q daily" />
<AdditionalSharedFrameworkToInstallArguments Condition=" $([MSBuild]::IsOSPlatform('windows'))" Include="-Version latest -Channel 8.0 -Quality daily" />
<_DefaultPropsForNuGetBuild Include="Configuration=$(Configuration)" />
<_DefaultPropsForNuGetBuild Include="TargetOS=$(TargetOS)" />
<_DefaultPropsForNuGetBuild Include="TargetArchitecture=$(TargetArchitecture)" />
<_DefaultPropsForNuGetBuild Include="ContinuousIntegrationBuild=$(ContinuousIntegrationBuild)" />
</ItemGroup>
<Target Name="_ProvisionDotNetForWorkloadTesting" Condition="!Exists($(_SdkWithNoWorkloadStampPath))">
<Error Text="%24(_SdkWithNoWorkloadPath) is not set" Condition="'$(_SdkWithNoWorkloadPath)' == ''" />
<Message Text="** Installing sdk $(SdkVersionForWorkloadTesting) for workload based tests into $(_SdkWithNoWorkloadPath)"
Condition="'$(SdkVersionForWorkloadTesting)' != ''"
Importance="High" />
<Message Text="** Installing latest sdk for workload based tests into $(_SdkWithNoWorkloadPath)"
Condition="'$(SdkVersionForWorkloadTesting)' == ''"
Importance="High" />
<ItemGroup>
<_SdkWithNoWorkloadTarget Include="none" InstallPath="$(_SdkWithNoWorkloadPath)" />
</ItemGroup>
<RemoveDir Directories="$(_SdkWithNoWorkloadPath)" />
<MakeDir Directories="$(_SdkWithNoWorkloadPath)" />
<DownloadFile SourceUrl="https://dot.net/v1/$(_DotNetInstallScriptName)"
DestinationFolder="$(ArtifactsObjDir)"
Retries="3"
Condition="!Exists($(_DotNetInstallScriptPath))"/>
<Exec Condition="!$([MSBuild]::IsOSPlatform('windows'))"
IgnoreStandardErrorWarningFormat="true"
Command="chmod +x $(_DotNetInstallScriptPath); $(_DotNetInstallCommand)" />
<Exec Condition="$([MSBuild]::IsOSPlatform('windows'))"
IgnoreStandardErrorWarningFormat="true"
Command='powershell -ExecutionPolicy ByPass -NoProfile -command "& $(_DotNetInstallCommand)"' />
</Target>
<!-- TODO: stamps -->
<Target Name="_InstallSharedFrameworksForWorkloadTesting">
<Exec Condition="'%(AdditionalSharedFrameworkToInstallArguments.Identity)' != '' and !$([MSBuild]::IsOSPlatform('windows'))"
IgnoreStandardErrorWarningFormat="true"
Command="$(_DotNetInstallScriptPath) -InstallDir $(_SdkWithNoWorkloadPath) -Runtime dotnet -SkipNonVersionedFiles %(AdditionalSharedFrameworkToInstallArguments.Identity)" />
<Exec Condition="'%(AdditionalSharedFrameworkToInstallArguments.Identity)' != '' and $([MSBuild]::IsOSPlatform('windows'))"
IgnoreStandardErrorWarningFormat="true"
Command='powershell -ExecutionPolicy ByPass -NoProfile -command "& $(_DotNetInstallScriptPath) -InstallDir $(_SdkWithNoWorkloadPath) -Runtime dotnet -SkipNonVersionedFiles %(AdditionalSharedFrameworkToInstallArguments.Identity)"' />
</Target>
<Target Name="_GetDotNetVersion">
<PropertyGroup>
<_DotNetVersionCommand>$(_DotNetPath) --version</_DotNetVersionCommand>
</PropertyGroup>
<Exec Command="$(_DotNetVersionCommand)" ConsoleToMsBuild="true" StandardOutputImportance="Low" IgnoreExitCode="true">
<Output TaskParameter="ConsoleOutput" PropertyName="_DotNetVersionOutput" />
<Output TaskParameter="ExitCode" PropertyName="_DotNetVersionExitCode" />
</Exec>
<!-- If `dotnet -version` failed, then run it again, so we can surface the output as *Errors*.
This allows the errors to show up correctly, versus trying to use the output lines with
the Error task -->
<Exec Condition="$(_DotNetVersionExitCode) != '0'" Command="$(_DotNetVersionCommand)" CustomErrorRegularExpression=".*" />
<PropertyGroup>
<SdkBandVersionForWorkload_ComputedFromInstaller>$(SdkBandVersion)$([System.Text.RegularExpressions.Regex]::Match($(_DotNetVersionOutput), `-[A-z]*[\.]*\d*`))</SdkBandVersionForWorkload_ComputedFromInstaller>
</PropertyGroup>
<Message Text="** Using sdk band version for installing manifests: $(SdkBandVersionForWorkload_ComputedFromInstaller)" Importance="High" />
<Message Text="
********************
Warning: Using sdk band version for installing manifests: $(SdkBandVersionForWorkload_ComputedFromInstaller),
but the sdk band version in runtime is : $(SdkBandVersionForWorkload_FromRuntimeVersions)
********************"
Condition="$(SdkBandVersionForWorkload_ComputedFromInstaller) != $(SdkBandVersionForWorkload_FromRuntimeVersions)"
Importance="High" />
</Target>
<Target Name="_FirstDotNetRun">
<!-- info`, or version don't trigger workload integrity check -->
<Exec Command="$(_DotNetPath) workload list" ConsoleToMsBuild="true" StandardOutputImportance="Low" />
</Target>
<Target Name="_SetPackageVersionForWorkloadsTesting">
<PropertyGroup>
<!-- Used for workload testing -->
<PackageVersionForWorkloadManifests>$(PackageVersion)</PackageVersionForWorkloadManifests>
<PackageVersionForWorkloadManifests Condition="'$(StabilizePackageVersion)' == 'true'">$(ProductVersion)</PackageVersionForWorkloadManifests>
</PropertyGroup>
<Error Condition="'$(PackageVersionForWorkloadManifests)' == ''"
Text="%24(PackageVersionForWorkloadManifests) is not set. PackageVersion=$(PackageVersion)." />
</Target>
<Target Name="GetWorkloadInputs" DependsOnTargets="$(GetWorkloadInputsDependsOn)">
<ItemGroup>
<AvailableNuGetsInArtifacts Include="$(LibrariesShippingPackagesDir)\*.nupkg" />
<!--<_SdkWithWorkloadToInstall Include="none" Version="none" />-->
<_SdkWithWorkloadToInstall Include="@(WorkloadCombinationsToInstall)" />
<_SdkWithWorkloadToInstall InstallPath="$(_SdkForWorkloadTestingBasePath)\dotnet-%(Identity)" />
<!--<_SdkWithWorkloadToInstall StampPath="%(InstallPath)\version-%(Version).stamp" Condition="'%(Version)' != ''" />-->
<_SdkWithWorkloadToInstall StampPath="%(InstallPath)\.workload-installed.$(RuntimeIdentifier).stamp" />
</ItemGroup>
<Error Text="Cannot find any nupkg files in $(LibrariesShippingPackagesDir), needed for workloads" Condition="@(AvailableNuGetsInArtifacts->Count()) == 0" />
</Target>
<UsingTask Condition="'$(InstallWorkloadForTesting)' == 'true'"
TaskName="Microsoft.Workload.Build.Tasks.InstallWorkloadFromArtifacts"
AssemblyFile="$(WorkloadBuildTasksAssemblyPath)" />
<UsingTask Condition="'$(InstallWorkloadForTesting)' == 'true'"
TaskName="GenerateFileFromTemplate"
AssemblyFile="$(WorkloadBuildTasksAssemblyPath)" />
<Target Name="InstallWorkloadUsingArtifacts"
AfterTargets="ArchiveTests"
DependsOnTargets="$(InstallWorkloadUsingArtifactsDependsOn)"
Condition="'$(InstallWorkloadForTesting)' == 'true'" />
<Target Name="GetNuGetsToBuildForWorkloadTesting" Returns="@(_NuGetsToBuild)" DependsOnTargets="$(GetNuGetsToBuildForWorkloadTestingDependsOn)" Condition="'$(PreparePackagesForWorkloadInstall)' == 'true'">
<ItemGroup>
<_NuGetsToBuild Include="$(LibrariesShippingPackagesDir)Microsoft.NETCore.App.Ref.$(PackageVersionForWorkloadManifests).nupkg"
Project="$(InstallerProjectRoot)pkg/sfx/Microsoft.NETCore.App\Microsoft.NETCore.App.Ref.sfxproj"
Properties="@(_DefaultPropsForNuGetBuild, ';')"
Descriptor="Ref pack"/>
</ItemGroup>
</Target>
<Target Name="_PreparePackagesForWorkloadInstall" Inputs="%(_NuGetsToBuild.Project);%(_NuGetsToBuild.Dependencies)" Outputs="%(_NuGetsToBuild.Identity)" Condition="'$(PreparePackagesForWorkloadInstall)' == 'true'">
<Message Importance="High" Text="
** Building %(_NuGetsToBuild.Descriptor) **
" />
<MSBuild Projects="%(_NuGetsToBuild.Project)"
Properties="%(_NuGetsToBuild.Properties)"
Targets="Restore" />
<MSBuild Projects="%(_NuGetsToBuild.Project)"
Properties="%(_NuGetsToBuild.Properties)"
Targets="Pack" />
</Target>
<Target Name="_InstallWorkloads"
Inputs="@(AvailableNuGetsInArtifacts)"
Outputs="@(_SdkWithWorkloadToInstall->'%(StampPath)');$(_SdkWithNoWorkloadStampPath)">
<ItemGroup>
<_BuiltNuGets Include="$(LibrariesShippingPackagesDir)\*.nupkg" />
</ItemGroup>
<Message Text="Packages found in $(LibrariesShippingPackagesDir): @(_BuiltNuGets)" Importance="Low" />
<InstallWorkloadFromArtifacts
WorkloadIds="@(WorkloadIdForTesting)"
InstallTargets="@(_SdkWithWorkloadToInstall)"
VersionBandForSdkManifestsDir="$(SdkBandVersionForWorkload_ComputedFromInstaller)"
VersionBandForManifestPackages="$(SdkBandVersionForWorkload_FromRuntimeVersions)"
LocalNuGetsPath="$(LibrariesShippingPackagesDir)"
TemplateNuGetConfigPath="$(RepoRoot)NuGet.config"
SdkWithNoWorkloadInstalledPath="$(_SdkWithNoWorkloadPath)"
/>
<Touch Files="$(_SdkWithNoWorkloadStampPath)" AlwaysCreate="true" />
</Target>
</Project>