Apply Library.Template pattern

This commit is contained in:
Andrew Arnott 2019-10-10 14:47:39 -06:00
Родитель b3925e829a
Коммит b874e3cd9a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: A9B9910CDCCDA441
43 изменённых файлов: 984 добавлений и 364 удалений

Просмотреть файл

@ -15,23 +15,4 @@ variables:
NUGET_PACKAGES: $(Agent.TempDirectory)/.nuget/packages
jobs:
- job: Windows
pool: Hosted Windows 2019 with VS2019
steps:
- template: azure-pipelines/build.yml
- job: Linux
pool:
vmImage: Ubuntu 16.04
steps:
- template: azure-pipelines/testfx.yml
parameters:
projectdirectory: src/Microsoft.VisualStudio.Threading.Tests
- job: macOS
pool:
vmImage: macOS 10.13
steps:
- template: azure-pipelines/testfx.yml
parameters:
projectdirectory: src/Microsoft.VisualStudio.Threading.Tests
- template: azure-pipelines/build.yml

Просмотреть файл

@ -18,10 +18,13 @@
[string]$OutputPath
)
$version = '1.1.0-beta1-63314-01'
$pdb2pdbpath = "$env:temp\pdb2pdb.$version\tools\Pdb2Pdb.exe"
$version = '1.1.0-beta1-64128-01'
$baseDir = "$PSScriptRoot\..\obj\tools"
$pdb2pdbpath = "$baseDir\pdb2pdb.$version\tools\Pdb2Pdb.exe"
if (-not (Test-Path $pdb2pdbpath)) {
nuget install pdb2pdb -version $version -PackageSaveMode nuspec -OutputDirectory $env:temp -Source https://dotnet.myget.org/F/symreader-converter/api/v3/index.json
if (-not (Test-Path $baseDir)) { New-Item -Type Directory -Path $baseDir | Out-Null }
$baseDir = (Resolve-Path $baseDir).Path # Normalize it
& (& $PSScriptRoot\Get-NuGetTool.ps1) install pdb2pdb -version $version -PackageSaveMode nuspec -OutputDirectory $baseDir -Source https://dotnet.myget.org/F/symreader-converter/api/v3/index.json | Out-Null
}
$args = $DllPath,'/out',$OutputPath,'/nowarn','0021'
@ -29,5 +32,6 @@
$args += '/pdb',$PdbPath
}
& "$env:temp\pdb2pdb.$version\tools\Pdb2Pdb.exe" $args
Write-Verbose "$pdb2pdbpath $args"
& $pdb2pdbpath $args
#}

Просмотреть файл

@ -0,0 +1,22 @@
<#
.SYNOPSIS
Downloads the NuGet.exe tool and returns the path to it.
.PARAMETER NuGetVersion
The version of the NuGet tool to acquire.
#>
Param(
[Parameter()]
[string]$NuGetVersion='5.2.0'
)
$toolsPath = & "$PSScriptRoot\Get-TempToolsPath.ps1"
$binaryToolsPath = Join-Path $toolsPath $NuGetVersion
if (!(Test-Path $binaryToolsPath)) { $null = mkdir $binaryToolsPath }
$nugetPath = Join-Path $binaryToolsPath nuget.exe
if (!(Test-Path $nugetPath)) {
Write-Host "Downloading nuget.exe $NuGetVersion..." -ForegroundColor Yellow
(New-Object System.Net.WebClient).DownloadFile("https://dist.nuget.org/win-x86-commandline/v$NuGetVersion/NuGet.exe", $nugetPath)
}
return (Resolve-Path $nugetPath).Path

Просмотреть файл

@ -0,0 +1,13 @@
if ($env:AGENT_TOOLSDIRECTORY) {
$path = "$env:AGENT_TOOLSDIRECTORY\vs-platform\tools"
} elseif ($env:localappdata) {
$path = "$env:localappdata\vs-platform\tools"
} else {
$path = "$PSScriptRoot\..\obj\tools"
}
if (!(Test-Path $path)) {
New-Item -ItemType Directory -Path $Path | Out-Null
}
(Resolve-Path $path).Path

Просмотреть файл

@ -0,0 +1,28 @@
<#
.SYNOPSIS
Gets the path to the nbgv CLI tool, installing it if necessary.
#>
Param(
)
$existingTool = Get-Command "nbgv" -ErrorAction SilentlyContinue
if ($existingTool) {
return $existingTool.Path
}
if ($env:AGENT_TEMPDIRECTORY) {
$toolInstallDir = "$env:AGENT_TEMPDIRECTORY/$env:BUILD_BUILDID"
} else {
$toolInstallDir = "$PSScriptRoot/../obj/tools"
}
$toolPath = "$toolInstallDir/nbgv"
if (!(Test-Path $toolInstallDir)) { New-Item -Path $toolInstallDir -ItemType Directory | Out-Null }
if (!(Get-Command $toolPath -ErrorAction SilentlyContinue)) {
Write-Host "Installing nbgv to $toolInstallDir"
dotnet tool install --tool-path "$toolInstallDir" nbgv --configfile "$PSScriptRoot/justnugetorg.nuget.config" | Out-Null
}
# Normalize the path on the way out.
return (Get-Command $toolPath).Path

Просмотреть файл

