Merge remote-tracking branch 'origin/master' into microbuild

This commit is contained in:
Andrew Arnott 2020-04-14 08:07:47 -06:00
Родитель 00b940e5c0 ce8a37067b
Коммит 200c8b87b4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: A9B9910CDCCDA441
17 изменённых файлов: 78 добавлений и 76 удалений

8
.github/workflows/build.yml поставляемый
Просмотреть файл

@ -36,7 +36,7 @@ jobs:
./init.ps1 -UpgradePrerequisites
dotnet --info
if ($env:RUNNER_OS -eq "Windows") {
choco install procdump
choco install procdump -y
Write-Host "##[set-env name=PROCDUMP_PATH;]$env:PROGRAMDATA\chocolatey\bin\"
}
shell: pwsh
@ -44,11 +44,11 @@ jobs:
run: azure-pipelines/variables/_pipelines.ps1
shell: pwsh
- name: build
run: dotnet build src --no-restore -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/build.binlog"
run: dotnet build --no-restore -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/build.binlog"
- name: pack
run: dotnet pack src --no-build -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/pack.binlog"
run: dotnet pack --no-build -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"bin/build_logs/pack.binlog"
- name: test
run: dotnet test src --no-build -c ${{ env.BUILDCONFIGURATION }} /bl:"bin/build_logs/test.binlog" --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --logger trx --settings "${{ github.workspace }}/.github/workflows/${{ runner.os }}.runsettings"
run: dotnet test --no-build -c ${{ env.BUILDCONFIGURATION }} /bl:"bin/build_logs/test.binlog" --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --logger trx --settings "${{ github.workspace }}/.github/workflows/${{ runner.os }}.runsettings"
- name: Update pipeline variables based on build outputs
run: azure-pipelines/variables/_pipelines.ps1
shell: pwsh

2
.vscode/extensions.json поставляемый
Просмотреть файл

@ -4,7 +4,7 @@
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"ms-azure-devops.azure-pipelines",
"ms-vscode.csharp",
"ms-dotnettools.csharp",
"k--kato.docomment",
"editorconfig.editorconfig",
"pflannery.vscode-versionlens",

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

@ -76,26 +76,23 @@ try {
}
# Rename project directories and solution
Set-Location src
git mv Library.sln "$LibraryName.sln"
git mv Library/Library.csproj "Library/$LibraryName.csproj"
git mv Library "$LibraryName"
git mv Library.Tests/Library.Tests.csproj "Library.Tests/$LibraryName.Tests.csproj"
git mv Library.Tests "$LibraryName.Tests"
git mv src/Library/Library.csproj "src/Library/$LibraryName.csproj"
git mv src/Library "src/$LibraryName"
git mv src/Library.Tests/Library.Tests.csproj "src/Library.Tests/$LibraryName.Tests.csproj"
git mv src/Library.Tests "src/$LibraryName.Tests"
# Refresh solution file both to update paths and give the projects unique GUIDs
dotnet sln remove Library/Library.csproj
dotnet sln remove Library.Tests/Library.Tests.csproj
dotnet sln add "$LibraryName"
dotnet sln add "$LibraryName.Tests"
dotnet sln remove src/Library/Library.csproj
dotnet sln remove src/Library.Tests/Library.Tests.csproj
dotnet sln add "src/$LibraryName"
dotnet sln add "src/$LibraryName.Tests"
git add "$LibraryName.sln"
# Update project reference in test project. Add before removal to keep the same ItemGroup in place.
dotnet add "$LibraryName.Tests" reference "$LibraryName"
dotnet remove "$LibraryName.Tests" reference Library/Library.csproj
git add "$LibraryName.Tests/$LibraryName.Tests.csproj"
Set-Location ..
dotnet add "src/$LibraryName.Tests" reference "src/$LibraryName"
dotnet remove "src/$LibraryName.Tests" reference src/Library/Library.csproj
git add "src/$LibraryName.Tests/$LibraryName.Tests.csproj"
# Replace placeholders in source files
Replace-Placeholders -Path "src/$LibraryName/Calculator.cs" -Replacements @{

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

@ -3,21 +3,21 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29322.22
MinimumVisualStudioVersion = 15.0.26124.0
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library", "Library\Library.csproj", "{C06D702E-6FC7-453B-BDDF-608F825EC003}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library", "src\Library\Library.csproj", "{C06D702E-6FC7-453B-BDDF-608F825EC003}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library.Tests", "Library.Tests\Library.Tests.csproj", "{DC5F3D1C-A9A3-44B7-A3C0-82C1FF4C3336}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library.Tests", "src\Library.Tests\Library.Tests.csproj", "{DC5F3D1C-A9A3-44B7-A3C0-82C1FF4C3336}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1CE9670B-D5FF-46A7-9D00-24E70E6ED48B}"
ProjectSection(SolutionItems) = preProject
..\.editorconfig = ..\.editorconfig
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
..\global.json = ..\global.json
..\nuget.config = ..\nuget.config
shipping.ruleset = shipping.ruleset
stylecop.json = stylecop.json
tests.ruleset = tests.ruleset
..\version.json = ..\version.json
.editorconfig = .editorconfig
src\Directory.Build.props = src\Directory.Build.props
src\Directory.Build.targets = src\Directory.Build.targets
global.json = global.json
nuget.config = nuget.config
src\shipping.ruleset = src\shipping.ruleset
src\stylecop.json = src\stylecop.json
src\tests.ruleset = src\tests.ruleset
version.json = version.json
EndProjectSection
EndProject
Global

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

