-
Notifications
You must be signed in to change notification settings - Fork 0
/
Set-VS2010SymbolServer.ps1
276 lines (245 loc) · 11.9 KB
/
Set-VS2010SymbolServer.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#requires -version 2.0
# Wintellect .NET Debugging Code
# (c) 2009 by John Robbins\Wintellect - Do whatever you want to do with it
# as long as you give credit.
<#.SYNOPSIS
Sets up a computer with symbol server values in both the environment and in
VS 2010.
.DESCRIPTION
Sets up both the _NT_SYMBOL_PATH environment variable and Visual Studio 2010
to use a common symbol cache directory as well as common symbol servers.
.PARAMETER Internal
Sets the symbol server to use to \\SYMBOLS\SYMBOLS. Visual Studio will not use
the public symbol servers. This will turn off the .NET Framework Source Stepping
You must specify either -Internal or -Public to the script.
.PARAMETER Public
Sets the symbol server to use as the two public symbol servers from Microsoft.
All the appropriate settings are configured to properly have .NET Reference
Source stepping working.
.PARAMETER CacheDirectory
Defaults to C:\SYMBOLS\PUBLIC for -Public and C:\SYMBOLS\INTERNAL for -Internal.
Note that if -Public is set, the public symbols will go into
<CacheDirectory>\MicrosoftPublicSymbols because Visual Studio 2010 is hard coded to
use that location.
.PARAMETER SymbolServers
A string array of additional symbol servers to use. If -Internal is set, these
additional symbol servers will appear after \\SYMBOLS\SYMBOLS. If -Public is
set, these symbol servers will appear after the public symbol servers so both
the environment variable and Visual Studio have the same search order
#>
[CmdLetBinding(SupportsShouldProcess=$true)]
param ( [switch] $Internal ,
[switch] $Public ,
[string] $CacheDirectory ,
[string[]] $SymbolServers )
# Always make sure all variables are defined.
Set-PSDebug -Strict
# Creates the cache directory if it does not exist.
function CreateCacheDirectory ( [string] $cacheDirectory )
{
if ( ! $(Test-path $cacheDirectory -type "Container" ))
{
if ($PSCmdLet.ShouldProcess("Destination: $cacheDirectory" ,
"Create Directory"))
{
New-Item -type directory -Path $cacheDirectory > $null
}
}
}
function Set-ItemPropertyScript ( $path , $name , $value , $type )
{
if ( $path -eq $null )
{
Write-Error "Set-ItemPropertyScript path param cannot be null!"
exit
}
if ( $name -eq $null )
{
Write-Error "Set-ItemPropertyScript name param cannot be null!"
exit
}
$propString = "Item: " + $path.ToString() + " Property: " + $name
if ($PSCmdLet.ShouldProcess($propString ,"Set Property"))
{
if ($type -eq $null)
{
Set-ItemProperty -Path $path -Name $name -Value $value
}
else
{
Set-ItemProperty -Path $path -Name $name -Value $value -Type $type
}
}
}
# Do the parameter checking.
if ( $Internal -eq $Public )
{
Write-Error "You must specify either -Internal or -Public"
exit
}
# Check if VS is running.
if (Get-Process 'devenv' -ea SilentlyContinue)
{
Write-Error "Visual Studio is running. Please close all instances before running this script"
exit
}
$dbgRegKey = "HKCU:\Software\Microsoft\VisualStudio\10.0\Debugger"
if ( $Internal )
{
$CacheDirectory = "C:\SYMBOLS\INTERNAL"
CreateCacheDirectory $CacheDirectory
# Default to \\SYMBOLS\SYMBOLS and add any additional symbol servers to
# the end of the string.
$symPath = "SRV*$CacheDirectory*\\vsncstor\symbols*\\cpvsbuild\drops\symbols*\\SYMBOLS\SYMBOLS"
$vsPaths = ""
$pathState = ""
for ( $i = 0 ; $i -lt $SymbolServers.Length ; $i++ )
{
$symPath += "*"
$symPath += $SymbolServers[$i]
$vsPaths += $SymbolServers[$i]
$vsPaths += ";"
$pathState += "1"
}
$symPath += ";"
Set-ItemPropertyScript HKCU:\Environment _NT_SYMBOL_PATH $symPath
# Turn off .NET Framework Source stepping.
Set-ItemPropertyScript $dbgRegKey FrameworkSourceStepping 0 DWORD
# Turn off using the Microsoft symbol servers.
Set-ItemPropertyScript $dbgRegKey SymbolUseMSSymbolServers 0 DWORD
# Set the symbol cache dir to the same value as used in the environment
# variable.
Set-ItemPropertyScript $dbgRegKey SymbolCacheDir $CacheDirectory
# Set the VS symbol path to any additional values
Set-ItemPropertyScript $dbgRegKey SymbolPath $vsPaths
# Tell VS that to the additional servers specified.
Set-ItemPropertyScript $dbgRegKey SymbolPathState $pathState
}
else
{
$CacheDirectory = "C:\SYMBOLS\PUBLIC"
CreateCacheDirectory $CacheDirectory
# It's public so we have a little different processing to do. I have to
# add the MicrosoftPublicSymbols as VS hardcodes that onto the path.
# This way both WinDBG and VS are using the same paths for public
# symbols.
$refSrcPath = "$CacheDirectory\MicrosoftPublicSymbols*http://referencesource.microsoft.com/symbols"
$msdlPath = "$CacheDirectory\MicrosoftPublicSymbols*http://msdl.microsoft.com/download/symbols"
$extraPaths = ""
$enabledPDBLocations ="11"
# Poke on any additional symbol servers. I've keeping everything the
# same between VS as WinDBG.
for ( $i = 0 ; $i -lt $SymbolServers.Length ; $i++ )
{
$extraPaths += ";"
$extraPaths += $SymbolServers[$i]
$enabledPDBLocations += "1"
}
$envPath = "SRV*$refSrcPath;SRV*$msdlPath$extraPaths"
Set-ItemPropertyScript HKCU:\Environment _NT_SYMBOL_PATH $envPath
# Turn off Just My Code.
Set-ItemPropertyScript $dbgRegKey JustMyCode 0 DWORD
# Turn on .NET Framework Source stepping.
Set-ItemPropertyScript $dbgRegKey FrameworkSourceStepping 1 DWORD
# Turn on Source Server Support.
Set-ItemPropertyScript $dbgRegKey UseSourceServer 1 DWORD
# Turn on Source Server Diagnostics as that's a good thing. :)
Set-ItemPropertyScript $dbgRegKey ShowSourceServerDiagnostics 1 DWORD
# It's very important to turn off requiring the source to match exactly.
# With this flag on, .NET Reference Source Stepping doesn't work.
Set-ItemPropertyScript $dbgRegKey UseDocumentChecksum 0 DWORD
# Turn on using the Microsoft symbol servers.
Set-ItemPropertyScript $dbgRegKey SymbolUseMSSymbolServers 1 DWORD
# Set the VS SymbolPath setting.
$vsSymPath =" $refSrcPath;$msdlPath$extraPaths"
Set-ItemPropertyScript $dbgRegKey SymbolPath $vsSymPath
# Tell VS that all paths set are active (you see those as check boxes in
# the Options dialog, Debugging\Symbols page).
Set-ItemPropertyScript $dbgRegKey SymbolPathState $enabledPDBLocations
# Set the symbol cache dir to the same value as used in the environment
# variable.
Set-ItemPropertyScript $dbgRegKey SymbolCacheDir $CacheDirectory
}
""
"Please log out to activate the new symbol server settings"
""
# SIG # Begin signature block
# MIIOkQYJKoZIhvcNAQcCoIIOgjCCDn4CAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUAmLSr8rIWV1q8HZNWKDJr9js
# WnKggglnMIIEXDCCA0SgAwIBAgIQT2PQMPgVo6WzRGlABj0WiTANBgkqhkiG9w0B
# AQUFADCBlTELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0
# IExha2UgQ2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYD
# VQQLExhodHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xHTAbBgNVBAMTFFVUTi1VU0VS
# Rmlyc3QtT2JqZWN0MB4XDTA1MDUxNzAwMDAwMFoXDT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