diff --git a/tools/common.ps1 b/tools/common.ps1 index 47fc377a..ea38f468 100644 --- a/tools/common.ps1 +++ b/tools/common.ps1 @@ -117,6 +117,22 @@ function Get-EbpfMsiUrl { return "/~https://github.com/microsoft/xdp-for-windows/releases/download/main-prerelease/$EbpfMsiFilename" } +function Get-CoreNetCiCommit { + return "61af6f56ef187dcedb459bcc56f56e305f98a6e4" +} + +function Get-CoreNetCiArtifactPath { + param ( + [Parameter()] + [string]$Name + ) + + $RootDir = Split-Path $PSScriptRoot -Parent + $Commit = Get-CoreNetCiCommit + + return "$RootDir\artifacts\corenet-ci-$Commit\vm-setup\$Name" +} + # Refreshes the PATH environment variable. function Refresh-Path { $env:Path=( @@ -131,8 +147,8 @@ function Collect-LiveKD { [string]$OutFile ) - $LiveKD = "C:\livekd64.exe" - $KD = "C:\kd.exe" + $LiveKD = Get-CoreNetCiArtifactPath -Name "livekd64.exe" + $KD = Get-CoreNetCiArtifactPath -Name "kd.exe" Write-Host "Capturing live kernel dump to $OutFile" @@ -150,7 +166,7 @@ function Collect-ProcessDump { [string]$OutFile ) - $ProcDump = "C:\procdump64.exe" + $ProcDump = Get-CoreNetCiArtifactPath -Name "procdump64.exe" Write-Host "Capturing process dump of $ProcessName to $OutFile" @@ -165,7 +181,7 @@ function Initiate-Bugcheck { [string]$Code = "0xE2" ) - $NotMyFault = "C:\notmyfault64.exe" + $NotMyFault = Get-CoreNetCiArtifactPath -Name "notmyfault64.exe" Write-Host "$NotMyFault -accepteula -bugcheck $Code" & $NotMyFault -accepteula -bugcheck $Code diff --git a/tools/log.ps1 b/tools/log.ps1 index 612b9d73..d6fb90ec 100644 --- a/tools/log.ps1 +++ b/tools/log.ps1 @@ -75,8 +75,10 @@ $ErrorActionPreference = 'Stop' # Important paths. $RootDir = Split-Path $PSScriptRoot -Parent +. $RootDir\tools\common.ps1 + $ArtifactsDir = "$RootDir\artifacts\bin\$($Arch)_$($Config)" -$TracePdb = "$RootDir\artifacts\corenet-ci-main\vm-setup\tracepdb.exe" +$TracePdb = Get-CoreNetCiArtifactPath -Name "tracepdb.exe" $WprpFile = "$RootDir\tools\xdptrace.wprp" $TmfPath = "$ArtifactsDir\tmfs" $LogsDir = "$RootDir\artifacts\logs" diff --git a/tools/prepare-machine.ps1 b/tools/prepare-machine.ps1 index e003d8cd..9f345eb6 100644 --- a/tools/prepare-machine.ps1 +++ b/tools/prepare-machine.ps1 @@ -80,13 +80,16 @@ $EbpfNugetRestoreDir = "$RootDir/packages/$EbpfNugetVersion" $Reboot = $false function Download-CoreNet-Deps { + $CoreNetCiCommit = Get-CoreNetCiCommit + # Download and extract /~https://github.com/microsoft/corenet-ci. if (!(Test-Path "artifacts")) { mkdir artifacts } - if ($Force -and (Test-Path "artifacts/corenet-ci-main")) { - Remove-Item -Recurse -Force "artifacts/corenet-ci-main" + if ($Force -and (Test-Path "artifacts/corenet-ci-$CoreNetCiCommit")) { + Remove-Item -Recurse -Force "artifacts/corenet-ci-$CoreNetCiCommit" } - if (!(Test-Path "artifacts/corenet-ci-main")) { - Invoke-WebRequest-WithRetry -Uri "/~https://github.com/microsoft/corenet-ci/archive/refs/heads/main.zip" -OutFile "artifacts\corenet-ci.zip" + if (!(Test-Path "artifacts/corenet-ci-$CoreNetCiCommit")) { + Remove-Item -Recurse -Force "artifacts/corenet-ci-*" + Invoke-WebRequest-WithRetry -Uri "/~https://github.com/microsoft/corenet-ci/archive/$CoreNetCiCommit.zip" -OutFile "artifacts\corenet-ci.zip" Expand-Archive -Path "artifacts\corenet-ci.zip" -DestinationPath "artifacts" -Force Remove-Item -Path "artifacts\corenet-ci.zip" } @@ -148,7 +151,7 @@ function Setup-TestSigning { # Installs the XDP certificates. function Install-Certs { - $CodeSignCertPath = "artifacts\CoreNetSignRoot.cer" + $CodeSignCertPath = Get-CoreNetCiArtifactPath -Name "CoreNetSignRoot.cer" if (!(Test-Path $CodeSignCertPath)) { Write-Error "$CodeSignCertPath does not exist!" } @@ -207,8 +210,6 @@ if ($Cleanup) { if ($ForBuild) { Download-CoreNet-Deps Download-eBpf-Nuget - Copy-Item artifacts\corenet-ci-main\vm-setup\CoreNetSignRoot.cer artifacts\CoreNetSignRoot.cer - Copy-Item artifacts\corenet-ci-main\vm-setup\CoreNetSign.pfx artifacts\CoreNetSign.pfx } if ($ForEbpfBuild) { @@ -280,15 +281,6 @@ if ($Cleanup) { Setup-TestSigning Download-CoreNet-Deps Download-Ebpf-Msi - Copy-Item artifacts\corenet-ci-main\vm-setup\CoreNetSignRoot.cer artifacts\CoreNetSignRoot.cer - Copy-Item artifacts\corenet-ci-main\vm-setup\CoreNetSign.pfx artifacts\CoreNetSign.pfx - Copy-Item artifacts\corenet-ci-main\vm-setup\devcon.exe C:\devcon.exe - Copy-Item artifacts\corenet-ci-main\vm-setup\dswdevice.exe C:\dswdevice.exe - Copy-Item artifacts\corenet-ci-main\vm-setup\kd.exe C:\kd.exe - Copy-Item artifacts\corenet-ci-main\vm-setup\livekd64.exe C:\livekd64.exe - Copy-Item artifacts\corenet-ci-main\vm-setup\notmyfault64.exe C:\notmyfault64.exe - Copy-Item artifacts\corenet-ci-main\vm-setup\procdump64.exe C:\procdump64.exe - Copy-Item artifacts\corenet-ci-main\vm-setup\wsario.exe C:\wsario.exe Install-Certs Setup-VcRuntime Setup-VsTest diff --git a/tools/setup.ps1 b/tools/setup.ps1 index 390cec3c..27a6e0d8 100644 --- a/tools/setup.ps1 +++ b/tools/setup.ps1 @@ -55,8 +55,8 @@ $RootDir = Split-Path $PSScriptRoot -Parent # Important paths. $ArtifactsDir = "$RootDir\artifacts\bin\$($Arch)_$($Config)" $LogsDir = "$RootDir\artifacts\logs" -$DevCon = "C:\devcon.exe" -$DswDevice = "C:\dswdevice.exe" +$DevCon = Get-CoreNetCiArtifactPath -Name "devcon.exe" +$DswDevice = Get-CoreNetCiArtifactPath -Name "dswdevice.exe" # File paths. $XdpSys = "$ArtifactsDir\xdp\xdp.sys" diff --git a/tools/sign.ps1 b/tools/sign.ps1 index f9aef23f..9df150f2 100644 --- a/tools/sign.ps1 +++ b/tools/sign.ps1 @@ -24,6 +24,9 @@ param ( Set-StrictMode -Version 'Latest' $ErrorActionPreference = 'Stop' +$RootDir = Split-Path $PSScriptRoot -Parent +. $RootDir\tools\common.ps1 + function Get-WindowsKitTool { param ( [string]$Arch = "x86", @@ -61,9 +64,9 @@ $RootDir = (Split-Path $PSScriptRoot -Parent) $ArtifactsDir = Join-Path $RootDir "artifacts\bin\$($Arch)_$($Config)" # Certificate paths. -$CodeSignCertPath = Join-Path $RootDir "artifacts\CoreNetSignRoot.cer" +$CodeSignCertPath = Get-CoreNetCiArtifactPath -Name "CoreNetSignRoot.cer" if (!(Test-Path $CodeSignCertPath)) { Write-Error "$CodeSignCertPath does not exist!" } -$CertPath = Join-Path $RootDir "artifacts\CoreNetSign.pfx" +$CertPath = Get-CoreNetCiArtifactPath -Name "CoreNetSign.pfx" if (!(Test-Path $CertPath)) { Write-Error "$CertPath does not exist!" } # All the file paths. diff --git a/tools/spinxsk.ps1 b/tools/spinxsk.ps1 index c38de88b..82278539 100644 --- a/tools/spinxsk.ps1 +++ b/tools/spinxsk.ps1 @@ -90,11 +90,13 @@ $ErrorActionPreference = 'Stop' # Important paths. $RootDir = Split-Path $PSScriptRoot -Parent +. $RootDir\tools\common.ps1 + $ArtifactsDir = "$RootDir\artifacts\bin\$($Arch)_$($Config)" $LogsDir = "$RootDir\artifacts\logs" $SpinXsk = "$ArtifactsDir\spinxsk.exe" -$LiveKD = "C:\livekd64.exe" -$KD = "C:\kd.exe" +$LiveKD = Get-CoreNetCiArtifactPath -Name "livekd64.exe" +$KD = Get-CoreNetCiArtifactPath -Name "kd.exe" # Verify all the files are present. if (!(Test-Path $SpinXsk)) { diff --git a/tools/xskperf.ps1 b/tools/xskperf.ps1 index a12da938..e894aea9 100644 --- a/tools/xskperf.ps1 +++ b/tools/xskperf.ps1 @@ -124,8 +124,10 @@ function Wait-NetAdapterUpStatus { } $RootDir = Split-Path $PSScriptRoot -Parent +. $RootDir\tools\common.ps1 + $ArtifactsDir = "$RootDir\artifacts\bin\$($Arch)_$($Config)" -$WsaRio = "C:\wsario.exe" +$WsaRio = Get-CoreNetCiArtifactPath -Name "wsario.exe" $Mode = $Mode.ToUpper() $Adapter = Get-NetAdapter $AdapterName $AdapterIndex = $Adapter.ifIndex