Add VC++ Debug redist deployment to `deploy-ebpf.ps1`. (#2613)

* Add VC++ Debug redist deployment.

* wip

* Update doc.

* indent

* adjust $null checks in all PS scripts

* fix
This commit is contained in:
Gianni Trevisiol 2023-06-23 18:47:59 -07:00 коммит произвёл GitHub
Родитель 62537b4f15
Коммит 020cdad9b8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 38 добавлений и 8 удалений

Просмотреть файл

@ -82,7 +82,7 @@ C:\Windows\system32\msiexec.exe /i eBPF-for-Windows.x.x.x.msi <other options> /l
This method uses a machine that
has already built the binaries for `x64/Debug` or `x64/Release`.
1. Deploy the binaries to `C:\Temp` in your VM, as follows:
1. Deploy the binaries to `C:\Temp` in your VM, as follows (from within a "*Developer PowerShell for VS 2022*"):
- If you **built the binaries from inside the VM**, then from your `ebpf-for-windows` directory in the VM, run:

Просмотреть файл

@ -21,13 +21,10 @@ $source_directory="."
"ebpfnetsh.pdb",
"export_program_info.exe",
"export_program_info.pdb",
"MSVCP140D.dll",
"NetEbpfExt.sys",
"NetEbpfExt.pdb",
"net-ebpf-ext.guid",
"ucrtbased.dll",
"VCRUNTIME140_1D.dll",
"VCRUNTIME140D.dll")
"ucrtbased.dll")
[System.Collections.ArrayList]$built_runtime_jit_files=@(
"ebpfsvc.exe",
@ -212,6 +209,8 @@ $source_directory="."
$destination_directory="C:\Temp"
$error.clear()
$vm="Windows 10 dev environment"
$vc_redist_dir = Join-Path -Path $env:VCToolsRedistDir '\debug_nonredist\x64\Microsoft.VC143.DebugCRT\'
$copy_redist=$false
##
## Process command-line options
@ -249,7 +248,7 @@ OPTIONS:
$vm=($arg -split "=")[1];
break
}
"^(?:-l|--list)(?:=(.+))?$"
"^(?:-l|--local)(?:=(.+))?$"
{
if ($matches[1]) {
$destination_directory = $matches[1]
@ -267,11 +266,13 @@ OPTIONS:
{ @("-t", "--test") -contains $_ }
{
$built_files= $built_runtime_files + $built_test_files
$copy_redist=$true
break
}
{ @("-t", "--jittest") -contains $_ }
{
$built_files= $built_runtime_files + $built_runtime_jit_files + $built_test_files
$copy_redist=$true
break
}
default
@ -297,6 +298,21 @@ if ($vm -eq $null) {
Copy-Item "$source_path" -Destination "$destination_path" -ErrorAction Stop
}
if ($copy_redist) {
Write-Host "Copying the VC++ Redist (Debug) files from `"$vc_redist_dir`" to `"$destination_directory`""
$files = Get-ChildItem -Path $vc_redist_dir -File
foreach ($file in $files) {
$source_path = $file.FullName
$destination_path = Join-Path -Path $destination_directory -ChildPath $file.Name
$destination_full_directory = Split-Path $destination_path -Parent
Write-Host " $source_path -> $destination_path"
if (!(Test-Path $destination_full_directory)) {
New-Item -Type Directory $destination_full_directory -ErrorAction Stop | Write-Verbose
}
Copy-Item -Path $source_path -Destination $destination_path -ErrorAction Stop
}
}
Write-Host "Copying files from `"$source_directory`" to `"$destination_directory`""
foreach ( $file in $source_files ) {
$source_path = "$source_directory\$file"
@ -346,3 +362,17 @@ foreach ( $file in $source_files ) {
exit 1
}
}
if ($copy_redist) {
Write-Host "Copying the VC++ Redist (Debug) files from `"$vc_redist_dir`" to `"$destination_directory`" in VM `"$vm`"..."
$files = Get-ChildItem -Path $vc_redist_dir -File
foreach ($file in $files) {
$source_path = $file.FullName
$destination_path = Join-Path -Path $destination_directory -ChildPath $file.Name
Write-Host " $source_path -> $destination_path"
Copy-VMFile "$vm" -SourcePath "$source_path" -DestinationPath "$destination_path" -CreateFullPath -FileSource Host -Force
if (! $?) {
exit 1
}
}
}

Просмотреть файл

@ -75,7 +75,7 @@ function Invoke-Test
}
# Parse output to check for errors.
if ($null -eq $Output) {
if ($Output -eq $null) {
throw ("No output generated by $TestName.")
}
Out-String -InputObject $Output | Write-Log

Просмотреть файл

@ -94,7 +94,7 @@ if ($Configuration -eq "Release" -and $SkipVerification) {
throw "Invalid parameter. SkipVerification is only supported for Debug builds"
}
if ($null -eq (Get-Command 'msbuild.exe' -ErrorAction SilentlyContinue)) {
if ((Get-Command 'msbuild.exe' -ErrorAction SilentlyContinue) -eq $null) {
throw "Unable to locate msbuild.exe. This command needs to run within a 'Developer Command Prompt'"
}