1+ # requires -Module VstsTaskSdk
2+
3+ # VstsTaskSdk is required above for Assert-VstsPath and Get-VstsTaskVariable
4+ # defined in ToolFunctions.ps1 and prefixed by VstsTaskSdk.psd1 which specifies DefaultCommandPrefix = 'Vsts'
5+
6+ # Existing symbol binary layout
7+ # V1 agent
8+ # ...\agent\Worker\Tools\Pdbstr\pdbstr.exe
9+ # ...\agent\Worker\Tools\Symstore\dbghelp.dll
10+ # ...\agent\Worker\Tools\Symstore\srcsrv.dll
11+ # ...\agent\Worker\Tools\Symstore\symsrv.dll
12+ # ...\agent\Worker\Tools\Symstore\symstore.exe
13+ # V2 agent
14+ # ...\agent\externals\pdbstr\pdbstr.exe
15+ # ...\agent\externals\symstore\dbghelp.dll
16+ # ...\agent\externals\symstore\srcsrv.dll
17+ # ...\agent\externals\symstore\symsrv.dll
18+ # ...\agent\externals\symstore\symstore.exe
19+ # New symbol binary layout
20+ # V1 & V2 agent
21+ # ...\tasks\PublishSymbols\{Version}\*.dll
22+ # ...\tasks\PublishSymbols\{Version}\*.exe
23+
24+ # # Ad-hoc test initialization
25+ # node make.js build --task PublishSymbols
26+ # $env:System_Culture = "en-US"
27+ # Import-Module .\_build\Tasks\PublishSymbols\ps_modules\VstsTaskSdk\VstsTaskSdk.psd1
28+ # Import-Module .\_build\Tasks\PublishSymbols\SymbolsCommon.psm1
29+ # Get-Command -Module SymbolsCommon
30+ #
31+ # # Ad-hoc test cleanup
32+ # Remove-Module SymbolsCommon
33+ # Remove-Module VstsTaskSdk
34+ # $env:Agent_HomeDirectory = $null
35+ # $env:PublishSymbols_Debug = $null
36+ # $env:PublishSymbols_UseDbgLkg = $null
37+ # $env:System_Culture = $null
38+ #
39+ # # Ad-hoc test cases
40+ #
41+ # # V2 agent, UseDbgLkg true
42+ # $env:Agent_HomeDirectory = "D:\Downloads\vsts-agent-win7-x64-2.117.1"
43+ # $env:PublishSymbols_Debug = "true"
44+ # $env:PublishSymbols_UseDbgLkg = "true"
45+ # Get-DbghelpPath
46+ # Get-PdbstrPath
47+ # Get-SymStorePath
48+ #
49+ # # V2 agent, UseDbgLkg false
50+ # $env:Agent_HomeDirectory = "D:\Downloads\vsts-agent-win7-x64-2.117.1"
51+ # $env:PublishSymbols_Debug = "true"
52+ # $env:PublishSymbols_UseDbgLkg = $null
53+ # Get-DbghelpPath
54+ # Get-PdbstrPath
55+ # Get-SymStorePath
56+ #
57+ # # V1 agent, UseDbgLkg true
58+ # $env:Agent_HomeDirectory = "\\artifactagent1\C$\B"
59+ # $env:PublishSymbols_Debug = "true"
60+ # $env:PublishSymbols_UseDbgLkg = "true"
61+ # Get-DbghelpPath
62+ # Get-PdbstrPath
63+ # Get-SymStorePath
64+ #
65+ # # V1 agent, UseDbgLkg false
66+ # $env:Agent_HomeDirectory = "\\artifactagent1\C$\B"
67+ # $env:PublishSymbols_Debug = "true"
68+ # $env:PublishSymbols_UseDbgLkg = $null
69+ # Get-DbghelpPath
70+ # Get-PdbstrPath
71+ # Get-SymStorePath
72+
73+ function Get-SymbolBinaryPath
74+ {
75+ [CmdletBinding ()]
76+ param (
77+ # Path relative to task script
78+ [Parameter (Mandatory = $true )]
79+ [string ]$DbgLkgPath ,
80+ # Path relative to Agent.HomeDirectory
81+ [Parameter (Mandatory = $true )]
82+ [string ]$V2AgentPath ,
83+ # Path relative to Agent.HomeDirectory
84+ [Parameter (Mandatory = $true )]
85+ [string ]$V1AgentPath
86+ )
87+
88+ $useDbgLkg = [System.Convert ]::ToBoolean($env: PublishSymbols_UseDbgLkg )
89+ if ($useDbgLkg )
90+ {
91+ # Use the latest symbol binaries as specified by variable "PublishSymbols_UseDbgLkg" in the build definition
92+ $path = [System.IO.Path ]::GetFullPath(" $PSScriptRoot \$DbgLkgPath " )
93+ }
94+ else
95+ {
96+ # Use existing binaries shipped with the agent
97+ $agentRoot = Get-VstsTaskVariable - Name Agent.HomeDirectory - Require
98+ $path = " $agentRoot \$V2AgentPath "
99+ if (-not [System.IO.File ]::Exists($path ))
100+ {
101+ $path = " $agentRoot \$V1AgentPath "
102+ }
103+ }
104+
105+ $debug = [System.Convert ]::ToBoolean($env: PublishSymbols_Debug )
106+ if ($debug )
107+ {
108+ Write-Host " Get-SymbolBinaryPath: $path "
109+ }
110+
111+ Assert-VstsPath - LiteralPath $path - PathType Leaf
112+ return $path
113+ }
114+
115+ function Get-PdbstrPath {
116+ [CmdletBinding ()]
117+ param ()
118+ return Get-SymbolBinaryPath `
119+ - DbgLkgPath " pdbstr.exe" `
120+ - V2AgentPath " externals\pdbstr\pdbstr.exe" `
121+ - V1AgentPath " Agent\Worker\Tools\Pdbstr\pdbstr.exe"
122+ }
123+
124+ function Get-DbghelpPath
125+ {
126+ [CmdletBinding ()]
127+ param ()
128+ return Get-SymbolBinaryPath `
129+ - DbgLkgPath " dbghelp.dll" `
130+ - V2AgentPath " externals\symstore\dbghelp.dll" `
131+ - V1AgentPath " Agent\Worker\Tools\Symstore\dbghelp.dll"
132+ }
133+
134+ function Get-SymStorePath {
135+ [CmdletBinding ()]
136+ param ()
137+ return Get-SymbolBinaryPath `
138+ - DbgLkgPath " symstore.exe" `
139+ - V2AgentPath " externals\symstore\symstore.exe" `
140+ - V1AgentPath " Agent\Worker\Tools\Symstore\symstore.exe"
141+ }
142+
143+ Export-ModuleMember - Function @ (" Get-PdbstrPath" , " Get-DbghelpPath" , " Get-SymStorePath" )
0 commit comments