forked from microsoft/vstest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PortableToFullPdb.ps1
79 lines (60 loc) · 2.19 KB
/
PortableToFullPdb.ps1
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
# Copyright (c) Microsoft. All rights reserved.
# Portable to Full PDB conversion script for Test Platform.
[CmdletBinding()]
Param(
[Parameter(Mandatory=$false)]
[ValidateSet("Debug", "Release")]
[System.String] $Configuration = "Release"
)
#
# Variables
#
Write-Verbose "Setup environment variables."
$TP_ROOT_DIR = (Get-Item (Split-Path $MyInvocation.MyCommand.Path)).Parent.FullName
$TP_PACKAGES_DIR = Join-Path $TP_ROOT_DIR "packages"
$TP_OUT_DIR = Join-Path $TP_ROOT_DIR "artifacts"
$PdbConverterToolVersion = "1.1.0-beta1-62316-01"
function Locate-PdbConverterTool
{
$pdbConverter = Join-Path -path $TP_PACKAGES_DIR -ChildPath "Pdb2Pdb\$PdbConverterToolVersion\tools\Pdb2Pdb.exe"
if (!(Test-Path -path $pdbConverter)) {
throw "Unable to locate Pdb2Pdb converter exe in path '$pdbConverter'."
}
Write-Verbose "Pdb2Pdb converter path is : $pdbConverter"
return $pdbConverter
}
function ConvertPortablePdbToWindowsPdb
{
$allPdbs = Get-ChildItem -path $TP_OUT_DIR\$Configuration *.pdb -Recurse | % {$_.FullName}
$portablePdbs = New-Object System.Collections.Generic.List[System.Object]
foreach($pdb in $allPdbs)
{
# First four bytes should be 'BSJB' for portable pdb
$bytes = [char[]](Get-Content $pdb -Encoding byte -TotalCount 4) -join ''
if( $bytes -eq "BSJB")
{
$portablePdbs.Add($pdb)
}
}
$pdbConverter = Locate-PdbConverterTool
foreach($portablePdb in $portablePdbs)
{
# First check if corresponding dll exists
$dllOrExePath = $portablePdb -replace ".pdb",".dll"
if(!(Test-Path -path $dllOrExePath))
{
# If no corresponding dll found, check if exe exists
$dllOrExePath = $portablePdb -replace ".pdb",".exe"
if(!(Test-Path -path $dllOrExePath))
{
throw "Unable to locate dll/exe corresponding to $portablePdb"
}
}
$fullpdb = $portablePdb -replace ".pdb",".pdbfull"
Write-Verbose "$pdbConverter $dll /pdb $portablePdb /out $fullpdb"
& $pdbConverter $dllOrExePath /pdb $portablePdb /out $fullpdb
Remove-Item -Path $portablePdb
}
}
Write-Verbose "Converting Portable pdbs to Windows(Full) Pdbs..."
ConvertPortablePdbToWindowsPdb