@@ -62,15 +62,15 @@ $env:TP_OUT_DIR = Join-Path $env:TP_ROOT_DIR "artifacts"
62
62
$env: TP_TESTARTIFACTS = Join-Path $env: TP_OUT_DIR " testArtifacts"
63
63
$env: TP_PACKAGE_PROJ_DIR = Join-Path $env: TP_ROOT_DIR " src\package"
64
64
65
- # Set Version from scripts/build/TestPlatform.Settings.targets
65
+ # Set Version from scripts/build/TestPlatform.Settings.targets, when we are running locally and not providing the version as the parameter
66
+ # or when the build is done directly in VS
66
67
if ([string ]::IsNullOrWhiteSpace($Version ))
67
68
{
68
- $Version = ([xml ](Get-Content $env: TP_ROOT_DIR \scripts\build\TestPlatform.Settings.targets)).Project.PropertyGroup.TPVersionPrefix |
69
- Where-Object { $_ } |
69
+ $Version = ([xml ](Get-Content $env: TP_ROOT_DIR \scripts\build\TestPlatform.Settings.targets)).Project.PropertyGroup[0 ].TPVersionPrefix |
70
70
ForEach-Object { $_.Trim () } |
71
71
Select-Object - First 1
72
72
73
- Write-Verbose " Version was not provided using version '$Version ' from TestPlatform.Settings.targets"
73
+ Write-Verbose " Version was not provided using version '$Version ' from TestPlatform.Settings.targets"
74
74
}
75
75
76
76
#
@@ -102,7 +102,7 @@ $TPB_TargetRuntime = $TargetRuntime
102
102
$TPB_X64_Runtime = " win7-x64"
103
103
$TPB_X86_Runtime = " win7-x86"
104
104
105
- # Version suffix is empty for RTM releases
105
+ # Version suffix is empty for RTM release
106
106
$TPB_Version = if ($VersionSuffix -ne ' ' ) { $Version + " -" + $VersionSuffix } else { $Version }
107
107
$TPB_CIBuild = $CIBuild
108
108
$TPB_PublishTests = $PublishTestArtifacts
@@ -116,6 +116,14 @@ $Script:ScriptFailed = $false
116
116
117
117
Import-Module " $ ( $CurrentScriptDir.FullName ) \verify-nupkgs.ps1"
118
118
119
+ # Update the version in the dependencies props to be the TPB_version version, this is not ideal but because changing how this is resolved would
120
+ # mean that we need to change the whole build process this is a solution with the least amount of impact, that does not require us to keep track of
121
+ # the version in multiple places
122
+ $dependenciesPath = " $env: TP_ROOT_DIR \scripts\build\TestPlatform.Dependencies.props"
123
+ $dependencies = Get-Content - Raw - Encoding UTF8 $dependenciesPath
124
+ $updatedDependencies = $dependencies -replace " <NETTestSdkVersion>.*?</NETTestSdkVersion>" , " <NETTestSdkVersion>$TPB_Version </NETTestSdkVersion>"
125
+ $updatedDependencies | Set-Content - Encoding UTF8 $dependenciesPath
126
+
119
127
function Write-Log ([string ] $message )
120
128
{
121
129
$currentColor = $Host.UI.RawUI.ForegroundColor
@@ -163,22 +171,42 @@ function Install-DotNetCli
163
171
Write-Log " Install-DotNetCli: Get the latest dotnet cli toolset..."
164
172
$dotnetInstallPath = Join-Path $env: TP_TOOLS_DIR " dotnet"
165
173
New-Item - ItemType directory - Path $dotnetInstallPath - Force | Out-Null
166
- & $dotnetInstallScript - Channel " master" - InstallDir $dotnetInstallPath - NoPath - Version $env: DOTNET_CLI_VERSION
174
+ & $dotnetInstallScript - Channel " master" - InstallDir $dotnetInstallPath - Version $env: DOTNET_CLI_VERSION
167
175
168
176
# Pull in additional shared frameworks.
169
177
# Get netcoreapp2.1 shared components.
170
- if (! (Test-Path " $dotnetInstallPath \shared\Microsoft.NETCore.App\2.1.0" )) {
171
- & $dotnetInstallScript - InstallDir $dotnetInstallPath - SharedRuntime - Version ' 2.1.0' - Channel ' release/2.1.0'
172
- }
178
+
179
+ & $dotnetInstallScript - InstallDir " $dotnetInstallPath " - Runtime ' dotnet' - Version ' 2.1.0' - Channel ' release/2.1.0' - Architecture x64 - NoPath
180
+ $env: DOTNET_ROOT = $dotnetInstallPath
181
+
182
+ & $dotnetInstallScript - InstallDir " ${dotnetInstallPath} _x86" - Runtime ' dotnet' - Version ' 2.1.0' - Channel ' release/2.1.0' - Architecture x86 - NoPath
183
+ ${env: DOTNET_ROOT(x86)} = " ${dotnetInstallPath} _x86"
184
+
185
+ $env: DOTNET_MULTILEVEL_LOOKUP = 0
186
+
187
+ " ---- dotnet environment variables"
188
+ Get-ChildItem " Env:\dotnet_*"
189
+
190
+ " `n`n ---- x64 dotnet"
191
+ & " $env: DOTNET_ROOT \dotnet.exe" -- info
192
+
193
+ " `n`n ---- x86 dotnet"
194
+ & " ${env: DOTNET_ROOT(x86)} \dotnet.exe" -- info
173
195
174
- # Get shared components which is compatible with dotnet cli version $env:DOTNET_CLI_VERSION
175
- # if (!(Test-Path "$dotnetInstallPath\shared\Microsoft.NETCore.App\$env:DOTNET_RUNTIME_VERSION")) {
176
- # & $dotnetInstallScript -InstallDir $dotnetInstallPath -SharedRuntime -Version $env:DOTNET_RUNTIME_VERSION -Channel 'master'
177
- # }
178
196
179
197
Write-Log " Install-DotNetCli: Complete. {$ ( Get-ElapsedTime ($timer )) }"
180
198
}
181
199
200
+ function Clear-Package {
201
+ # find all microsoft packages that have the same version as we specified
202
+ # this is cache-busting the nuget packages, so we don't reuse them from cache
203
+ # after we built new ones
204
+ if (Test-Path $env: TP_PACKAGES_DIR ) {
205
+ $devPackages = Get-ChildItem $env: TP_PACKAGES_DIR / microsoft.*/ $TPB_Version | Select-Object - ExpandProperty FullName
206
+ $devPackages | Remove-Item - Force - Recurse - Confirm:$false
207
+ }
208
+ }
209
+
182
210
function Restore-Package
183
211
{
184
212
$timer = Start-Timer
@@ -202,26 +230,51 @@ function Invoke-Build
202
230
203
231
Write-Log " .. .. Build: Source: $TPB_Solution "
204
232
Write-Verbose " $dotnetExe build $TPB_Solution --configuration $TPB_Configuration -v:minimal -p:Version=$TPB_Version -p:CIBuild=$TPB_CIBuild -p:LocalizedBuild=$TPB_LocalizedBuild "
205
- & $dotnetExe build $TPB_Solution -- configuration $TPB_Configuration - v:minimal - p:Version= $TPB_Version - p:CIBuild= $TPB_CIBuild - p:LocalizedBuild= $TPB_LocalizedBuild
233
+ & $dotnetExe build $TPB_Solution -- configuration $TPB_Configuration - v:minimal - p:Version= $TPB_Version - p:CIBuild= $TPB_CIBuild - p:LocalizedBuild= $TPB_LocalizedBuild - bl:TestPlatform.binlog
206
234
Write-Log " .. .. Build: Complete."
207
235
208
236
Set-ScriptFailedOnError
209
237
238
+ Write-Log " Invoke-Build: Complete. {$ ( Get-ElapsedTime ($timer )) }"
239
+ }
240
+
241
+ function Invoke-TestAssetsBuild
242
+ {
243
+ $timer = Start-Timer
244
+ Write-Log " Invoke-TestAssetsBuild: Start test assets build."
245
+ $dotnetExe = Get-DotNetPath
246
+
247
+
210
248
Write-Log " .. .. Build: Source: $TPB_TestAssets_Solution "
211
249
Write-Verbose " $dotnetExe build $TPB_TestAssets_Solution --configuration $TPB_Configuration -v:minimal -p:Version=$TPB_Version -p:CIBuild=$TPB_CIBuild "
212
- & $dotnetExe build $TPB_TestAssets_Solution -- configuration $TPB_Configuration - v:minimal - p:Version = $TPB_Version - p: CIBuild= $TPB_CIBuild - p:LocalizedBuild= $TPB_LocalizedBuild
250
+ & $dotnetExe build $TPB_TestAssets_Solution -- configuration $TPB_Configuration - v:minimal - p:CIBuild= $TPB_CIBuild - p:LocalizedBuild= $TPB_LocalizedBuild - bl: " $ ( $ env: TP_ROOT_DIR ) \TestAssets.binlog "
213
251
Write-Log " .. .. Build: Complete."
214
252
215
253
Set-ScriptFailedOnError
216
254
217
- Write-Log " Invoke-Build: Complete. {$ ( Get-ElapsedTime ($timer )) }"
255
+ Write-Log " Invoke-TestAssetsBuild: Complete. {$ ( Get-ElapsedTime ($timer )) }"
256
+ }
257
+
258
+ function Copy-PackageIntoStaticDirectory {
259
+ # packages are published into folder based on configuration, but
260
+ # nuget does not understand that, and does not support wildcards in paths
261
+ # in order to be able to use the produced packages for acceptance tests we
262
+ # need to put them in folder that is not changing it's name based on config
263
+ $tpPackagesPath = " $env: TP_OUT_DIR \$TPB_Configuration \packages\"
264
+ $tpPackagesDestination = " $env: TP_TESTARTIFACTS "
265
+ Copy-Item $tpPackagesPath $tpPackagesDestination - Force - Filter * .nupkg - Verbose - Recurse
218
266
}
219
267
220
268
function Publish-PatchedDotnet {
221
269
Write-Log " Publish-PatchedDotnet: Copy local dotnet installation to testArtifacts"
222
270
$dotnetPath = " $env: TP_TOOLS_DIR \dotnet\"
223
-
271
+
224
272
$dotnetTestArtifactsPath = " $env: TP_TESTARTIFACTS \dotnet\"
273
+
274
+ if (Test-Path $dotnetTestArtifactsPath ) {
275
+ Remove-Item - Force - Recurse $dotnetTestArtifactsPath
276
+ }
277
+
225
278
$dotnetTestArtifactsSdkPath = " $env: TP_TESTARTIFACTS \dotnet\sdk\$env: DOTNET_CLI_VERSION \"
226
279
Copy-Item $dotnetPath $dotnetTestArtifactsPath - Force - Recurse
227
280
@@ -922,15 +975,19 @@ Get-ChildItem env: | Where-Object -FilterScript { $_.Name.StartsWith("TP_") } |
922
975
Write-Log " Test platform build variables: "
923
976
Get-Variable | Where-Object - FilterScript { $_.Name.StartsWith (" TPB_" ) } | Format-Table
924
977
Install-DotNetCli
978
+ Clear-Package
925
979
Restore-Package
926
980
Update-LocalizedResources
927
981
Invoke-Build
928
982
Publish-Package
929
- Publish-PatchedDotnet
930
983
Publish-Tests
931
984
Create- VsixPackage
932
985
Create- NugetPackages
933
986
Generate- Manifest
987
+ Publish-PatchedDotnet
988
+ Copy-PackageIntoStaticDirectory
989
+ Invoke-TestAssetsBuild
990
+
934
991
Write-Log " Build complete. {$ ( Get-ElapsedTime ($timer )) }"
935
992
if ($Script :ScriptFailed ) { Exit 1 } else { Exit 0 }
936
993
0 commit comments