-
Notifications
You must be signed in to change notification settings - Fork 0
/
UploadSymbolsToDataCubeSymbolsContainer.ps1
121 lines (93 loc) · 4.61 KB
/
UploadSymbolsToDataCubeSymbolsContainer.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#Requires -Version 3.0
<#
.DESCRIPTION
Upload symbol pdb files to data cube sp-symbols container
.NOTE
You can download symstore from https://go.microsoft.com/fwlink/p/?LinkId=536682
The script relies on Azure PowerShell cmdlets to upload symbol files to Azure storage. You can download it from https://www.microsoft.com/web/handlers/webpi.ashx/getinstaller/WindowsAzurePowershellGet.3f.3f.3fnew.appids
The script also allows utlizing GitLink to update symbol files with source index mapping to your Git host. You can check out https://github.com/GitTools/GitLink for more details.
.EXAMPLE
.\UploadSybmolsToDataCubeSymbolsContainer.ps1 -symstoreExePath "C:\tools\symstore.exe" `
-pdbRootFolder "C:\build\release" `
-workingFolder "C:\working" `
-product "myproduct" `
-dataCubeStorageAccountName "mystorageaccountname" `
-dataCubeStorageAccountKey "mystroageaccountkey" `
-gitLinkExePath "C:\tools\GitLink.exe" `
-gitLinkCommandParameters "C:\source\ -c release"
#>
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true, Position=0)]
[string]$symstoreExePath,
[Parameter(Mandatory=$true, Position=1)]
[string]$pdbRootFolder,
[Parameter(Mandatory=$true, Position=2)]
[string]$workingFolder,
[Parameter(Mandatory=$true, Position=3)]
[string]$product,
[Parameter(Mandatory=$true, Position=4)]
[string]$dataCubeStorageAccountName,
[Parameter(Mandatory=$true, Position=5)]
[string]$dataCubeStorageAccountKey,
[Parameter(Mandatory=$false, Position=6)]
[string]$gitLinkExePath,
[Parameter(Mandatory=$false, Position=7)]
[string]$gitLinkCommandParameters
)
if(!(Test-Path $symstoreExePath))
{
Write-Error "$symstoreExePath doesn't exist."
exit -1
}
# Create a sub working folder each time
$workingFolder = Join-Path $workingFolder $(Get-Date -Format o).Replace(":", "_")
# It's the default data cube symbol container name. Please don't change it.
$symbolContainerName = "sp-symbols"
if($gitLinkExePath -and $gitLinkCommandParameters)
{
# Run Gitlink to index source
Write-Host "$(Get-Date): Start GetLink to index source"
$gitLinkOutputFile = Join-Path $workingFolder "GitLinkOutput.txt"
$process = Start-Process -FilePath $gitLinkExePath -ArgumentList $gitLinkCommandParameters -Wait -PassThru -RedirectStandardOutput $gitLinkOutputFile
if($process.ExitCode -ne 0)
{
Write-Error "GetLink failed as error code: $($process.ExitCode). Output:"
Get-Content $gitLinkOutputFile | Write-Host
exit -1
}
Write-Host "$(Get-Date): Finish GetLink"
}
# Run symstore to index the original pdb files into the working folder
Write-Host "$(Get-Date): Start SymStore"
$pdbFiles = Get-ChildItem -Path $pdbRootFolder -Filter "*.pdb" -Recurse
# You can also filter the pdbs. The following is an simple example of filtering out the pdbs for "Test" assemblies.
# $pdbFiles = Get-ChildItem -Path $pdbRootFolder -Filter "*.pdb" -Recurse | ? {!$_.FullName.Contains("Test")}
foreach ($pdbfile in $pdbFiles)
{
$pdbFilePath = $pdbfile.FullName
Write-Host "Start to index $pdbFilePath"
& $symstoreExePath add /f "$pdbFilePath" /compress /s "$workingFolder" /t "$product" /o
if ($lastexitcode -ne 0)
{
Write-Error "symstore failed as error code: $lastexitcode"
exit -1
}
}
Write-Host "$(Get-Date): Finish SymStore"
# Upload the pdb files to data cube storage sp-symbols container
Write-Host "$(Get-Date): Start Upload"
$storageContext = New-AzureStorageContext -StorageAccountName $dataCubeStorageAccountName -StorageAccountKey $dataCubeStorageAccountKey
if(!(Get-AzureStorageContainer -Name $symbolContainerName -Context $storageContext -ErrorAction Ignore))
{
New-AzureStorageContainer -Name $symbolContainerName -Context $storageContext -ErrorAction Stop
}
$pdbFiles = Get-ChildItem -Path $workingFolder -Filter "*.pd_" -Recurse
foreach ($pdbfile in $pdbFiles)
{
$pdbfilePath = $pdbfile.FullName
$blobName = $pdbfilePath.Substring($workingFolder.Length+1).Replace("\", "/")
Write-Host "Start to upload $pdbfilePath"
Set-AzureStorageBlobContent -Blob $blobName -Container $symbolContainerName -File $pdbfilePath -Context $storageContext -Force -Verbose -ErrorAction Stop
}
Write-Host "$(Get-Date): Finish Upload"