44 [Parameter (Mandatory = $true )][string ] $DotnetSymbolVersion , # Version of dotnet symbol to use
55 [Parameter (Mandatory = $false )][switch ] $CheckForWindowsPdbs , # If we should check for the existence of windows pdbs in addition to portable PDBs
66 [Parameter (Mandatory = $false )][switch ] $ContinueOnError , # If we should keep checking symbols after an error
7- [Parameter (Mandatory = $false )][switch ] $Clean # Clean extracted symbols directory after checking symbols
7+ [Parameter (Mandatory = $false )][switch ] $Clean , # Clean extracted symbols directory after checking symbols
8+ [Parameter (Mandatory = $false )][string ] $SymbolExclusionFile # Exclude the symbols in the file from publishing to symbol server
89)
910
11+ . $PSScriptRoot \..\tools.ps1
1012# Maximum number of jobs to run in parallel
1113$MaxParallelJobs = 16
1214
@@ -25,14 +27,28 @@ if ($CheckForWindowsPdbs) {
2527 $WindowsPdbVerificationParam = " --windows-pdbs"
2628}
2729
30+ $ExclusionSet = New-Object System.Collections.Generic.HashSet[string ];
31+
32+ if (! $InputPath -or ! (Test-Path $InputPath )){
33+ Write-Host " No symbols to validate."
34+ ExitWithExitCode 0
35+ }
36+
37+ # Check if the path exists
38+ if ($SymbolExclusionFile -and (Test-Path $SymbolExclusionFile )){
39+ [string []]$Exclusions = Get-Content " $SymbolExclusionFile "
40+ $Exclusions | foreach { if ($_ -and $_.Trim ()){$ExclusionSet.Add ($_ )} }
41+ }
42+ else {
43+ Write-Host " Symbol Exclusion file does not exists. No symbols to exclude."
44+ }
45+
2846$CountMissingSymbols = {
2947 param (
3048 [string ] $PackagePath , # Path to a NuGet package
3149 [string ] $WindowsPdbVerificationParam # If we should check for the existence of windows pdbs in addition to portable PDBs
3250 )
3351
34- . $using :PSScriptRoot \..\tools.ps1
35-
3652 Add-Type - AssemblyName System.IO.Compression.FileSystem
3753
3854 Write-Host " Validating $PackagePath "
@@ -142,37 +158,44 @@ $CountMissingSymbols = {
142158 return $null
143159 }
144160
145- $FileGuid = New-Guid
146- $ExpandedSymbolsPath = Join-Path - Path $SymbolsPath - ChildPath $FileGuid
147-
148- $SymbolsOnMSDL = & $FirstMatchingSymbolDescriptionOrDefault `
149- - FullPath $FileName `
150- - TargetServerParam ' --microsoft-symbol-server' `
151- - SymbolsPath " $ExpandedSymbolsPath -msdl" `
152- - WindowsPdbVerificationParam $WindowsPdbVerificationParam
153- $SymbolsOnSymWeb = & $FirstMatchingSymbolDescriptionOrDefault `
154- - FullPath $FileName `
155- - TargetServerParam ' --internal-server' `
156- - SymbolsPath " $ExpandedSymbolsPath -symweb" `
157- - WindowsPdbVerificationParam $WindowsPdbVerificationParam
158-
159- Write-Host - NoNewLine " `t Checking file " $FileName " ... "
160-
161- if ($SymbolsOnMSDL -ne $null -and $SymbolsOnSymWeb -ne $null ) {
162- Write-Host " Symbols found on MSDL ($SymbolsOnMSDL ) and SymWeb ($SymbolsOnSymWeb )"
161+ $FileRelativePath = $FileName.Replace (" $ExtractPath \" , " " )
162+ if (($ ($using :ExclusionSet ) -ne $null ) -and ($ ($using :ExclusionSet ).Contains($FileRelativePath ) -or ($ ($using :ExclusionSet ).Contains($FileRelativePath.Replace (" \" , " /" ))))){
163+ Write-Host " Skipping $FileName from symbol validation"
163164 }
164- else {
165- $MissingSymbols ++
166165
167- if ($SymbolsOnMSDL -eq $null -and $SymbolsOnSymWeb -eq $null ) {
168- Write-Host ' No symbols found on MSDL or SymWeb!'
166+ else {
167+ $FileGuid = New-Guid
168+ $ExpandedSymbolsPath = Join-Path - Path $SymbolsPath - ChildPath $FileGuid
169+
170+ $SymbolsOnMSDL = & $FirstMatchingSymbolDescriptionOrDefault `
171+ - FullPath $FileName `
172+ - TargetServerParam ' --microsoft-symbol-server' `
173+ - SymbolsPath " $ExpandedSymbolsPath -msdl" `
174+ - WindowsPdbVerificationParam $WindowsPdbVerificationParam
175+ $SymbolsOnSymWeb = & $FirstMatchingSymbolDescriptionOrDefault `
176+ - FullPath $FileName `
177+ - TargetServerParam ' --internal-server' `
178+ - SymbolsPath " $ExpandedSymbolsPath -symweb" `
179+ - WindowsPdbVerificationParam $WindowsPdbVerificationParam
180+
181+ Write-Host - NoNewLine " `t Checking file " $FileName " ... "
182+
183+ if ($SymbolsOnMSDL -ne $null -and $SymbolsOnSymWeb -ne $null ) {
184+ Write-Host " Symbols found on MSDL ($SymbolsOnMSDL ) and SymWeb ($SymbolsOnSymWeb )"
169185 }
170186 else {
171- if ($SymbolsOnMSDL -eq $null ) {
172- Write-Host ' No symbols found on MSDL!'
187+ $MissingSymbols ++
188+
189+ if ($SymbolsOnMSDL -eq $null -and $SymbolsOnSymWeb -eq $null ) {
190+ Write-Host ' No symbols found on MSDL or SymWeb!'
173191 }
174192 else {
175- Write-Host ' No symbols found on SymWeb!'
193+ if ($SymbolsOnMSDL -eq $null ) {
194+ Write-Host ' No symbols found on MSDL!'
195+ }
196+ else {
197+ Write-Host ' No symbols found on SymWeb!'
198+ }
176199 }
177200 }
178201 }
0 commit comments