Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script for checking symbol availability #2492

Merged
merged 4 commits into from
Apr 15, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions eng/common/CheckSymbols.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
param(
JohnTortugo marked this conversation as resolved.
Show resolved Hide resolved
[Parameter(Mandatory=$true)][string]$InputPath, # Path to directory where NuGet packages to be checked are stored
[Parameter(Mandatory=$true)][string]$ExtractPath, # Path to where the packages will be extracted during validation
[Parameter(Mandatory=$true)][string]$SymbolToolPath # Path to where dotnet symbol-tool was installed
JohnTortugo marked this conversation as resolved.
Show resolved Hide resolved
)

function ConfirmSymbolsAvailable {
JohnTortugo marked this conversation as resolved.
Show resolved Hide resolved
param(
[string]$PackagePath, # Path to a NuGet package
[string]$OutputPath, # Path to where symbols should be stored
[string]$SymbolToolDirectory # Path to where symbol-tool was installed
JohnTortugo marked this conversation as resolved.
Show resolved Hide resolved
)

# Ensure input file exist
if (!(Test-Path $PackagePath))
{
Write-Error "Input file not exist."
JohnTortugo marked this conversation as resolved.
Show resolved Hide resolved
}

# Extensions for which we'll look for symbols
$RelevantExtensions = @(".dll", ".exe", ".so", ".dylib")
JohnTortugo marked this conversation as resolved.
Show resolved Hide resolved

# How many files are missing symbol information
$MissingSymbols = 0

$PackageId = [System.IO.Path]::GetFileNameWithoutExtension($PackagePath)
$ExtractPath = $OutputPath+$PackageId;
JohnTortugo marked this conversation as resolved.
Show resolved Hide resolved
$SymbolsPath = $OutputPath+$PackageId+".Symbols";

[System.IO.Compression.ZipFile]::ExtractToDirectory($PackagePath, $ExtractPath)
JohnTortugo marked this conversation as resolved.
Show resolved Hide resolved

# Makes easier to reference `symbol tool`
Push-Location $SymbolToolDirectory
Write-Host "Changing directory to $SymbolToolDirectory"

Get-ChildItem -Recurse $ExtractPath |
Where-Object {$RelevantExtensions -contains $_.Extension} |
ForEach-Object {
$FullPath = $_.FullName
$FileName = [System.IO.Path]::GetFileName($FullPath)
$Extension = $_.Extension

# Those below are potential symbol files that the `dotnet symbol` might
# return. Which one will be returned depend on the type of file we are
# checking and which type of file was uploaded.

# The file itself is returned
$SymbolPath = $SymbolsPath+"\"+$FileName

# PDB file for the module
$PdbPath = $SymbolPath.Replace($Extension, ".pdb")

# PDB file for x-generated module
JohnTortugo marked this conversation as resolved.
Show resolved Hide resolved
$NGenPdb = $SymbolPath.Replace($Extension, ".ni.pdb")

# DBG file for a .so library
$SODbg = $SymbolPath.Replace($Extension, ".so.dbg")

# DWARF file for a .dylib
$DylibDwarf = $SymbolPath.Replace($Extension, ".dylib.dwarf")

Write-Host -NoNewLine "`t Checking file $FullPath ... "

.\dotnet-symbol.exe --symbols --modules $FullPath -o $SymbolsPath -d *>$null
JohnTortugo marked this conversation as resolved.
Show resolved Hide resolved

if (Test-Path $PdbPath)
{
$SymbolType = "PDB"
}
elseif (Test-Path $NGenPdb)
JohnTortugo marked this conversation as resolved.
Show resolved Hide resolved
{
$SymbolType = "NGen PDB"
}
elseif (Test-Path $SODbg)
{
$SymbolType = "DBG for SO"
}
elseif (Test-Path $DylibDwarf)
{
$SymbolType = "Dward for Dylib"
}
elseif (Test-Path $SymbolPath)
{
$SymbolType = "Module"
}
else
{
$MissingSymbols++
Write-Host "No symbols found!"
return
}

Write-Host "Symbols [$SymbolType] found."
}

Pop-Location

return $MissingSymbols
}

function CheckSymbols {
param(
# Path to a NuGet packages directory
[string]$PackagesPath,
# Path to where packages will be extracted
[string]$OutputsPath,
# Path to symbol tool install dir
[string]$SymbolToolDir
)

if (Test-Path $OutputsPath)
{
Remove-Item -recurse $OutputsPath
}

Get-ChildItem "$PackagesPath\*.nupkg" |
ForEach-Object {
$FileName = $_.Name
Write-Host "Validating $FileName "
$Status = ConfirmSymbolsAvailable "$PackagesPath\$FileName" $OutputsPath $SymbolToolDir

if ($Status -ne 0)
{
Write-Error "Missing symbols for $Status modules in the package $FileName"
}
}
}

CheckSymbols $InputPath $ExtractPath $SymbolToolPath
4 changes: 4 additions & 0 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/Publish.proj
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@
Text="##vso[artifact.upload containerfolder=ReleaseConfigs;artifactname=ReleaseConfigs]$(RepositoryEngineeringDir)common\PublishToSymbolServers.proj"
Importance="high" />

<Message
Text="##vso[artifact.upload containerfolder=ReleaseConfigs;artifactname=ReleaseConfigs]$(RepositoryEngineeringDir)common\CheckSymbols.ps1"
Importance="high" />

</Target>

<Target Name="PublishSymbols">
Expand Down