Skip to content

Commit

Permalink
Merge pull request #684 from microsoft/libtemplateUpdate
Browse files Browse the repository at this point in the history
Merge latest Library.Template
  • Loading branch information
AArnott authored Sep 2, 2022
2 parents 5a9d94a + 94caea8 commit 54c1ad1
Show file tree
Hide file tree
Showing 43 changed files with 681 additions and 259 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0.200-focal
FROM mcr.microsoft.com/dotnet/sdk:6.0.300-focal

# Installing mono makes `dotnet test` work without errors even for net472.
# But installing it takes a long time, so it's excluded by default.
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ _TeamCity*
# Visual Studio code coverage results
*.coverage
*.coveragexml
/coveragereport/

# NCrunch
_NCrunch_*
Expand Down
41 changes: 0 additions & 41 deletions Apply-Template.ps1

This file was deleted.

4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.5.108" PrivateAssets="all" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.5.109" PrivateAssets="all" />
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="all" />
<!-- Use the Unstable package ID so that update tools will help us keep it current even though it seems to be ever-unstable lately. -->
<PackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.435" PrivateAssets="all" />
Expand Down Expand Up @@ -80,7 +80,7 @@
It's also not necessary to generate these assets.
-->
<PropertyGroup Condition="'$(IsWpfTempProject)' == 'true'">
<_WpfTempProjectNuGetFilePathNoExt>$(RepoRootPath)obj\$(_TargetAssemblyProjectName)\$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g</_WpfTempProjectNuGetFilePathNoExt>
<_WpfTempProjectNuGetFilePathNoExt>$(BaseIntermediateOutputPath)..\$(_TargetAssemblyProjectName)\$(_TargetAssemblyProjectName)$(MSBuildProjectExtension).nuget.g</_WpfTempProjectNuGetFilePathNoExt>

<EnableSourceLink>false</EnableSourceLink>
<EmbedUntrackedSources>false</EmbedUntrackedSources>
Expand Down
26 changes: 13 additions & 13 deletions SUPPORT.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Support

## How to file issues and get help

This project uses GitHub Issues to track bugs and feature requests. Please search the existing
issues before filing new issues to avoid duplicates. For new issues, file your bug or
feature request as a new Issue.

For help and questions about using this project, please file a GitHub issue.

## Microsoft Support Policy

Support for this C# projection generator is limited to the resources listed above.
# Support

## How to file issues and get help

This project uses GitHub Issues to track bugs and feature requests. Please search the existing
issues before filing new issues to avoid duplicates. For new issues, file your bug or
feature request as a new Issue.

For help and questions about using this project, please file a GitHub issue.

## Microsoft Support Policy

Support for this C# projection generator is limited to the resources listed above.
7 changes: 6 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,20 @@ parameters:
displayName: Build on macOS
type: boolean
default: false # macOS is often bogged down in Azure Pipelines
- name: RunTests
displayName: Run tests
type: boolean
default: true

variables:
TreatWarningsAsErrors: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
BuildConfiguration: Release
# #codecov_token: # Get a new one from https://codecov.io/
NUGET_PACKAGES: $(Agent.TempDirectory)/.nuget/packages
NUGET_PACKAGES: $(Agent.TempDirectory)/.nuget/packages/

jobs:
- template: azure-pipelines/build.yml
parameters:
includeMacOS: ${{ parameters.includeMacOS }}
RunTests: ${{ parameters.RunTests }}
42 changes: 42 additions & 0 deletions azure-pipelines/Convert-PDB.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<#
.SYNOPSIS
Converts between Windows PDB and Portable PDB formats.
.PARAMETER DllPath
The path to the DLL whose PDB is to be converted.
.PARAMETER PdbPath
The path to the PDB to convert. May be omitted if the DLL was compiled on this machine and the PDB is still at its original path.
.PARAMETER OutputPath
The path of the output PDB to write.
#>
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true,Position=0)]
[string]$DllPath,
[Parameter()]
[string]$PdbPath,
[Parameter(Mandatory=$true,Position=1)]
[string]$OutputPath
)

if ($IsMacOS -or $IsLinux) {
Write-Error "This script only works on Windows"
return
}

$version = '1.1.0-beta2-21101-01'
$baseDir = "$PSScriptRoot/../obj/tools"
$pdb2pdbpath = "$baseDir/Microsoft.DiaSymReader.Pdb2Pdb.$version/tools/Pdb2Pdb.exe"
if (-not (Test-Path $pdb2pdbpath)) {
if (-not (Test-Path $baseDir)) { New-Item -Type Directory -Path $baseDir | Out-Null }
$baseDir = (Resolve-Path $baseDir).Path # Normalize it
Write-Verbose "& (& $PSScriptRoot/Get-NuGetTool.ps1) install Microsoft.DiaSymReader.Pdb2Pdb -version $version -PackageSaveMode nuspec -OutputDirectory $baseDir -Source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json | Out-Null"
& (& $PSScriptRoot/Get-NuGetTool.ps1) install Microsoft.DiaSymReader.Pdb2Pdb -version $version -PackageSaveMode nuspec -OutputDirectory $baseDir -Source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json | Out-Null
}