@ -9,6 +9,7 @@ trigger:
- doc/
- '*.md'
- .vscode/
- .github/
variables:
TreatWarningsAsErrors: true

2
azure-pipelines/artifacts/_all.ps1 Normal file → Executable file
Просмотреть файл

@ -1,3 +1,5 @@
#!/usr/bin/env pwsh
# This script returns all the artifacts that should be collected after a build.
#
# Each powershell artifact is expressed as an object with these properties:

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

@ -2,7 +2,7 @@ if ($env:AGENT_TEMPDIRECTORY) {
# The DotNetCoreCLI uses an alternate location to publish these files
$guidRegex = '^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$'
@{
$env:AGENT_TEMPDIRECTORY = (Get-ChildItem $env:AGENT_TEMPDIRECTORY -Directory |? { $_.Name -match $guidRegex } |% { Get-ChildItem "$($_.FullName)\testhost.*.dmp","$($_.FullName)\Sequence_*.xml" -Recurse });
$env:AGENT_TEMPDIRECTORY = (Get-ChildItem $env:AGENT_TEMPDIRECTORY -Directory |? { $_.Name -match $guidRegex } |% { Get-ChildItem "$($_.FullName)\testhost*.dmp","$($_.FullName)\Sequence_*.xml" -Recurse });
}
} else {
$srcRoot = Resolve-Path "$PSScriptRoot\..\..\src"

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

@ -10,12 +10,10 @@ steps:
- script: dotnet build --no-restore -c $(BuildConfiguration) /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog"
displayName: dotnet build
workingDirectory: src
condition: and(succeeded(), 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
@ -24,7 +22,6 @@ steps:
command: test
arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings"
testRunTitle: net472-$(Agent.JobName)
workingDirectory: src
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
- task: DotNetCoreCLI@2
@ -33,7 +30,6 @@ steps:
command: test
arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings"
testRunTitle: netcoreapp2.1-$(Agent.JobName)
workingDirectory: src
- task: DotNetCoreCLI@2
displayName: dotnet test -f netcoreapp3.1
@ -41,19 +37,14 @@ steps:
command: test
arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings"
testRunTitle: netcoreapp3.1-$(Agent.JobName)
workingDirectory: src
- task: PowerShell@2
inputs:
filePath: azure-pipelines/variables/_pipelines.ps1
failOnStderr: true
- powershell: 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)"
- powershell: azure-pipelines/artifacts/_pipelines.ps1 -ArtifactNameSuffix "-$(Agent.JobName)"
failOnStderr: true
displayName: Publish artifacts
condition: succeededOrFailed()

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

@ -24,5 +24,4 @@ steps:
- script: dotnet build
displayName: dotnet build (expanded template)
workingDirectory: src
condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT'))

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

@ -4,19 +4,17 @@ parameters:
steps:
- powershell: |
.\init.ps1 -AccessToken '$(System.AccessToken)' ${{ parameters['initArgs'] }} -UpgradePrerequisites
.\init.ps1 ${{ parameters['initArgs'] }} -UpgradePrerequisites
dotnet --info
displayName: Install prerequisites
# The procdump tool and env var is required for dotnet test to collect hang/crash dumps of tests.
- powershell: |
choco install procdump
choco install procdump -y
Write-Host "##vso[task.setvariable variable=PROCDUMP_PATH;]$env:ProgramData\chocolatey\bin\"
displayName: Install procdump
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
- task: PowerShell@2
inputs:
filePath: azure-pipelines/variables/_pipelines.ps1
failOnStderr: true
- powershell: azure-pipelines/variables/_pipelines.ps1
failOnStderr: true
displayName: Set pipeline variables based on source

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

@ -3,6 +3,11 @@ steps:
displayName: Download deployables
artifact: deployables-Windows
- task: NuGetToolInstaller@1
displayName: Use NuGet 5.x
inputs:
versionSpec: 5.x
- task: NuGetCommand@2
displayName: Push packages to CI feed
inputs:

2
azure-pipelines/variables/_all.ps1 Normal file → Executable file
Просмотреть файл

@ -1,3 +1,5 @@
#!/usr/bin/env pwsh
# This script returns a hashtable of build variables that should be set
# at the start of a build or release definition's execution.

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

@ -1,3 +1,5 @@
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Installs dependencies required to build and test the projects in this repository.
@ -71,7 +73,7 @@ try {
if (!$NoRestore -and $PSCmdlet.ShouldProcess("NuGet packages", "Restore")) {
Write-Host "Restoring NuGet packages" -ForegroundColor $HeaderColor
dotnet restore src
dotnet restore
if ($lastexitcode -ne 0) {
throw "Failure while restoring packages."
}

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

@ -28,9 +28,9 @@
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<!-- <PackageReference Include="Microsoft.SourceLink.AzureRepos.Git" Version="1.0.0" PrivateAssets="All" /> -->
<PackageReference Include="Nerdbank.GitVersioning" Version="3.0.50" PrivateAssets="all" />
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="3.4.0" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.113" PrivateAssets="all" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.1.74" PrivateAssets="all" />
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="3.5.0" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.164" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>

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

@ -1,4 +1,8 @@
<Project>
<PropertyGroup>
<!-- Workaround https://github.com/dotnet/wpf/issues/1718 -->
<EmbedUntrackedSources Condition=" '$(UseWPF)' == 'true' ">false</EmbedUntrackedSources>
</PropertyGroup>
<PropertyGroup Condition=" '$(IsTestProject)' == 'true' ">
<CoverletOutputFormat>cobertura</CoverletOutputFormat>
<Exclude>[xunit.*]*</Exclude>

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

@ -1,3 +1,5 @@
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Installs the .NET SDK specified in the global.json file at the root of this repository,
@ -21,7 +23,7 @@ Param (
)
$DotNetInstallScriptRoot = "$PSScriptRoot/../obj/tools"
if (!(Test-Path $DotNetInstallScriptRoot)) { New-Item -ItemType Directory -Path $DotNetInstallScriptRoot | Out-Null }
if (!(Test-Path $DotNetInstallScriptRoot)) { New-Item -ItemType Directory -Path $DotNetInstallScriptRoot -WhatIf:$false | Out-Null }
$DotNetInstallScriptRoot = Resolve-Path $DotNetInstallScriptRoot
# Look up actual required .NET Core SDK version from global.json
@ -81,25 +83,6 @@ Function Install-DotNet($Version, [switch]$Runtime) {
}
}
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 | Get-Unique |% {
if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) {
Install-DotNet -Version $_ -Runtime
}
}
return
}
$switches = @(
'-Architecture','x64'
)
@ -108,7 +91,23 @@ $envVars = @{
'DOTNET_SKIP_FIRST_TIME_EXPERIENCE' = 'true';
}
if ($InstallLocality -eq 'repo') {
if ($InstallLocality -eq 'machine') {
if ($IsWindows) {
if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) {
Install-DotNet -Version $sdkVersion
}
$runtimeVersions | Get-Unique |% {
if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) {
Install-DotNet -Version $_ -Runtime
}
}
return
} else {
$DotNetInstallDir = '/usr/share/dotnet'
}
} elseif ($InstallLocality -eq 'repo') {
$DotNetInstallDir = "$DotNetInstallScriptRoot/.dotnet"
} elseif ($env:AGENT_TOOLSDIRECTORY) {
$DotNetInstallDir = "$env:AGENT_TOOLSDIRECTORY/dotnet"

2
tools/Install-NuGetCredProvider.ps1 Normal file → Executable file
Просмотреть файл

@ -1,3 +1,5 @@
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Downloads and installs the Microsoft Artifacts Credential Provider