@ -0,0 +1,50 @@
<#
.SYNOPSIS
Installs a NuGet package.
.PARAMETER PackageID
The Package ID to install.
.PARAMETER Version
The version of the package to install. If unspecified, the latest stable release is installed.
.PARAMETER Source
The package source feed to find the package to install from.
.PARAMETER PackagesDir
The directory to install the package to. By default, it uses the Packages folder at the root of the repo.
.PARAMETER ConfigFile
The nuget.config file to use. By default, it uses :/nuget.config.
#>
[CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Low')]
Param(
[Parameter(Position=1,Mandatory=$true)]
[string]$PackageId,
[Parameter()]
[string]$Version,
[Parameter()]
[string]$Source,
[Parameter()]
[switch]$Prerelease,
[Parameter()]
[string]$PackagesDir="$PSScriptRoot\..\packages",
[Parameter()]
[string]$ConfigFile="$PSScriptRoot\..\nuget.config",
[Parameter()]
[ValidateSet('Quiet','Normal','Detailed')]
[string]$Verbosity='normal'
)
$nugetPath = & "$PSScriptRoot\Get-NuGetTool.ps1"
try {
Write-Verbose "Installing $PackageId..."
$nugetArgs = "Install",$PackageId,"-OutputDirectory",$PackagesDir,'-ConfigFile',$ConfigFile
if ($Version) { $nugetArgs += "-Version",$Version }
if ($Source) { $nugetArgs += "-FallbackSource",$Source }
if ($Prerelease) { $nugetArgs += "-Prerelease" }
$nugetArgs += '-Verbosity',$Verbosity
if ($PSCmdlet.ShouldProcess($PackageId, 'nuget install')) {
$p = Start-Process $nugetPath $nugetArgs -NoNewWindow -Wait -PassThru
if ($p.ExitCode -ne 0) { throw }
}
} finally {
Pop-Location
}

Просмотреть файл

@ -0,0 +1,39 @@
<#
.SYNOPSIS
Set environment variables in the environment.
Azure Pipeline and CMD environments are considered.
.PARAMETER Variables
A hashtable of variables to be set.
.OUTPUTS
A boolean indicating whether the environment variables can be expected to propagate to the caller's environment.
#>
[CmdletBinding(SupportsShouldProcess=$true)]
Param(
[Parameter(Mandatory=$true, Position=1)]
$Variables
)
if ($Variables.Count -eq 0) {
return $true
}
$cmdInstructions = !$env:TF_BUILD -and $env:PS1UnderCmd -eq '1'
if ($cmdInstructions) {
Write-Warning "Environment variables have been set that will be lost because you're running under cmd.exe"
Write-Host "Environment variables that must be set manually:" -ForegroundColor Blue
}
$Variables.GetEnumerator() |% {
Set-Item -Path env:$($_.Key) -Value $_.Value
# If we're running in Azure Pipelines, set these environment variables
if ($env:TF_BUILD) {
Write-Host "##vso[task.setvariable variable=$($_.Key);]$($_.Value)"
}
if ($cmdInstructions) {
Write-Host "SET $($_.Key)=$($_.Value)"
}
}
return !$cmdInstructions

Просмотреть файл

@ -1,8 +1,14 @@
# This artifact captures everything needed to insert into VS (NuGet packages, insertion metadata, etc.)
# Only collect on Windows agents (Linux agents are missing nuget.exe, and besides we can only sign on Windows).
if ($env:AGENT_OS -and ($env:AGENT_OS -ne 'Windows_NT')) {
Write-Verbose "Skipping VSInsertion artifact since we're not on Windows"
return @{}
}
$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..")
$config = 'Debug'
if ($env:BuildConfiguration) { $config = $env:BuildConfiguration }
if ($env:BUILDCONFIGURATION) { $config = $env:BUILDCONFIGURATION }
$NuGetPackages = "$RepoRoot\bin\Packages\$config\NuGet"
$CoreXTPackages = "$RepoRoot\bin\Packages\$config\CoreXT"
if (-not (Test-Path $NuGetPackages)) { Write-Error "No NuGet packages found. Has a build been run?"; return @{} }
@ -14,7 +20,8 @@ $profilingInputs = [xml](Get-Content -Path "$PSScriptRoot\..\ProfilingInputs.pro
$profilingInputs.Project.ItemGroup.TestStore.Include = "vstsdrop:" + (& "$PSScriptRoot\..\variables\ProfilingInputsDropName.ps1")
$profilingInputs.Save("$ArtifactPath\ProfilingInputs.props")
$version = $(nbgv get-version -p "$RepoRoot\src" -f json | ConvertFrom-Json).NuGetPackageVersion
$nbgv = & "$PSScriptRoot\..\Get-nbgv.ps1"
$version = $(& $nbgv get-version -p "$RepoRoot\src" -f json | ConvertFrom-Json).NuGetPackageVersion
nuget pack "$PSScriptRoot\..\InsertionMetadataPackage.nuspec" -OutputDirectory $CoreXTPackages -BasePath $ArtifactPath -Version $version | Out-Null
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE

Просмотреть файл

@ -11,36 +11,41 @@
# FileInfo objects are also allowed.
$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..")
$ArtifactStagingDirectory = "$RepoRoot\obj\artifacts\"
Function EnsureTrailingSlash($path) {
if ($path.length -gt 0 -and $path[$path.length-1] -ne '\') {
$path = $path + '\'
if ($path.length -gt 0 -and !$path.EndsWith('\') -and !$path.EndsWith('/')) {
$path = $path + [IO.Path]::DirectorySeparatorChar
}
$path
$path.Replace('\', [IO.Path]::DirectorySeparatorChar)
}
Get-ChildItem "$PSScriptRoot\*.ps1" -Exclude "_*" -Recurse |% {
$ArtifactName = $_.BaseName
Write-Host "Collecting files for the $ArtifactName artifact"
(& $_).GetEnumerator() |% {
$BaseDirectory = New-Object Uri ((EnsureTrailingSlash $_.Key), [UriKind]::Absolute)
$_.Value |% {
if ($_.GetType() -eq [IO.FileInfo] -or $_.GetType() -eq [IO.DirectoryInfo]) {
$_ = $_.FullName
$fileGroups = & $_
if (!$fileGroups -or $fileGroups.Count -eq 0) {
Write-Warning "No files found for the `"$ArtifactName`" artifact."
} else {
$fileGroups.GetEnumerator() | % {
$BaseDirectory = New-Object Uri ((EnsureTrailingSlash $_.Key), [UriKind]::Absolute)
$_.Value | % {
if ($_.GetType() -eq [IO.FileInfo] -or $_.GetType() -eq [IO.DirectoryInfo]) {
$_ = $_.FullName
}
$artifact = New-Object -TypeName PSObject
Add-Member -InputObject $artifact -MemberType NoteProperty -Name ArtifactName -Value $ArtifactName
$SourceFullPath = New-Object Uri ($BaseDirectory, $_)
Add-Member -InputObject $artifact -MemberType NoteProperty -Name Source -Value $SourceFullPath.LocalPath
$RelativePath = [Uri]::UnescapeDataString($BaseDirectory.MakeRelative($SourceFullPath))
Add-Member -InputObject $artifact -MemberType NoteProperty -Name ContainerFolder -Value (Split-Path $RelativePath)
Write-Output $artifact
}
$artifact = New-Object -TypeName PSObject
Add-Member -InputObject $artifact -MemberType NoteProperty -Name ArtifactName -Value $ArtifactName
$SourceFullPath = New-Object Uri ($BaseDirectory, $_)
Add-Member -InputObject $artifact -MemberType NoteProperty -Name Source -Value $SourceFullPath.LocalPath
$RelativePath = [Uri]::UnescapeDataString($BaseDirectory.MakeRelative($SourceFullPath))
Add-Member -InputObject $artifact -MemberType NoteProperty -Name ContainerFolder -Value (Split-Path $RelativePath)
Write-Output $artifact
}
}
}

Просмотреть файл

@ -1,10 +1,13 @@
# This script translates all the artifacts described by _all.ps1
# into commands that instruct VSTS to actually collect those artifacts.
# into commands that instruct Azure Pipelines to actually collect those artifacts.
param (
[string]$ArtifactNameSuffix
)
$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..")
if (!$env:BuildConfiguration) { throw "BuildConfiguration environment variable must be set." }
if ($env:Build_ArtifactStagingDirectory) {
$ArtifactStagingFolder = $env:Build_ArtifactStagingDirectory
if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) {
$ArtifactStagingFolder = $env:BUILD_ARTIFACTSTAGINGDIRECTORY
} else {
$ArtifactStagingFolder = "$RepoRoot\obj\_artifacts"
if (Test-Path $ArtifactStagingFolder) {
@ -12,24 +15,41 @@ if ($env:Build_ArtifactStagingDirectory) {
}
}
function mklink {
cmd /c mklink $args
function Create-SymbolicLink {
param (
$Link,
$Target
)
if ($Link -eq $Target) {
return
}
if (Test-Path $Link) { Remove-Item $Link }
$LinkContainer = Split-Path $Link -Parent
if (!(Test-Path $LinkContainer)) { mkdir $LinkContainer }
Write-Verbose "Linking $Link to $Target"
if ($IsMacOS -or $IsLinux) {
ln $Target $Link
} else {
cmd /c mklink $Link $Target
}
}
# Stage all artifacts
$Artifacts = & "$PSScriptRoot\_all.ps1"
$Artifacts |% {
$DestinationFolder = (Join-Path (Join-Path $ArtifactStagingFolder $_.ArtifactName) $_.ContainerFolder).TrimEnd('\')
$Name = Split-Path $_.Source -Leaf
$DestinationFolder = (Join-Path (Join-Path $ArtifactStagingFolder "$($_.ArtifactName)$ArtifactNameSuffix") $_.ContainerFolder).TrimEnd('\')
$Name = "$(Split-Path $_.Source -Leaf)"
#Write-Host "$($_.Source) -> $($_.ArtifactName)\$($_.ContainerFolder)" -ForegroundColor Yellow
if (-not (Test-Path $DestinationFolder)) { New-Item -ItemType Directory -Path $DestinationFolder | Out-Null }
if (Test-Path -PathType Leaf $_.Source) { # skip folders
mklink "$DestinationFolder\$Name" $_.Source
Create-SymbolicLink -Link "$DestinationFolder\$Name" -Target $_.Source
}
}
$Artifacts |% { $_.ArtifactName } | Get-Unique |% {
Write-Host "##vso[artifact.upload containerfolder=$_;artifactname=$_;]$ArtifactStagingFolder\$_"
Write-Host "##vso[artifact.upload containerfolder=$_$ArtifactNameSuffix;artifactname=$_$ArtifactNameSuffix;]$ArtifactStagingFolder/$_$ArtifactNameSuffix"
}

Просмотреть файл

@ -0,0 +1,12 @@
if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) {
$artifactsRoot = $env:BUILD_ARTIFACTSTAGINGDIRECTORY
} else {
$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..")
$artifactsRoot = "$RepoRoot\bin"
}
if (!(Test-Path $artifactsRoot/build_logs)) { return }
@{
"$artifactsRoot/build_logs" = (Get-ChildItem -Recurse "$artifactsRoot/build_logs")
}

Просмотреть файл

@ -0,0 +1,22 @@
$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..")
# Prepare code coverage reports for merging on another machine
if ($env:SYSTEM_DEFAULTWORKINGDIRECTORY) {
Write-Host "Substituting $env:SYSTEM_DEFAULTWORKINGDIRECTORY with `"{reporoot}`""
$reports = Get-ChildItem "$RepoRoot/bin/coverage.cobertura.xml" -Recurse
$reports |% {
$content = Get-Content -Path $_ |% { $_ -Replace [regex]::Escape($env:SYSTEM_DEFAULTWORKINGDIRECTORY), "{reporoot}" }
Set-Content -Path $_ -Value $content -Encoding UTF8
}
} else {
Write-Warning "coverageResults: Azure Pipelines not detected. Machine-neutral token replacement skipped."
}
if (!((Test-Path $RepoRoot\bin) -and (Test-Path $RepoRoot\obj))) { return }
@{
$RepoRoot = (
@(Get-ChildItem "$RepoRoot\bin\coverage.cobertura.xml" -Recurse) +
(Get-ChildItem "$RepoRoot\obj\*.cs" -Recurse)
);
}

Просмотреть файл

@ -0,0 +1,19 @@
$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot/../..")
$BuildConfiguration = $env:BUILDCONFIGURATION
if (!$BuildConfiguration) {
$BuildConfiguration = 'Debug'
}
$result = @{ }
$PackagesRoot = "$RepoRoot/bin/Packages/$BuildConfiguration"
if (Test-Path $PackagesRoot) {
$result[$PackagesRoot] = (Get-ChildItem $PackagesRoot -Recurse)
}
if (Test-Path "$RepoRoot/bin/SosThreadingTools") {
$result["$RepoRoot/bin/SosThreadingTools/x86/$BuildConfiguration/net472"] = "$RepoRoot/bin/SosThreadingTools/x86/$BuildConfiguration/net472/SosThreadingTools_x86.dll";
$result["$RepoRoot/bin/SosThreadingTools/x64/$BuildConfiguration/net472"] = "$RepoRoot/bin/SosThreadingTools/x64/$BuildConfiguration/net472/SosThreadingTools_x64.dll";
}
$result

Просмотреть файл

@ -0,0 +1,9 @@
$ObjRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..\obj")
if (!(Test-Path $ObjRoot)) { return }
@{
"$ObjRoot" = (
(Get-ChildItem "$ObjRoot\project.assets.json" -Recurse)
);
}

Просмотреть файл

@ -0,0 +1,64 @@
Function Get-SymbolFiles {
[CmdletBinding()]
param (
[parameter(Mandatory=$true)]
[string]$Path
)
$WindowsPdbSubDirName = "symstore"
$ActivityName = "Collecting symbols from $Path"
Write-Progress -Activity $ActivityName -CurrentOperation "Discovery PDB files"
$PDBs = Get-ChildItem -rec "$Path\*.pdb" |? { $_.FullName -notmatch "unittest|tests|\W$WindowsPdbSubDirName\W" }
Write-Progress -Activity $ActivityName -CurrentOperation "De-duplicating symbols"
$PDBsByHash = @{}
$i = 0
$PDBs |% {
Write-Progress -Activity $ActivityName -CurrentOperation "De-duplicating symbols" -PercentComplete (100 * $i / $PDBs.Length)
$hash = Get-FileHash $_
$i++
Add-Member -InputObject $_ -MemberType NoteProperty -Name Hash -Value $hash.Hash
Write-Output $_
} | Sort-Object CreationTime |% {
# De-dupe based on hash. Prefer the first match so we take the first built copy.
if (-not $PDBsByHash.ContainsKey($_.Hash)) {
$PDBsByHash.Add($_.Hash, $_.FullName)
Write-Output $_
}
} |% {
# Collect the DLLs/EXEs as well.
$dllPath = "$($_.Directory)\$($_.BaseName).dll"
$exePath = "$($_.Directory)\$($_.BaseName).exe"
if (Test-Path $dllPath) {
$BinaryImagePath = $dllPath
} elseif (Test-Path $exePath) {
$BinaryImagePath = $exePath
}
Write-Output $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 }
& "$PSScriptRoot\..\Convert-PDB.ps1" -DllPath $BinaryImagePath -PdbPath $_ -OutputPath "$WindowsPdbDir\$($_.BaseName).pdb"
if ($LASTEXITCODE -ne 0) {
Write-Warning "PDB conversion of `"$_`" failed."
}
Write-Output "$WindowsPdbDir\$($_.BaseName).pdb"
}
}
# This doesn't work off Windows, nor do we need to convert symbols on multiple OS agents
if ($IsMacOS -or $IsLinux) {
return;
}
$BinPath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..\bin")
if (!(Test-Path $BinPath)) { return }
$symbolfiles = Get-SymbolFiles -Path $BinPath | Get-Unique
@{
"$BinPath" = $SymbolFiles;
}

Просмотреть файл

@ -1,101 +0,0 @@
steps:
- task: ms-vseng.MicroBuildShipTasks.7c429315-71ba-4cb3-94bb-f829c95f7915.MicroBuildCodesignVerify@2
displayName: Verify Signed Files
inputs:
TargetFolders: |
$(Build.SourcesDirectory)/bin/Packages/$(BuildConfiguration)/NuGet
- task: MicroBuildCleanup@1
condition: and(succeededOrFailed(), ne(variables['Hosted'], 'true'))
displayName: MicroBuild Cleanup
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
displayName: Component Detection
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
- task: ms-vscs-artifact.build-tasks.artifactDropTask-1.artifactDropTask@0
inputs:
dropServiceURI: https://devdiv.artifacts.visualstudio.com
buildNumber: $(ProfilingInputsDropName)
sourcePath: $(Build.ArtifactStagingDirectory)\OptProf\ProfilingInputs
toLowerCase: false
usePat: false
displayName: Publish to Artifact Services - ProfilingInputs
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
- task: NuGetCommand@2
inputs:
command: push
searchPatternPush: '$(Build.SourcesDirectory)\bin\**\$(BuildConfiguration)\**\*.nupkg;!**\*.symbols.nupkg;!**/VS.*.nupkg'
publishVstsFeed: $(feedGuid)
allowPackageConflicts: true
displayName: Push packages to VSTS feed
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
- powershell: |
$DllPaths = @(
,"bin\Microsoft.VisualStudio.Threading\$(BuildConfiguration)\Microsoft.VisualStudio.Threading.dll"
,"bin\Microsoft.VisualStudio.Threading.Analyzers.CodeFixes\$(BuildConfiguration)\Microsoft.VisualStudio.Threading.Analyzers.dll"
,"bin\Microsoft.VisualStudio.Threading.Analyzers.CodeFixes\$(BuildConfiguration)\Microsoft.VisualStudio.Threading.Analyzers.CodeFixes.dll"
)
Get-ChildItem $DllPaths -rec |% {
$OutputDir = "$($_.Directory.FullName)\symstore"
if (!(Test-Path $OutputDir)) { mkdir $OutputDir | Out-Null }
Write-Host "Converting PDB for $_"
azure-pipelines\Convert-PDB.ps1 -DllPath $_ -OutputPath "$OutputDir\$($_.BaseName).pdb"
}
displayName: Converting portable PDBs to Windows PDBs
- task: CopyFiles@1
inputs:
SourceFolder: bin
Contents: |
Microsoft.VisualStudio.Threading/$(BuildConfiguration)/**/Microsoft.VisualStudio.Threading.dll
Microsoft.VisualStudio.Threading/$(BuildConfiguration)/**/symstore/Microsoft.VisualStudio.Threading.pdb
Microsoft.VisualStudio.Threading.Analyzers.CodeFixes/$(BuildConfiguration)/**/Microsoft.VisualStudio.Threading.Analyzers.dll
Microsoft.VisualStudio.Threading.Analyzers.CodeFixes/$(BuildConfiguration)/**/symstore/Microsoft.VisualStudio.Threading.Analyzers.pdb
Microsoft.VisualStudio.Threading.Analyzers.CodeFixes/$(BuildConfiguration)/**/Microsoft.VisualStudio.Threading.Analyzers.CodeFixes.dll
Microsoft.VisualStudio.Threading.Analyzers.CodeFixes/$(BuildConfiguration)/**/symstore/Microsoft.VisualStudio.Threading.Analyzers.CodeFixes.pdb
AsyncDebugTools/x86/$(BuildConfiguration)/AsyncDebugTools.dll
AsyncDebugTools/x86/$(BuildConfiguration)/AsyncDebugTools.pdb
AsyncDebugTools/x64/$(BuildConfiguration)/AsyncDebugTools.dll
AsyncDebugTools/x64/$(BuildConfiguration)/AsyncDebugTools.pdb
TargetFolder: $(Build.ArtifactStagingDirectory)/symbols
displayName: Collecting symbols artifacts
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: $(Build.ArtifactStagingDirectory)/InsertionOutputs
ArtifactName: InsertionOutputs
ArtifactType: Container
displayName: Publish InsertionOutputs as Azure DevOps artifacts
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: $(Build.ArtifactStagingDirectory)/symbols
ArtifactName: symbols
ArtifactType: Container
displayName: Publish symbols as Azure DevOps artifacts
- task: PublishSymbols@2
inputs:
SymbolsFolder: $(Build.ArtifactStagingDirectory)/symbols
SearchPattern: '**/*.pdb'
IndexSources: false
SymbolServerType: TeamServices
displayName: Publish symbols to symbol server
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
- task: Ref12.ref12-analyze-task.ref12-analyze-task.Ref12Analyze@0
displayName: Ref12 (Codex) Analyze
inputs:
codexoutputroot: $(Build.ArtifactStagingDirectory)\Codex
workflowArguments: |
/sourcesDirectory:$(Build.SourcesDirectory)
/codexRepoUrl:$(Build.Repository.Uri)
/repoName:$(Build.Repository.Name)
/additionalCodexArguments:-bld
/additionalCodexArguments:$(Build.ArtifactStagingDirectory)/build_logs
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
continueOnError: true

Просмотреть файл

@ -1,144 +1,56 @@
steps:
- checkout: self
clean: true
parameters:
windowsPool: Hosted Windows 2019 with VS2019
- task: DotNetCoreInstaller@0
displayName: Install .NET Core SDK 2.2.401
inputs:
packageType: sdk
version: 2.2.401
condition: and(succeeded(), ne(variables['Hosted'], 'true')) # Hosted agents already have this.
jobs:
- job: Windows
pool: ${{ parameters.windowsPool }}
steps:
- checkout: self
clean: true
- template: install-dependencies.yml
- script: |
dotnet tool install --tool-path .. nbgv
..\nbgv cloud
echo ##vso[task.setvariable variable=PATH]%Path%;$(Build.SourcesDirectory)
workingDirectory: src
displayName: Set build number
- powershell: '& (./azure-pipelines/Get-nbgv.ps1) cloud -p src'
displayName: Set build number
- task: PowerShell@2
inputs:
filePath: azure-pipelines\variables\_pipelines.ps1
failOnStderr: true
displayName: Set pipeline variables based on source
- ${{ if eq(variables['system.collectionId'], '011b8bdf-6d56-4f87-be0d-0092136884d9') }}:
- template: microbuild.before.yml
- ${{ if eq(variables['system.collectionId'], '011b8bdf-6d56-4f87-be0d-0092136884d9') }}:
- template: azure-pipeline.microbuild.before.yml
- template: dotnet.yml
- script: dotnet --info
displayName: Show dotnet SDK info
- ${{ if eq(variables['system.collectionId'], '011b8bdf-6d56-4f87-be0d-0092136884d9') }}:
- template: microbuild.after.yml
# We have to use the traditional nuget.exe for restoring since we have vcxproj projects too.
- task: NuGetToolInstaller@0
displayName: Pin nuget.exe version
inputs:
versionSpec: 5.1.x
- job: Linux
pool:
vmImage: Ubuntu 16.04
steps:
- checkout: self
clean: true
- template: install-dependencies.yml
- template: dotnet.yml
- powershell: nuget restore src\Microsoft.VisualStudio.Threading.sln
displayName: Nuget restore packages
- job: macOS
pool:
vmImage: macOS 10.13
steps:
- checkout: self
clean: true
- template: install-dependencies.yml
- template: dotnet.yml
- task: VSBuild@1
inputs:
msbuildArgs: /t:build,pack /m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/msbuild.binlog"
platform: Any CPU
configuration: $(BuildConfiguration)
displayName: Build Visual Studio solution
- task: PowerShell@2
inputs:
filePath: azure-pipelines\artifacts\VSInsertion.ps1
failOnStderr: true
displayName: Build VSInsertion CoreXT nupkg
- task: VSBuild@1
inputs:
msbuildArgs: /t:build /m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/msbuild_x86.binlog"
platform: x86
configuration: $(BuildConfiguration)
displayName: Build SosThreadingTools x86
- task: VSBuild@1
inputs:
msbuildArgs: /t:build /m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/msbuild_x64.binlog"
platform: x64
configuration: $(BuildConfiguration)
displayName: Build SosThreadingTools x64
- task: DotNetCoreCLI@2
displayName: Run tests
inputs:
command: test
projects: '**/*.Tests.csproj'
arguments: --configuration $(BuildConfiguration) --no-build --filter "TestCategory!=FailsInCloudTest" -v n
workingDirectory: src
condition: and(succeeded(), ne(variables['SignType'], 'real'))
- task: CopyFiles@1
inputs:
Contents: |
obj/**/project.assets.json
TargetFolder: $(Build.ArtifactStagingDirectory)/projectAssetsJson
displayName: Collecting project.assets.json artifacts
- job: WrapUp
dependsOn:
- Windows
- Linux
- macOS
pool:
vmImage: Ubuntu 16.04
condition: succeededOrFailed()
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: $(Build.ArtifactStagingDirectory)/projectAssetsJson
ArtifactName: projectAssetsJson
ArtifactType: Container
displayName: Publish projectAssetsJson artifacts
condition: succeededOrFailed()
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: $(Build.ArtifactStagingDirectory)/build_logs
ArtifactName: build_logs
ArtifactType: Container
displayName: Publish build_logs artifacts
condition: succeededOrFailed()
- task: PowerShell@2
inputs:
filePath: azure-pipelines\variables\_pipelines.ps1
failOnStderr: true
displayName: Update pipeline variables based on build outputs
- task: PowerShell@2
inputs:
filePath: azure-pipelines\artifacts\_pipelines.ps1
displayName: Publish artifacts
- task: VSTest@2
displayName: Run tests on .NET Framework (with code coverage)
inputs:
testFiltercriteria: TestCategory!=FailsInCloudTest
searchFolder: $(System.DefaultWorkingDirectory)\bin
testAssemblyVer2: |
**\*tests*.dll
platform: $(BuildPlatform)
configuration: $(BuildConfiguration)
codeCoverageEnabled: true
condition: and(false, succeeded(), ne(variables['SignType'], 'real'))
- ${{ if eq(variables['system.collectionId'], '011b8bdf-6d56-4f87-be0d-0092136884d9') }}:
- template: azure-pipeline.microbuild.after.yml
- task: PowerShell@2
displayName: Collecting deployables
inputs:
targetType: inline
script: |
md $(Build.ArtifactStagingDirectory)/deployables\x86
md $(Build.ArtifactStagingDirectory)/deployables\x64
Get-ChildItem bin\Packages\$(BuildConfiguration)\NuGet\*.nupkg -rec |% { copy $_ $(Build.ArtifactStagingDirectory)\deployables }
copy bin\SosThreadingTools/x86/$(BuildConfiguration)/net472/SosThreadingTools.dll $(Build.ArtifactStagingDirectory)\deployables\x86
copy bin\SosThreadingTools/x86/$(BuildConfiguration)/net472/Microsoft.Diagnostics.Runtime.dll $(Build.ArtifactStagingDirectory)\deployables\x86
copy bin\SosThreadingTools/x64/$(BuildConfiguration)/net472/SosThreadingTools.dll $(Build.ArtifactStagingDirectory)\deployables\x64
copy bin\SosThreadingTools/x64/$(BuildConfiguration)/net472/Microsoft.Diagnostics.Runtime.dll $(Build.ArtifactStagingDirectory)\deployables\x64
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: $(Build.ArtifactStagingDirectory)/deployables
ArtifactName: deployables
ArtifactType: Container
displayName: Publish deployables artifacts
steps:
- checkout: self
clean: true
- template: install-dependencies.yml
parameters:
initArgs: -NoRestore
- template: publish-codecoverage.yml
- template: publish-deployables.yml

Просмотреть файл

@ -0,0 +1,87 @@
steps:
# We use VSBuild instead of "dotnet build" on Windows where MicroBuild tasks have to run (since they don't support MSBuild Core yet).
- task: VSBuild@1
inputs:
msbuildArgs: /t:build,pack /m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/msbuild.binlog"
platform: Any CPU
configuration: $(BuildConfiguration)
displayName: Build Visual Studio solution
condition: eq(variables['Agent.OS'], 'Windows_NT')
- task: VSBuild@1
inputs:
msbuildArgs: /t:build /m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/msbuild_x86.binlog"
platform: x86
configuration: $(BuildConfiguration)
displayName: Build SosThreadingTools x86
condition: eq(variables['Agent.OS'], 'Windows_NT')
- task: VSBuild@1
inputs:
msbuildArgs: /t:build /m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/msbuild_x64.binlog"
platform: x64
configuration: $(BuildConfiguration)
displayName: Build SosThreadingTools x64
condition: eq(variables['Agent.OS'], 'Windows_NT')
- script: dotnet build --no-restore -c $(BuildConfiguration) /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog"
displayName: dotnet build
workingDirectory: src
condition: ne(variables['Agent.OS'], 'Windows_NT')
- script: dotnet pack --no-build -c $(BuildConfiguration) /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/pack.binlog"
displayName: dotnet pack
workingDirectory: src
condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT'))
- task: DotNetCoreCLI@2
displayName: dotnet test -f net472
inputs:
command: test
arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true
testRunTitle: net472-$(Agent.JobName)
workingDirectory: src
condition: eq(variables['Agent.OS'], 'Windows_NT')
- task: DotNetCoreCLI@2
displayName: dotnet test -f netcoreapp2.1
inputs:
command: test
arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true
testRunTitle: netcoreapp2.1-$(Agent.JobName)
workingDirectory: src/Microsoft.VisualStudio.Threading.Tests
# We have to artifically run this script so that the extra .nupkg is produced for variables/InsertConfigValues.ps1 to notice.
- powershell: azure-pipelines\artifacts\VSInsertion.ps1
displayName: Prepare VSInsertion artifact
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
- task: PowerShell@2
inputs:
filePath: azure-pipelines/variables/_pipelines.ps1
failOnStderr: true
displayName: Update pipeline variables based on build outputs
condition: succeededOrFailed()
- task: PowerShell@2
inputs:
filePath: azure-pipelines/artifacts/_pipelines.ps1
arguments: -ArtifactNameSuffix "-$(Agent.JobName)"
displayName: Publish artifacts
condition: succeededOrFailed()
- task: PublishSymbols@2
inputs:
SymbolsFolder: $(Build.ArtifactStagingDirectory)/symbols-Windows
SearchPattern: '**/*.pdb'
IndexSources: false
SymbolServerType: TeamServices
displayName: Publish symbols to symbol server
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), eq(variables['Agent.OS'], 'Windows_NT'))
- bash: bash <(curl -s https://codecov.io/bash)
displayName: Publish code coverage results to codecov.io
condition: ne(variables['codecov_token'], '')
timeoutInMinutes: 3
continueOnError: true

Просмотреть файл

@ -0,0 +1,21 @@
parameters:
initArgs:
steps:
- powershell: |
.\init.ps1 -AccessToken '$(System.AccessToken)' ${{ parameters['initArgs'] }}
dotnet --info
displayName: Install prerequisites
# We have to use the traditional nuget.exe for restoring since we have vcxproj projects too.
- task: NuGetToolInstaller@0
displayName: Pin nuget.exe version
inputs:
versionSpec: 5.1.x
- task: PowerShell@2
inputs:
filePath: azure-pipelines/variables/_pipelines.ps1
failOnStderr: true
displayName: Set pipeline variables based on source

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>

Просмотреть файл

@ -0,0 +1,40 @@
steps:
- task: MicroBuildCleanup@1
condition: succeededOrFailed()
displayName: MicroBuild Cleanup
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
displayName: Component Detection
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
- task: ms-vscs-artifact.build-tasks.artifactDropTask-1.artifactDropTask@0
inputs:
dropServiceURI: https://devdiv.artifacts.visualstudio.com
buildNumber: $(ProfilingInputsDropName)
sourcePath: $(Build.ArtifactStagingDirectory)\OptProf\ProfilingInputs
toLowerCase: false
usePat: false
displayName: Publish to Artifact Services - ProfilingInputs
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
continueOnError: true
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: $(Build.ArtifactStagingDirectory)/InsertionOutputs
ArtifactName: InsertionOutputs
ArtifactType: Container
displayName: Publish InsertionOutputs as Azure DevOps artifacts
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
- task: Ref12.ref12-analyze-task.ref12-analyze-task.Ref12Analyze@0
displayName: Ref12 (Codex) Analyze
inputs:
codexoutputroot: $(Build.ArtifactStagingDirectory)\Codex
workflowArguments: |
/sourcesDirectory:$(Build.SourcesDirectory)
/codexRepoUrl:$(Build.Repository.Uri)
/repoName:$(Build.Repository.Name)
/additionalCodexArguments:-bld
/additionalCodexArguments:$(Build.ArtifactStagingDirectory)/build_logs
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
continueOnError: true

Просмотреть файл

@ -2,8 +2,9 @@ steps:
- task: ms-vseng.MicroBuildTasks.965C8DC6-1483-45C9-B384-5AC75DA1F1A4.MicroBuildOptProfPlugin@4
inputs:
optimizationInputsDropNamePrefix: OptimizationInputs/DevDiv/vs-threading
optimizationInputsDropNamePrefix: OptimizationInputs/DevDiv/vs-streamjsonrpc
getDropNameByDrop: true
ShouldSkipOptimize: $(ShouldSkipOptimize)
displayName: Install OptProf Plugin
- task: MicroBuildSigningPlugin@1
@ -11,4 +12,3 @@ steps:
signType: $(SignType)
zipSources: false
displayName: Install MicroBuild Signing Plugin
condition: and(succeeded(), ne(variables['Hosted'], 'true'))

Просмотреть файл

@ -0,0 +1,31 @@
steps:
- download: current
artifact: coverageResults-Windows
displayName: Download Windows code coverage results
continueOnError: true
- download: current
artifact: coverageResults-Linux
displayName: Download Linux code coverage results
continueOnError: true
- download: current
artifact: coverageResults-macOS
displayName: Download macOS code coverage results
continueOnError: true
- powershell: |
dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool --version 4.2.2 --configfile azure-pipelines/justnugetorg.nuget.config
Copy-Item -Recurse $(Pipeline.Workspace)/coverageResults-Windows/obj/* $(System.DefaultWorkingDirectory)/obj
Write-Host "Substituting {reporoot} with $(System.DefaultWorkingDirectory)"
$reports = Get-ChildItem -Recurse "$(Pipeline.Workspace)/coverage.cobertura.xml"
$reports |% {
$content = Get-Content -Path $_ |% { $_.Replace("{reporoot}", "$(System.DefaultWorkingDirectory)") }
Set-Content -Path $_ -Value $content -Encoding UTF8
}
$Inputs = [string]::join(';', ($reports |% { Resolve-Path -relative $_ }))
obj/reportgenerator -reports:"$Inputs" -targetdir:coveragereport -reporttypes:Cobertura
displayName: Merge coverage
- task: PublishCodeCoverageResults@1
displayName: Publish code coverage results to Azure DevOps
inputs:
codeCoverageTool: cobertura
summaryFileLocation: 'coveragereport/Cobertura.xml'
failIfCoverageEmpty: true

Просмотреть файл

@ -0,0 +1,14 @@
steps:
- download: current
displayName: Download deployables
artifact: deployables-Windows
- task: NuGetCommand@2
displayName: Push packages to CI feed
inputs:
command: push
packagesToPush: $(Pipeline.Workspace)/deployables-Windows/NuGet/*.nupkg
nuGetFeedType: internal
publishVstsFeed: $(ci_feed)
allowPackageConflicts: true
condition: and(succeeded(), eq(variables['push_to_ci'], 'true'), ne(variables['ci_feed'], ''), ne(variables['Build.Reason'], 'PullRequest'))

Просмотреть файл

@ -1,38 +0,0 @@
steps:
- task: UseDotNet@2
displayName: Install .NET Core SDK 2.2.401
inputs:
packageType: sdk
version: 2.2.401
- task: UseDotNet@2
displayName: Install .NET Core 2.1 runtime
inputs:
packageType: runtime
version: 2.1.x
- script: dotnet --info
displayName: Show dotnet SDK info
- script: dotnet restore
displayName: Restore packages
workingDirectory: ${{ parameters.projectdirectory }}
- script: dotnet build --no-restore -v n -c $(BuildConfiguration) /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog"
displayName: Build test
workingDirectory: ${{ parameters.projectdirectory }}
- script: dotnet test -v n -f netcoreapp2.1 -c $(BuildConfiguration) --no-build --filter "TestCategory!=FailsInCloudTest"
displayName: Run tests for netcoreapp2.1 on the .NET Core 2.1 runtime
workingDirectory: ${{ parameters.projectdirectory }}
env:
DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX: 0
RuntimeFrameworkVersion: 2.1
- script: dotnet test -v n -f netcoreapp2.1 -c $(BuildConfiguration) --no-build --filter "TestCategory!=FailsInCloudTest"
displayName: Run tests for netcoreapp2.1 on the .NET Core 2.2 runtime
workingDirectory: ${{ parameters.projectdirectory }}
env:
DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX: 0
RuntimeFrameworkVersion: 2.2

Просмотреть файл

@ -0,0 +1,2 @@
$globalJson = Get-Content -Path "$PSScriptRoot\..\..\global.json" | ConvertFrom-Json
$globalJson.sdk.version

Просмотреть файл

@ -1,12 +0,0 @@
if ($env:ComputerName.StartsWith('factoryvm', [StringComparison]::OrdinalIgnoreCase)) {
Write-Host "Running on hosted queue"
Write-Output $true
} else {
Write-Output $false
}
if ($env:SYSTEM_COLLECTIONID -eq '011b8bdf-6d56-4f87-be0d-0092136884d9') {
Write-Host "Running on official devdiv account: $env:System_TeamFoundationCollectionUri"
} elseif ($env:SYSTEM_COLLECTIONID) {
Write-Host "Running under OSS account: $env:System_TeamFoundationCollectionUri"
}

Просмотреть файл

@ -1,3 +1,4 @@
$nbgv = & "$PSScriptRoot\..\Get-nbgv.ps1"
[string]::join(',',(@{
'MicrosoftVisualStudioThreadingVersion' = & { (nbgv get-version --project "$PSScriptRoot\..\..\src\Microsoft.VisualStudio.Threading" --format json | ConvertFrom-Json).AssemblyVersion };
'MicrosoftVisualStudioThreadingVersion' = & { (& $nbgv get-version --project "$PSScriptRoot\..\..\src\Microsoft.VisualStudio.Threading" --format json | ConvertFrom-Json).AssemblyVersion };
}.GetEnumerator() |% { "$($_.key)=$($_.value)" }))

Просмотреть файл

@ -1,5 +1,3 @@
if ($env:SignType) {
$env:SignType
} elseif ($env:SYSTEM_COLLECTIONID -eq '011b8bdf-6d56-4f87-be0d-0092136884d9') {
if ($env:SYSTEM_COLLECTIONID -eq '011b8bdf-6d56-4f87-be0d-0092136884d9') {
'test'
}

Просмотреть файл

@ -0,0 +1 @@
'MS.VS.Threading'

Просмотреть файл

@ -4,6 +4,7 @@
$vars = @{}
Get-ChildItem "$PSScriptRoot\*.ps1" -Exclude "_*" |% {
Write-Host "Computing $($_.BaseName) variable"
$vars[$_.BaseName] = & $_
}

Просмотреть файл

@ -1,11 +1,11 @@
# This script translates the variables returned by the _all.ps1 script
# into commands that instruct VSTS to actually set those variables for other VSTS tasks to consume.
# into commands that instruct Azure Pipelines to actually set those variables for other pipeline tasks to consume.
# The build or release definition may have set these variables to override
# what the build would do. So only set them if they have not already been set.
(& "$PSScriptRoot\_all.ps1").GetEnumerator() |% {
if (Test-Path -Path "env:$($_.Key)") {
if (Test-Path -Path "env:$($_.Key.ToUpper())") {
Write-Host "Skipping setting $($_.Key) because variable is already set." -ForegroundColor Cyan
} else {
Write-Host "$($_.Key)=$($_.Value)" -ForegroundColor Yellow

Просмотреть файл

@ -0,0 +1,5 @@
if ($env:SIGNTYPE -eq 'Real') {
'09d8d03c-1ac8-456e-9274-4d2364527d99' # VSIDE-RealSigned-Release
} else {
'da484c78-f942-44ef-b197-99e2a1bef53c' # VSIDE-TestSigned-Release
}

Просмотреть файл

@ -1,5 +0,0 @@
if ($env:SignType -eq 'Real') {
'09d8d03c-1ac8-456e-9274-4d2364527d99'
} else {
'da484c78-f942-44ef-b197-99e2a1bef53c'
}

3
init.cmd Normal file
Просмотреть файл

@ -0,0 +1,3 @@
@set PS1UnderCmd=1
powershell.exe -ExecutionPolicy bypass -Command "& '%~dpn0.ps1'" %*
@set PS1UnderCmd=

90
init.ps1 Normal file
Просмотреть файл

@ -0,0 +1,90 @@
<#
.SYNOPSIS
Installs dependencies required to build and test the projects in this repository.
.DESCRIPTION
This MAY not require elevation, as the SDK and runtimes are installed locally to this repo location,
unless `-InstallLocality machine` is specified.
.PARAMETER InstallLocality
A value indicating whether dependencies should be installed locally to the repo or at a per-user location.
Per-user allows sharing the installed dependencies across repositories and allows use of a shared expanded package cache.
Visual Studio will only notice and use these SDKs/runtimes if VS is launched from the environment that runs this script.
Per-repo allows for high isolation, allowing for a more precise recreation of the environment within an Azure Pipelines build.
When using 'repo', environment variables are set to cause the locally installed dotnet SDK to be used.
Per-repo can lead to file locking issues when dotnet.exe is left running as a build server and can be mitigated by running `dotnet build-server shutdown`.
Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it.
.PARAMETER NoPrerequisites
Skips the installation of prerequisite software (e.g. SDKs, tools).
.PARAMETER NoRestore
Skips the package restore step.
.PARAMETER Signing
Install the MicroBuild signing plugin for building test-signed builds on desktop machines.
.PARAMETER OptProf
Install the MicroBuild OptProf plugin for building optimized assemblies on desktop machines.
.PARAMETER AccessToken
An optional access token for authenticating to Azure Artifacts authenticated feeds.
#>
[CmdletBinding(SupportsShouldProcess=$true)]
Param (
[ValidateSet('repo','user','machine')]
[string]$InstallLocality='user',
[Parameter()]
[switch]$NoPrerequisites,
[Parameter()]
[switch]$NoRestore,
[Parameter()]
[switch]$Signing,
[Parameter()]
[switch]$OptProf,
[Parameter()]
[string]$AccessToken
)
if (!$NoPrerequisites) {
& "$PSScriptRoot\tools\Install-NuGetCredProvider.ps1" -AccessToken $AccessToken
& "$PSScriptRoot\tools\Install-DotNetSdk.ps1" -InstallLocality $InstallLocality
}
# Workaround nuget credential provider bug that causes very unreliable package restores on Azure Pipelines
$env:NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS=20
$env:NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS=20
Push-Location $PSScriptRoot
try {
$HeaderColor = 'Green'
if (!$NoRestore) {
Write-Host "Restoring NuGet packages" -ForegroundColor $HeaderColor
dotnet restore src
dotnet restore src /p:platform=x64
dotnet restore src /p:platform=x86
if ($lastexitcode -ne 0) {
throw "Failure while restoring packages."
}
}
$EnvVars = @{}
$InstallNuGetPkgScriptPath = ".\azure-pipelines\Install-NuGetPackage.ps1"
$nugetVerbosity = 'quiet'
if ($Verbose) { $nugetVerbosity = 'normal' }
$MicroBuildPackageSource = 'https://devdiv.pkgs.visualstudio.com/DefaultCollection/_packaging/MicroBuildToolset/nuget/v3/index.json'
if ($Signing) {
Write-Host "Installing MicroBuild signing plugin" -ForegroundColor $HeaderColor
& $InstallNuGetPkgScriptPath MicroBuild.Plugins.Signing -source $MicroBuildPackageSource -Verbosity $nugetVerbosity
$EnvVars['SignType'] = "Test"
}
if ($OptProf) {
Write-Host "Installing MicroBuild OptProf plugin" -ForegroundColor $HeaderColor
& $InstallNuGetPkgScriptPath MicroBuild.Plugins.OptProf -source $MicroBuildPackageSource -Verbosity $nugetVerbosity
$EnvVars['OptProfEnabled'] = '1'
}
& "$PSScriptRoot\azure-pipelines\Set-EnvVars.ps1" -Variables $EnvVars | Out-Null
}
catch {
Write-Error $error[0]
exit $lastexitcode
}
finally {
Pop-Location
}

Просмотреть файл

Просмотреть файл

@ -0,0 +1,8 @@
<Project>
<PropertyGroup Condition=" '$(IsTestProject)' == 'true' ">
<CoverletOutputFormat>cobertura</CoverletOutputFormat>
<Exclude>[xunit.*]*,[Microsoft.CodeAnalysis*]*</Exclude>
<!-- Ensure we preserve each coverlet output file per target framework: https://github.com/tonerdo/coverlet/issues/177 -->
<CoverletOutput>$(OutputPath)/</CoverletOutput>
</PropertyGroup>
</Project>

Просмотреть файл

@ -18,17 +18,18 @@
<ProjectReference Include="..\Microsoft.VisualStudio.Threading\Microsoft.VisualStudio.Threading.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.6.3" />
<PackageReference Include="MicroBuild.Nonshipping" Version="$(MicroBuildVersion)" />
<PackageReference Include="MicroBuild.VisualStudio" Version="$(MicroBuildVersion)" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="1.0.0-beta1.19210.3" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.CodeFix.Testing.XUnit" Version="1.0.0-beta1.19210.3" />
<PackageReference Include="Microsoft.CodeAnalysis" Version="2.8.2" />
<PackageReference Include="Microsoft.VisualStudio.OLE.Interop" Version="7.10.6070" />
<PackageReference Include="Microsoft.VisualStudio.Shell.14.0" Version="14.3.25407" IncludeAssets="runtime" />
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop.11.0" Version="11.0.61030" IncludeAssets="runtime" />
<PackageReference Include="Microsoft.VisualStudio.Shell.Interop.14.0.DesignTime" Version="14.3.25407" IncludeAssets="runtime" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing.XUnit" Version="1.0.0-beta1.19210.3" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic.CodeFix.Testing.XUnit" Version="1.0.0-beta1.19210.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="MicroBuild.Nonshipping" Version="$(MicroBuildVersion)" />
<PackageReference Include="xunit" Version="2.4.1" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="..\Microsoft.VisualStudio.Threading.Analyzers.CodeFixes\build\AdditionalFiles\**" LinkBase="BuiltIn.AdditionalFiles">

Просмотреть файл

@ -29,14 +29,14 @@
</Compile>
</ItemGroup>
<ItemGroup>
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="coverlet.msbuild" Version="2.6.3" />
<PackageReference Include="MicroBuild.Nonshipping" Version="$(MicroBuildVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="Xunit.Combinatorial" Version="1.2.7" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="Xunit.SkippableFact" Version="1.3.12" />
<PackageReference Include="Xunit.StaFact" Version="1.0.11-beta" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="OpenCover" Version="4.6.519" />
<PackageReference Include="MicroBuild.Nonshipping" Version="$(MicroBuildVersion)" />
<PackageReference Include="xunit" Version="2.4.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.VisualStudio.Threading\Microsoft.VisualStudio.Threading.csproj" />

Просмотреть файл

@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<AssemblyName>$(MSBuildProjectName)_$(Platform)</AssemblyName>
<IsPackable>false</IsPackable>
<Platforms>x86;x64</Platforms>
<CodeAnalysisRuleSet>SosThreadingTools.ruleset</CodeAnalysisRuleSet>

196
tools/Install-DotNetSdk.ps1 Normal file
Просмотреть файл

@ -0,0 +1,196 @@
<#
.SYNOPSIS
Installs the .NET SDK specified in the global.json file at the root of this repository,
along with supporting .NET Core runtimes used for testing.
.DESCRIPTION
This MAY not require elevation, as the SDK and runtimes are installed locally to this repo location,
unless `-InstallLocality machine` is specified.
.PARAMETER InstallLocality
A value indicating whether dependencies should be installed locally to the repo or at a per-user location.
Per-user allows sharing the installed dependencies across repositories and allows use of a shared expanded package cache.
Visual Studio will only notice and use these SDKs/runtimes if VS is launched from the environment that runs this script.
Per-repo allows for high isolation, allowing for a more precise recreation of the environment within an Azure Pipelines build.
When using 'repo', environment variables are set to cause the locally installed dotnet SDK to be used.
Per-repo can lead to file locking issues when dotnet.exe is left running as a build server and can be mitigated by running `dotnet build-server shutdown`.
Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it.
#>
[CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Medium')]
Param (
[ValidateSet('repo','user','machine')]
[string]$InstallLocality='user'
)
$DotNetInstallScriptRoot = "$PSScriptRoot/../obj/tools"
if (!(Test-Path $DotNetInstallScriptRoot)) { New-Item -ItemType Directory -Path $DotNetInstallScriptRoot | Out-Null }
$DotNetInstallScriptRoot = Resolve-Path $DotNetInstallScriptRoot
# Look up actual required .NET Core SDK version from global.json
$sdkVersion = & "$PSScriptRoot/../azure-pipelines/variables/DotNetSdkVersion.ps1"
# Search for all .NET Core runtime versions referenced from MSBuild projects and arrange to install them.
$runtimeVersions = @()
Get-ChildItem "$PSScriptRoot\..\src\*.*proj" -Recurse |% {
$projXml = [xml](Get-Content -Path $_)
$targetFrameworks = $projXml.Project.PropertyGroup.TargetFramework
if (!$targetFrameworks) {
$targetFrameworks = $projXml.Project.PropertyGroup.TargetFrameworks
if ($targetFrameworks) {
$targetFrameworks = $targetFrameworks -Split ';'
}
}
$targetFrameworks |? { $_ -match 'netcoreapp(\d+\.\d+)' } |% {
$runtimeVersions += $Matches[1]
}
}
Function Get-FileFromWeb([Uri]$Uri, $OutDir) {
$OutFile = Join-Path $OutDir $Uri.Segments[-1]
if (!(Test-Path $OutFile)) {
Write-Verbose "Downloading $Uri..."
try {
(New-Object System.Net.WebClient).DownloadFile($Uri, $OutFile)
} finally {
# This try/finally causes the script to abort
}
}
$OutFile
}
Function Get-InstallerExe($Version, [switch]$Runtime) {
$sdkOrRuntime = 'Sdk'
if ($Runtime) { $sdkOrRuntime = 'Runtime' }
# Get the latest/actual version for the specified one
if (([Version]$Version).Build -eq -1) {
$versionInfo = -Split (Invoke-WebRequest -Uri "https://dotnetcli.blob.core.windows.net/dotnet/$sdkOrRuntime/$Version/latest.version")
$Version = $versionInfo[-1]
}
Get-FileFromWeb -Uri "https://dotnetcli.blob.core.windows.net/dotnet/$sdkOrRuntime/$Version/dotnet-$($sdkOrRuntime.ToLowerInvariant())-$Version-win-x64.exe" -OutDir "$DotNetInstallScriptRoot"
}
Function Install-DotNet($Version, [switch]$Runtime) {
if ($Runtime) { $sdkSubstring = '' } else { $sdkSubstring = 'SDK ' }
Write-Host "Downloading .NET Core $sdkSubstring$Version..."
$Installer = Get-InstallerExe -Version $Version -Runtime:$Runtime
Write-Host "Installing .NET Core $sdkSubstring$Version..."
cmd /c start /wait $Installer /install /quiet
if ($LASTEXITCODE -ne 0) {
throw "Failure to install .NET Core SDK"
}
}
if ($InstallLocality -eq 'machine') {
if ($IsMacOS -or $IsLinux) {
Write-Error "Installing the .NET Core SDK or runtime at a machine-wide location is only supported by this script on Windows."
exit 1
}
if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) {
Install-DotNet -Version $sdkVersion
}
$runtimeVersions |% {
if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) {
Install-DotNet -Version $_ -Runtime
}
}
return
}
$switches = @(
'-Architecture','x64'
)
$envVars = @{
# For locally installed dotnet, skip first time experience which takes a long time
'DOTNET_SKIP_FIRST_TIME_EXPERIENCE' = 'true';
}
if ($InstallLocality -eq 'repo') {
$DotNetInstallDir = "$DotNetInstallScriptRoot/.dotnet"
} elseif ($env:AGENT_TOOLSDIRECTORY) {
$DotNetInstallDir = "$env:AGENT_TOOLSDIRECTORY/dotnet"
} else {
$DotNetInstallDir = Join-Path $HOME .dotnet
}
Write-Host "Installing .NET Core SDK and runtimes to $DotNetInstallDir" -ForegroundColor Blue
if ($DotNetInstallDir) {
$switches += '-InstallDir',$DotNetInstallDir
$envVars['DOTNET_MULTILEVEL_LOOKUP'] = '0'
$envVars['DOTNET_ROOT'] = $DotNetInstallDir
}
if ($IsMacOS -or $IsLinux) {
$DownloadUri = "https://dot.net/v1/dotnet-install.sh"
$DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.sh"
} else {
$DownloadUri = "https://dot.net/v1/dotnet-install.ps1"
$DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.ps1"
}
if (-not (Test-Path $DotNetInstallScriptPath)) {
Invoke-WebRequest -Uri $DownloadUri -OutFile $DotNetInstallScriptPath
if ($IsMacOS -or $IsLinux) {
chmod +x $DotNetInstallScriptPath
}
}
if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) {
Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches"
} else {
Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches -DryRun"
}
$switches += '-Runtime','dotnet'
$runtimeVersions | Get-Unique |% {
if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) {
Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches"
} else {
Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches -DryRun"
}
}
if ($PSCmdlet.ShouldProcess("Set DOTNET environment variables to discover these installed runtimes?")) {
if ($env:TF_BUILD) {
Write-Host "Azure Pipelines detected. Logging commands will be used to propagate environment variables and prepend path."
}
if ($IsMacOS -or $IsLinux) {
$envVars['PATH'] = "${DotNetInstallDir}:$env:PATH"
} else {
$envVars['PATH'] = "$DotNetInstallDir;$env:PATH"
}
$envVars.GetEnumerator() |% {
Set-Item -Path env:$($_.Key) -Value $_.Value
# If we're running in Azure Pipelines, set these environment variables
if ($env:TF_BUILD) {
Write-Host "##vso[task.setvariable variable=$($_.Key);]$($_.Value)"
}
}
if ($env:TF_BUILD) {
Write-Host "##vso[task.prependpath]$DotNetInstallDir"
}
}
if ($env:PS1UnderCmd -eq '1') {
Write-Warning "Environment variable changes will be lost because you're running under cmd.exe. Run these commands manually:"
$envVars.GetEnumerator() |% {
if ($_.Key -eq 'PATH') {
# Special case this one for readability
Write-Host "SET PATH=$DotNetInstallDir;%PATH%"
} else {
Write-Host "SET $($_.Key)=$($_.Value)"
}
}
} else {
Write-Host "Environment variables set:" -ForegroundColor Blue
$envVars
}

Просмотреть файл

@ -0,0 +1,62 @@
<#
.SYNOPSIS
Downloads and installs the Microsoft Artifacts Credential Provider
from https://github.com/microsoft/artifacts-credprovider
to assist in authenticating to Azure Artifact feeds in interactive development
or unattended build agents.
.PARAMETER AccessToken
An optional access token for authenticating to Azure Artifacts authenticated feeds.
#>
[CmdletBinding()]
Param (
[Parameter()]
[string]$AccessToken
)
$toolsPath = & "$PSScriptRoot\..\azure-pipelines\Get-TempToolsPath.ps1"
if ($IsMacOS -or $IsLinux) {
$installerScript = "installcredprovider.sh"
$sourceUrl = "https://raw.githubusercontent.com/microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh"
} else {
$installerScript = "installcredprovider.ps1"
$sourceUrl = "https://raw.githubusercontent.com/microsoft/artifacts-credprovider/master/helpers/installcredprovider.ps1"
}
$installerScript = Join-Path $toolsPath $installerScript
if (!(Test-Path $installerScript)) {
Invoke-WebRequest $sourceUrl -OutFile $installerScript
}
$installerScript = (Resolve-Path $installerScript).Path
if ($IsMacOS -or $IsLinux) {
chmod u+x $installerScript
}
& $installerScript
if ($AccessToken) {
$endpoints = @()
$nugetConfig = [xml](Get-Content -Path "$PSScriptRoot\..\nuget.config")
$nugetConfig.configuration.packageSources.add |? { ($_.value -match '^https://pkgs\.dev\.azure\.com/') -or ($_.value -match '^https://[\w\-]+\.pkgs\.visualstudio\.com/') } |% {
$endpoint = New-Object -TypeName PSObject
Add-Member -InputObject $endpoint -MemberType NoteProperty -Name endpoint -Value $_.value
Add-Member -InputObject $endpoint -MemberType NoteProperty -Name username -Value ado
Add-Member -InputObject $endpoint -MemberType NoteProperty -Name password -Value $AccessToken
$endpoints += $endpoint
}
$auth = New-Object -TypeName PSObject
Add-Member -InputObject $auth -MemberType NoteProperty -Name endpointCredentials -Value $endpoints
$authJson = ConvertTo-Json -InputObject $auth
$envVars = @{
'VSS_NUGET_EXTERNAL_FEED_ENDPOINTS'=$authJson;
}
& "$PSScriptRoot\..\azure-pipelines\Set-EnvVars.ps1" -Variables $envVars | Out-Null
}