$args = $DllPath,'/out',$OutputPath,'/nowarn','0021'
if ($PdbPath) {
$args += '/pdb',$PdbPath
}

Write-Verbose "$pdb2pdbpath $args"
& $pdb2pdbpath $args
86 changes: 86 additions & 0 deletions azure-pipelines/Get-CodeCovTool.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<#
.SYNOPSIS
Downloads the CodeCov.io uploader tool and returns the path to it.
.PARAMETER AllowSkipVerify
Allows skipping signature verification of the downloaded tool if gpg is not installed.
#>
[CmdletBinding()]
Param(
[switch]$AllowSkipVerify
)

if ($IsMacOS) {
$codeCovUrl = "https://uploader.codecov.io/latest/macos/codecov"
$toolName = 'codecov'
}
elseif ($IsLinux) {
$codeCovUrl = "https://uploader.codecov.io/latest/linux/codecov"
$toolName = 'codecov'
}
else {
$codeCovUrl = "https://uploader.codecov.io/latest/windows/codecov.exe"
$toolName = 'codecov.exe'
}

$shaSuffix = ".SHA256SUM"
$sigSuffix = $shaSuffix + ".sig"

Function Get-FileFromWeb([Uri]$Uri, $OutDir) {
$OutFile = Join-Path $OutDir $Uri.Segments[-1]
if (!(Test-Path $OutFile)) {
Write-Verbose "Downloading $Uri..."
if (!(Test-Path $OutDir)) { New-Item -ItemType Directory -Path $OutDir | Out-Null }
try {
(New-Object System.Net.WebClient).DownloadFile($Uri, $OutFile)
} finally {
# This try/finally causes the script to abort
}
}

$OutFile
}

$toolsPath = & "$PSScriptRoot\Get-TempToolsPath.ps1"
$binaryToolsPath = Join-Path $toolsPath codecov
$testingPath = Join-Path $binaryToolsPath unverified
$finalToolPath = Join-Path $binaryToolsPath $toolName

if (!(Test-Path $finalToolPath)) {
if (Test-Path $testingPath) {
Remove-Item -Recurse -Force $testingPath # ensure we download all matching files
}
$tool = Get-FileFromWeb $codeCovUrl $testingPath
$sha = Get-FileFromWeb "$codeCovUrl$shaSuffix" $testingPath
$sig = Get-FileFromWeb "$codeCovUrl$sigSuffix" $testingPath
$key = Get-FileFromWeb https://keybase.io/codecovsecurity/pgp_keys.asc $testingPath

if ((Get-Command gpg -ErrorAction SilentlyContinue)) {
Write-Host "Importing codecov key" -ForegroundColor Yellow
gpg --import $key
Write-Host "Verifying signature on codecov hash" -ForegroundColor Yellow
gpg --verify $sig $sha
} else {
if ($AllowSkipVerify) {
Write-Warning "gpg not found. Unable to verify hash signature."
} else {
throw "gpg not found. Unable to verify hash signature. Install gpg or add -AllowSkipVerify to override."
}
}

Write-Host "Verifying hash on downloaded tool" -ForegroundColor Yellow
$actualHash = (Get-FileHash -Path $tool -Algorithm SHA256).Hash
$expectedHash = (Get-Content $sha).Split()[0]
if ($actualHash -ne $expectedHash) {
# Validation failed. Delete the tool so we can't execute it.
#Remove-Item $codeCovPath
throw "codecov uploader tool failed signature validation."
}

Copy-Item $tool $finalToolPath

if ($IsMacOS -or $IsLinux) {
chmod u+x $finalToolPath
}
}

