From 821916a788e9fc8ff9091b8a04ad0f0853c6d5fa Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Thu, 23 Sep 2021 12:52:46 -0700 Subject: [PATCH 1/5] Update the script to include symbolExclusion file --- eng/common/post-build/symbols-validation.ps1 | 72 ++++++++++++-------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/eng/common/post-build/symbols-validation.ps1 b/eng/common/post-build/symbols-validation.ps1 index a5af041ba77..c57726b10ad 100644 --- a/eng/common/post-build/symbols-validation.ps1 +++ b/eng/common/post-build/symbols-validation.ps1 @@ -4,7 +4,8 @@ param( [Parameter(Mandatory = $true)][string] $DotnetSymbolVersion, # Version of dotnet symbol to use [Parameter(Mandatory = $false)][switch] $CheckForWindowsPdbs, # If we should check for the existence of windows pdbs in addition to portable PDBs [Parameter(Mandatory = $false)][switch] $ContinueOnError, # If we should keep checking symbols after an error - [Parameter(Mandatory = $false)][switch] $Clean # Clean extracted symbols directory after checking symbols + [Parameter(Mandatory = $false)][switch] $Clean, # Clean extracted symbols directory after checking symbols + [Parameter(Mandatory = $false)][switch] $SymbolExclusion # Exclude the symbols in the file from publishing to symbol server ) # Maximum number of jobs to run in parallel @@ -25,6 +26,17 @@ if ($CheckForWindowsPdbs) { $WindowsPdbVerificationParam = "--windows-pdbs" } +$ExclusionSet = New-Object System.Collections.Generic.HashSet[string]; + +#Check if the path exists +if(Test-path $SymbolExclusion){ + $Exclusions = Get-Content "$SymbolExclusion" | foreach-object {} + $Exclusions | foreach { if($_ -and $_.Trim()){$ExclusionSet.Add($_)} } +} +else{ + Write-Host "Symbol Exclusion file does not exists.No symbols to exclude." +} + $CountMissingSymbols = { param( [string] $PackagePath, # Path to a NuGet package @@ -142,37 +154,43 @@ $CountMissingSymbols = { return $null } - $FileGuid = New-Guid - $ExpandedSymbolsPath = Join-Path -Path $SymbolsPath -ChildPath $FileGuid - - $SymbolsOnMSDL = & $FirstMatchingSymbolDescriptionOrDefault ` - -FullPath $FileName ` - -TargetServerParam '--microsoft-symbol-server' ` - -SymbolsPath "$ExpandedSymbolsPath-msdl" ` - -WindowsPdbVerificationParam $WindowsPdbVerificationParam - $SymbolsOnSymWeb = & $FirstMatchingSymbolDescriptionOrDefault ` - -FullPath $FileName ` - -TargetServerParam '--internal-server' ` - -SymbolsPath "$ExpandedSymbolsPath-symweb" ` - -WindowsPdbVerificationParam $WindowsPdbVerificationParam - - Write-Host -NoNewLine "`t Checking file " $FileName "... " - - if ($SymbolsOnMSDL -ne $null -and $SymbolsOnSymWeb -ne $null) { - Write-Host "Symbols found on MSDL ($SymbolsOnMSDL) and SymWeb ($SymbolsOnSymWeb)" + if($ExclusionSet -ne $null -and $ExclusionSet.contains($SymbolPath)) + { + Write-Host "Skipping $SymbolPath from symbol validation" } - else { - $MissingSymbols++ - - if ($SymbolsOnMSDL -eq $null -and $SymbolsOnSymWeb -eq $null) { - Write-Host 'No symbols found on MSDL or SymWeb!' + else{ + $FileGuid = New-Guid + $ExpandedSymbolsPath = Join-Path -Path $SymbolsPath -ChildPath $FileGuid + + $SymbolsOnMSDL = & $FirstMatchingSymbolDescriptionOrDefault ` + -FullPath $FileName ` + -TargetServerParam '--microsoft-symbol-server' ` + -SymbolsPath "$ExpandedSymbolsPath-msdl" ` + -WindowsPdbVerificationParam $WindowsPdbVerificationParam + $SymbolsOnSymWeb = & $FirstMatchingSymbolDescriptionOrDefault ` + -FullPath $FileName ` + -TargetServerParam '--internal-server' ` + -SymbolsPath "$ExpandedSymbolsPath-symweb" ` + -WindowsPdbVerificationParam $WindowsPdbVerificationParam + + Write-Host -NoNewLine "`t Checking file " $FileName "... " + + if ($SymbolsOnMSDL -ne $null -and $SymbolsOnSymWeb -ne $null) { + Write-Host "Symbols found on MSDL ($SymbolsOnMSDL) and SymWeb ($SymbolsOnSymWeb)" } else { - if ($SymbolsOnMSDL -eq $null) { - Write-Host 'No symbols found on MSDL!' + $MissingSymbols++ + + if ($SymbolsOnMSDL -eq $null -and $SymbolsOnSymWeb -eq $null) { + Write-Host 'No symbols found on MSDL or SymWeb!' } else { - Write-Host 'No symbols found on SymWeb!' + if ($SymbolsOnMSDL -eq $null) { + Write-Host 'No symbols found on MSDL!' + } + else { + Write-Host 'No symbols found on SymWeb!' + } } } } From a8ccaac91ee54d693bdfe7e75e20d20aecc8eccf Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Thu, 23 Sep 2021 15:29:23 -0700 Subject: [PATCH 2/5] Review comments --- eng/common/post-build/symbols-validation.ps1 | 27 ++++++++++---------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/eng/common/post-build/symbols-validation.ps1 b/eng/common/post-build/symbols-validation.ps1 index c57726b10ad..49876f8e36e 100644 --- a/eng/common/post-build/symbols-validation.ps1 +++ b/eng/common/post-build/symbols-validation.ps1 @@ -5,7 +5,7 @@ param( [Parameter(Mandatory = $false)][switch] $CheckForWindowsPdbs, # If we should check for the existence of windows pdbs in addition to portable PDBs [Parameter(Mandatory = $false)][switch] $ContinueOnError, # If we should keep checking symbols after an error [Parameter(Mandatory = $false)][switch] $Clean, # Clean extracted symbols directory after checking symbols - [Parameter(Mandatory = $false)][switch] $SymbolExclusion # Exclude the symbols in the file from publishing to symbol server + [Parameter(Mandatory = $false)][switch] $SymbolExclusionFile # Exclude the symbols in the file from publishing to symbol server ) # Maximum number of jobs to run in parallel @@ -26,17 +26,6 @@ if ($CheckForWindowsPdbs) { $WindowsPdbVerificationParam = "--windows-pdbs" } -$ExclusionSet = New-Object System.Collections.Generic.HashSet[string]; - -#Check if the path exists -if(Test-path $SymbolExclusion){ - $Exclusions = Get-Content "$SymbolExclusion" | foreach-object {} - $Exclusions | foreach { if($_ -and $_.Trim()){$ExclusionSet.Add($_)} } -} -else{ - Write-Host "Symbol Exclusion file does not exists.No symbols to exclude." -} - $CountMissingSymbols = { param( [string] $PackagePath, # Path to a NuGet package @@ -154,7 +143,19 @@ $CountMissingSymbols = { return $null } - if($ExclusionSet -ne $null -and $ExclusionSet.contains($SymbolPath)) + $ExclusionSet = New-Object System.Collections.Generic.HashSet[string]; + $FileRelativePath = $FileName.Replace("$ExtractPath\", "") + + #Check if the path exists + if(Test-path $SymbolExclusionFile){ + $Exclusions = Get-Content "$SymbolExclusionFile" | foreach-object {} + $Exclusions | foreach { if($_ -and $_.Trim()){$ExclusionSet.Add($_)} } + } + else{ + Write-Host "Symbol Exclusion file does not exists. No symbols to exclude." + } + + if ($ExclusionSet -ne $null -and ($ExclusionSet.Contains($FileRelativePath) -or $ExclusionSet.Contains($FileRelativePath.Replace("\", "/")))) { Write-Host "Skipping $SymbolPath from symbol validation" } From 3290f5167b7accbfbe12d03f7b7e5245c4e4b923 Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Thu, 23 Sep 2021 16:07:58 -0700 Subject: [PATCH 3/5] Revert some change --- eng/common/post-build/symbols-validation.ps1 | 26 ++++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/eng/common/post-build/symbols-validation.ps1 b/eng/common/post-build/symbols-validation.ps1 index 49876f8e36e..7ad5130cf72 100644 --- a/eng/common/post-build/symbols-validation.ps1 +++ b/eng/common/post-build/symbols-validation.ps1 @@ -26,6 +26,18 @@ if ($CheckForWindowsPdbs) { $WindowsPdbVerificationParam = "--windows-pdbs" } +$ExclusionSet = New-Object System.Collections.Generic.HashSet[string]; +$FileRelativePath = $FileName.Replace("$ExtractPath\", "") + +#Check if the path exists +if(Test-path $SymbolExclusionFile){ + $Exclusions = Get-Content "$SymbolExclusionFile" | foreach-object {} + $Exclusions | foreach { if($_ -and $_.Trim()){$ExclusionSet.Add($_)} } +} +else{ + Write-Host "Symbol Exclusion file does not exists. No symbols to exclude." +} + $CountMissingSymbols = { param( [string] $PackagePath, # Path to a NuGet package @@ -143,19 +155,7 @@ $CountMissingSymbols = { return $null } - $ExclusionSet = New-Object System.Collections.Generic.HashSet[string]; - $FileRelativePath = $FileName.Replace("$ExtractPath\", "") - - #Check if the path exists - if(Test-path $SymbolExclusionFile){ - $Exclusions = Get-Content "$SymbolExclusionFile" | foreach-object {} - $Exclusions | foreach { if($_ -and $_.Trim()){$ExclusionSet.Add($_)} } - } - else{ - Write-Host "Symbol Exclusion file does not exists. No symbols to exclude." - } - - if ($ExclusionSet -ne $null -and ($ExclusionSet.Contains($FileRelativePath) -or $ExclusionSet.Contains($FileRelativePath.Replace("\", "/")))) + if (($($using:ExclusionSet) -ne $null) -and ($($using:ExclusionSet).Contains($FileRelativePath) -or ($($using:ExclusionSet).Contains($FileRelativePath.Replace("\", "/"))))) { Write-Host "Skipping $SymbolPath from symbol validation" } From d990a7fed6412762e7bd4d4b68004b0442f30e0d Mon Sep 17 00:00:00 2001 From: Epsitha Ananth <47157394+epananth@users.noreply.github.com> Date: Fri, 24 Sep 2021 13:33:43 -0700 Subject: [PATCH 4/5] Update eng/common/post-build/symbols-validation.ps1 Co-authored-by: Michelle McDaniel --- eng/common/post-build/symbols-validation.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/post-build/symbols-validation.ps1 b/eng/common/post-build/symbols-validation.ps1 index 7ad5130cf72..93281b76d3f 100644 --- a/eng/common/post-build/symbols-validation.ps1 +++ b/eng/common/post-build/symbols-validation.ps1 @@ -5,7 +5,7 @@ param( [Parameter(Mandatory = $false)][switch] $CheckForWindowsPdbs, # If we should check for the existence of windows pdbs in addition to portable PDBs [Parameter(Mandatory = $false)][switch] $ContinueOnError, # If we should keep checking symbols after an error [Parameter(Mandatory = $false)][switch] $Clean, # Clean extracted symbols directory after checking symbols - [Parameter(Mandatory = $false)][switch] $SymbolExclusionFile # Exclude the symbols in the file from publishing to symbol server + [Parameter(Mandatory = $false)][string] $SymbolExclusionFile # Exclude the symbols in the file from publishing to symbol server ) # Maximum number of jobs to run in parallel From d02116b2a402ae88d316b6079f9fdfa8bc87f1ff Mon Sep 17 00:00:00 2001 From: Epsitha Ananth Date: Mon, 18 Oct 2021 12:44:38 -0700 Subject: [PATCH 5/5] updated --- eng/common/post-build/symbols-validation.ps1 | 24 ++++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/eng/common/post-build/symbols-validation.ps1 b/eng/common/post-build/symbols-validation.ps1 index 7ad5130cf72..a4a92efbedf 100644 --- a/eng/common/post-build/symbols-validation.ps1 +++ b/eng/common/post-build/symbols-validation.ps1 @@ -5,9 +5,10 @@ param( [Parameter(Mandatory = $false)][switch] $CheckForWindowsPdbs, # If we should check for the existence of windows pdbs in addition to portable PDBs [Parameter(Mandatory = $false)][switch] $ContinueOnError, # If we should keep checking symbols after an error [Parameter(Mandatory = $false)][switch] $Clean, # Clean extracted symbols directory after checking symbols - [Parameter(Mandatory = $false)][switch] $SymbolExclusionFile # Exclude the symbols in the file from publishing to symbol server + [Parameter(Mandatory = $false)][string] $SymbolExclusionFile # Exclude the symbols in the file from publishing to symbol server ) +. $PSScriptRoot\..\tools.ps1 # Maximum number of jobs to run in parallel $MaxParallelJobs = 16 @@ -27,11 +28,15 @@ if ($CheckForWindowsPdbs) { } $ExclusionSet = New-Object System.Collections.Generic.HashSet[string]; -$FileRelativePath = $FileName.Replace("$ExtractPath\", "") + +if (!$InputPath -or !(Test-Path $InputPath)){ + Write-Host "No symbols to validate." + ExitWithExitCode 0 +} #Check if the path exists -if(Test-path $SymbolExclusionFile){ - $Exclusions = Get-Content "$SymbolExclusionFile" | foreach-object {} +if ($SymbolExclusionFile -and (Test-Path $SymbolExclusionFile)){ + [string[]]$Exclusions = Get-Content "$SymbolExclusionFile" $Exclusions | foreach { if($_ -and $_.Trim()){$ExclusionSet.Add($_)} } } else{ @@ -44,8 +49,6 @@ $CountMissingSymbols = { [string] $WindowsPdbVerificationParam # If we should check for the existence of windows pdbs in addition to portable PDBs ) - . $using:PSScriptRoot\..\tools.ps1 - Add-Type -AssemblyName System.IO.Compression.FileSystem Write-Host "Validating $PackagePath " @@ -155,11 +158,12 @@ $CountMissingSymbols = { return $null } - if (($($using:ExclusionSet) -ne $null) -and ($($using:ExclusionSet).Contains($FileRelativePath) -or ($($using:ExclusionSet).Contains($FileRelativePath.Replace("\", "/"))))) - { - Write-Host "Skipping $SymbolPath from symbol validation" + $FileRelativePath = $FileName.Replace("$ExtractPath\", "") + if (($($using:ExclusionSet) -ne $null) -and ($($using:ExclusionSet).Contains($FileRelativePath) -or ($($using:ExclusionSet).Contains($FileRelativePath.Replace("\", "/"))))){ + Write-Host "Skipping $FileName from symbol validation" } - else{ + + else { $FileGuid = New-Guid $ExpandedSymbolsPath = Join-Path -Path $SymbolsPath -ChildPath $FileGuid