return $finalToolPath
9 changes: 7 additions & 2 deletions azure-pipelines/Get-SymbolFiles.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ $PDBs |% {
$BinaryImagePath = $dllPath
} elseif (Test-Path $exePath) {
$BinaryImagePath = $exePath
} else {
Write-Warning "`"$_`" found with no matching binary file."
$BinaryImagePath = $null
}

Write-Output $BinaryImagePath
Write-Output $_.FullName
if ($BinaryImagePath) {
Write-Output $BinaryImagePath
Write-Output $_.FullName
}
}
2 changes: 2 additions & 0 deletions azure-pipelines/Install-NuGetPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ try {
$p = Start-Process $nugetPath $nugetArgs -NoNewWindow -Wait -PassThru
if ($p.ExitCode -ne 0) { throw }
}

Write-Output (Get-ChildItem "$PackagesDir\$PackageId.*")[0].FullName
} finally {
Pop-Location
}
46 changes: 46 additions & 0 deletions azure-pipelines/Merge-CodeCoverage.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env pwsh

<#
.SYNOPSIS
Merges code coverage reports.
.PARAMETER Path
The path(s) to search for Cobertura code coverage reports.
.PARAMETER Format
The format for the merged result. The default is Cobertura
.PARAMETER OutputDir
The directory the merged result will be written to. The default is `coveragereport` in the root of this repo.
#>
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)]
[string[]]$Path,
[ValidateSet('Badges', 'Clover', 'Cobertura', 'CsvSummary', 'Html', 'Html_Dark', 'Html_Light', 'HtmlChart', 'HtmlInline', 'HtmlInline_AzurePipelines', 'HtmlInline_AzurePipelines_Dark', 'HtmlInline_AzurePipelines_Light', 'HtmlSummary', 'JsonSummary', 'Latex', 'LatexSummary', 'lcov', 'MarkdownSummary', 'MHtml', 'PngChart', 'SonarQube', 'TeamCitySummary', 'TextSummary', 'Xml', 'XmlSummary')]
[string]$Format='Cobertura',
[string]$OutputDir=("$PSScriptRoot/../coveragereport")
)

$RepoRoot = [string](Resolve-Path $PSScriptRoot/..)

if (!(Test-Path $RepoRoot/obj/reportgenerator*)) {
dotnet tool install --tool-path $RepoRoot/obj dotnet-reportgenerator-globaltool --version 5.1.9 --configfile $PSScriptRoot/justnugetorg.nuget.config
}

Write-Verbose "Searching $Path for *.cobertura.xml files"
$reports = Get-ChildItem -Recurse $Path -Filter *.cobertura.xml

if ($reports) {
$reports |% { $_.FullName } |% {
# In addition to replacing {reporoot}, we also normalize on one kind of slash so that the report aggregates data for a file whether data was collected on Windows or not.
$xml = [xml](Get-Content -Path $_)
$xml.coverage.packages.package.classes.class |? { $_.filename} |% {
$_.filename = $_.filename.Replace('{reporoot}', $RepoRoot).Replace([IO.Path]::AltDirectorySeparatorChar, [IO.Path]::DirectorySeparatorChar)
}

$xml.Save($_)
}

$Inputs = [string]::join(';', ($reports |% { Resolve-Path -relative $_.FullName }))
& "$RepoRoot/obj/reportgenerator" -reports:"$Inputs" -targetdir:$OutputDir -reporttypes:$Format
} else {
Write-Error "No reports found to merge."
}
10 changes: 10 additions & 0 deletions azure-pipelines/PoliCheckExclusions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<PoliCheckExclusions>
<!--Each of these exclusions is a folder name -if \[name]\exists in the file path, it will be skipped -->
<Exclusion Type="FolderPathFull">NODE_MODULES|.STORE</Exclusion>
<!--Each of these exclusions is a folder name -if any folder or file starts with "\[name]", it will be skipped -->
<!-- <Exclusion Type="FolderPathStart">ABC|XYZ</Exclusion>-->
<!--Each of these file types will be completely skipped for the entire scan -->
<!-- <Exclusion Type="FileType">.ABC|.XYZ</Exclusion>-->
<!--The specified file names will be skipped during the scan regardless which folder they are in -->
<!-- <Exclusion Type="FileName">ABC.TXT|XYZ.CS</Exclusion>-->
</PoliCheckExclusions>
37 changes: 37 additions & 0 deletions azure-pipelines/Publish-Legacy-Symbols.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Param(
[string]$Path
)

$ArtifactStagingFolder = & "$PSScriptRoot/Get-ArtifactsStagingDirectory.ps1"
$ArtifactStagingFolder += '/symbols-legacy'
robocopy $Path $ArtifactStagingFolder /mir /njh /njs /ndl /nfl
$WindowsPdbSubDirName = 'symstore'

Get-ChildItem "$ArtifactStagingFolder\*.pdb" -Recurse |% {
$dllPath = "$($_.Directory)/$($_.BaseName).dll"
$exePath = "$($_.Directory)/$($_.BaseName).exe"
if (Test-Path $dllPath) {
$BinaryImagePath = $dllPath
} elseif (Test-Path $exePath) {
$BinaryImagePath = $exePath
} else {
Write-Warning "`"$_`" found with no matching binary file."
$BinaryImagePath = $null
}

if ($BinaryImagePath) {
# Convert the PDB to legacy Windows PDBs
Write-Host "Converting PDB for $_" -ForegroundColor DarkGray
$WindowsPdbDir = "$($_.Directory.FullName)\$WindowsPdbSubDirName"
if (!(Test-Path $WindowsPdbDir)) { mkdir $WindowsPdbDir | Out-Null }
$legacyPdbPath = "$WindowsPdbDir\$($_.BaseName).pdb"
& "$PSScriptRoot\Convert-PDB.ps1" -DllPath $BinaryImagePath -PdbPath $_ -OutputPath $legacyPdbPath
if ($LASTEXITCODE -ne 0) {
Write-Warning "PDB conversion of `"$_`" failed."
}

Move-Item $legacyPdbPath $_ -Force
}
}

Write-Host "##vso[artifact.upload containerfolder=symbols-legacy;artifactname=symbols-legacy;]$ArtifactStagingFolder"
Loading

0 comments on commit 54c1ad1

Please sign in to comment.