Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ceadb47

Browse files
authoredFeb 16, 2020
Merge pull request #1761 from AArnott/validate/githubActions
Use Azure Pipelines exclusively (i.e. drop Travis, AppVeyor)
2 parents 95009f0 + 369a98b commit ceadb47

30 files changed

+430
-299
lines changed
 

‎.travis.yml

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,7 @@
1-
# Travis-CI Build for libgit2sharp
2-
# see travis-ci.org for details
3-
41
language: csharp
52
mono: none
63

7-
matrix:
8-
include:
9-
- os: linux
10-
dist: xenial
11-
before_install:
12-
- |
13-
wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
14-
sudo dpkg -i packages-microsoft-prod.deb
15-
sudo apt-get update
16-
sudo apt-get install -y powershell
17-
- os: osx
18-
osx_image: xcode8.3
19-
before_install:
20-
- brew update # This is necessary to get pwsh 6.2 instead of some 6.0-preview that isn't named `pwsh`
21-
- brew cask install powershell
22-
fast_finish: true
23-
24-
before_install:
25-
- date -u
26-
- uname -a
27-
- env | sort
28-
29-
install:
30-
- git fetch --unshallow
31-
- pwsh ./tools/Install-DotNetSdk.ps1 ; export PATH=~/.dotnet:$PATH
32-
33-
# Build libgit2, LibGit2Sharp and run the tests
34-
script:
35-
- ./buildandtest.sh 'LEAKS_IDENTIFYING'
36-
37-
# Only watch the development branch
4+
# Disable Travis-CI
385
branches:
396
only:
40-
- master
41-
- /^maint.*/
42-
43-
# Notify of build changes
44-
notifications:
45-
email:
46-
- emeric.fermas@gmail.com
7+
- NOTTHISONE

‎Directory.Build.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
55
<OutputPath>$(MSBuildThisFileDirectory)bin\$(MSBuildProjectName)\$(Configuration)\</OutputPath>
66
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
7+
<PackageOutputPath>$(MSBuildThisFileDirectory)bin\Packages\$(Configuration)\</PackageOutputPath>
78
<DefineConstants Condition=" '$(ExtraDefine)' != '' ">$(DefineConstants);$(ExtraDefine)</DefineConstants>
89
</PropertyGroup>
910

11+
<ItemGroup>
12+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
13+
</ItemGroup>
1014
</Project>

‎Directory.Build.targets

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project>
2+
<PropertyGroup Condition=" '$(IsTestProject)' == 'true' ">
3+
<CoverletOutputFormat>cobertura</CoverletOutputFormat>
4+
<Exclude>[xunit.*]*</Exclude>
5+
<!-- Ensure we preserve each coverlet output file per target framework: https://github.com/tonerdo/coverlet/issues/177 -->
6+
<CoverletOutput>$(OutputPath)/</CoverletOutput>
7+
</PropertyGroup>
8+
</Project>

‎LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
</ItemGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
14+
<PackageReference Include="coverlet.msbuild" Version="2.7.0" />
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
1516
<PackageReference Include="Moq" Version="4.10.1" />
1617
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
1718
<PackageReference Include="xunit" Version="2.4.1" />

‎LibGit2Sharp.Tests/StatusFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ public void CanIncludeStatusOfUnalteredFiles()
640640
RepositoryStatus status = repo.RetrieveStatus(new StatusOptions() { IncludeUnaltered = true });
641641

642642
Assert.Equal(unalteredPaths.Length, status.Unaltered.Count());
643-
Assert.Equal(unalteredPaths, status.Unaltered.OrderBy(s => s.FilePath).Select(s => s.FilePath).ToArray());
643+
Assert.Equal(unalteredPaths, status.Unaltered.OrderBy(s => s.FilePath, StringComparer.OrdinalIgnoreCase).Select(s => s.FilePath).ToArray());
644644
}
645645
}
646646

‎LibGit2Sharp.Tests/desktop/ShadowCopyFixture.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace LibGit2Sharp.Tests
1111
public class ShadowCopyFixture : BaseFixture
1212
{
1313
[Fact]
14+
[Trait("TestCategory", "FailsWhileInstrumented")]
1415
public void CanProbeForNativeBinariesFromAShadowCopiedAssembly()
1516
{
1617
Type type = typeof(Wrapper);

‎LibGit2Sharp/LibGit2Sharp.csproj

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,33 @@
1616
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
1717
<SignAssembly>true</SignAssembly>
1818
<AssemblyOriginatorKeyFile>..\libgit2sharp.snk</AssemblyOriginatorKeyFile>
19+
<PackageIcon>square-logo.png</PackageIcon>
20+
<PackageLicenseFile>App_Readme/LICENSE.md</PackageLicenseFile>
1921
</PropertyGroup>
2022

2123
<ItemGroup>
2224
<CodeAnalysisDictionary Include="CustomDictionary.xml" />
23-
<None Include="..\README.md" Pack="true" PackagePath="App_Readme\" />
24-
<None Include="..\LICENSE.md" Pack="true" PackagePath="App_Readme\" />
25-
<None Include="..\CHANGES.md" Pack="true" PackagePath="App_Readme\" />
25+
<None Include="..\square-logo.png" Pack="true" PackagePath="" />
26+
<None Include="..\README.md" Pack="true" PackagePath="App_Readme/" />
27+
<None Include="..\LICENSE.md" Pack="true" PackagePath="App_Readme/" />
28+
<None Include="..\CHANGES.md" Pack="true" PackagePath="App_Readme/" />
2629
<None Update="Core\Handles\Objects.tt" Generator="TextTemplatingFileGenerator" LastGenOutput="Objects.cs" />
2730
<Compile Update="Core\Handles\Objects.cs" DependentUpon="Objects.tt" DesignTime="True" AutoGen="True" />
2831
<Service Include="{508349b6-6b84-4df5-91f0-309beebad82d}" /> <!-- Needed for T4 generation -->
2932
</ItemGroup>
3033

3134
<ItemGroup>
3235
<PackageReference Include="LibGit2Sharp.NativeBinaries" Version="[2.0.305]" PrivateAssets="none" />
33-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63127-02" PrivateAssets="all" />
34-
<PackageReference Include="Nerdbank.GitVersioning" Version="2.3.138" PrivateAssets="all" />
36+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />
37+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.0.50" PrivateAssets="all" />
3538
</ItemGroup>
3639

3740
<Import Project="..\Targets\CodeGenerator.targets" />
3841
<Import Project="..\Targets\GenerateNativeDllName.targets" />
3942

4043
<Target Name="SetNuSpecProperties" BeforeTargets="GenerateNuspec" DependsOnTargets="GetBuildVersion">
4144
<PropertyGroup>
42-
<PackageIconUrl>https://github.com/libgit2/libgit2sharp/raw/$(GitCommitIdShort)/square-logo.png</PackageIconUrl>
4345
<PackageReleaseNotes>https://github.com/libgit2/libgit2sharp/blob/$(GitCommitIdShort)/CHANGES.md#libgit2sharp-changes</PackageReleaseNotes>
44-
<PackageLicenseUrl>https://github.com/libgit2/libgit2sharp/raw/$(GitCommitIdShort)/LICENSE.md</PackageLicenseUrl>
4546
</PropertyGroup>
4647
</Target>
4748

‎appveyor.yml

Lines changed: 3 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -1,158 +1,4 @@
1-
version: '{build}'
2-
3-
os: Visual Studio 2019
4-
1+
# Disable AppVeyor
52
branches:
6-
only:
7-
- master
8-
- /^maint.*/
9-
10-
configuration: release
11-
12-
skip_tags: true
13-
14-
nuget:
15-
disable_publish_on_pr: true
16-
17-
environment:
18-
coveralls_token:
19-
secure: ixIsBslo9NheDb5lJknF58EYdgvZ0r3/L0ecRiXjfXmjHBLvoSU6/ZRwaMM+BAlG
20-
coverity_token:
21-
secure: nuzUT+HecXGIi3KaPd/1hgFEZJan/j6+oNbPV75JKjk=
22-
coverity_email:
23-
secure: eGVilNg1Yuq+Xj+SW8r3WCtjnzhoDV0sNJkma4NRq7A=
24-
matrix:
25-
- publish_on_success: False
26-
ExtraDefine: LEAKS_IDENTIFYING
27-
- publish_on_success: True
28-
29-
matrix:
30-
fast_finish: true
31-
32-
install:
33-
- ps: |
34-
Write-Host "Commit being built = " -NoNewLine
35-
Write-Host $Env:APPVEYOR_REPO_COMMIT -ForegroundColor "Green"
36-
Write-Host "Target branch = " -NoNewLine
37-
Write-Host $Env:APPVEYOR_REPO_BRANCH -ForegroundColor "Green"
38-
Write-Host "Is a Pull Request = " -NoNewLine
39-
Write-Host $($Env:APPVEYOR_PULL_REQUEST_NUMBER -ne $null) -ForegroundColor "Green"
40-
41-
$CommitDate = [DateTime]::Parse($Env:APPVEYOR_REPO_COMMIT_TIMESTAMP)
42-
$BuildDate = $CommitDate.ToUniversalTime().ToString("yyyyMMddHHmmss")
43-
Write-Host "Merge commit UTC timestamp = " -NoNewLine
44-
Write-Host $BuildDate -ForegroundColor "Green"
45-
46-
$Env:SHOULD_RUN_COVERITY_ANALYSIS = $($Env:APPVEYOR_SCHEDULED_BUILD -eq $True)
47-
Write-Host "Should run Coverity analysis = " -NoNewLine
48-
Write-Host $Env:SHOULD_RUN_COVERITY_ANALYSIS -ForegroundColor "Green"
49-
50-
$Env:SHOULD_RUN_COVERALLS = $($Env:APPVEYOR_SCHEDULED_BUILD -eq $True)
51-
Write-Host "Should run Coveralls = " -NoNewLine
52-
Write-Host $Env:SHOULD_RUN_COVERALLS -ForegroundColor "Green"
53-
54-
Write-Host "Identifying leaks = " -NoNewLine
55-
Write-Host ($Env:ExtraDefine -eq "LEAKS_IDENTIFYING") -ForegroundColor "Green"
56-
57-
Write-Host "Should publish on success = " -NoNewLine
58-
Write-Host $Env:publish_on_success -ForegroundColor "Green"
59-
60-
If ($Env:SHOULD_RUN_COVERALLS -eq $True)
61-
{
62-
nuget install OpenCover -Version 4.6.166 -ExcludeVersion -OutputDirectory .\packages
63-
nuget install coveralls.net -Version 0.6.0 -ExcludeVersion -OutputDirectory .\packages
64-
}
65-
66-
If ($Env:SHOULD_RUN_COVERITY_ANALYSIS -eq $True)
67-
{
68-
cinst curl -y
69-
}
70-
71-
./tools/Install-DotNetSdk.ps1
72-
73-
before_build:
74-
- ps: |
75-
msbuild "$Env:APPVEYOR_BUILD_FOLDER\LibGit2Sharp.sln" `
76-
/nologo /verbosity:quiet `
77-
/logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" `
78-
/t:restore
79-
80-
build_script:
81-
- ps: |
82-
& cov-build.exe --dir cov-int msbuild "$Env:APPVEYOR_BUILD_FOLDER\LibGit2Sharp.sln" `
83-
/nologo /verbosity:minimal /fl /flp:verbosity=normal `
84-
/logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" `
85-
/t:build,pack
86-
87-
test_script:
88-
- ps: |
89-
Foreach ($runner in 'xunit.console.exe','xunit.console.x86.exe')
90-
{
91-
If ($Env:SHOULD_RUN_COVERALLS -eq $True -and $Env:publish_on_success -eq $True)
92-
{
93-
.\packages\OpenCover\tools\OpenCover.Console.exe `
94-
-register:user `
95-
"-target:""$Env:userprofile\.nuget\packages\xunit.runner.console\2.4.1\tools\net46\$runner""" `
96-
"-targetargs:""$Env:APPVEYOR_BUILD_FOLDER\bin\LibGit2Sharp.Tests\Release\net46\LibGit2Sharp.Tests.dll"" -noshadow" `
97-
"-filter:+[LibGit2Sharp]* -[LibGit2Sharp.Tests]*" `
98-
-hideskipped:All `
99-
-output:opencoverCoverage.xml
100-
}
101-
ElseIf ($Env:SHOULD_RUN_COVERITY_ANALYSIS -eq $False)
102-
{
103-
& "$Env:userprofile\.nuget\packages\xunit.runner.console\2.4.1\tools\net46\$runner" `
104-
"$Env:APPVEYOR_BUILD_FOLDER\bin\LibGit2Sharp.Tests\Release\net46\LibGit2Sharp.Tests.dll" -noshadow
105-
}
106-
}
107-
108-
- dotnet test LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj -f netcoreapp2.1 --no-restore --no-build
109-
110-
after_test:
111-
- ps: |
112-
If ($Env:SHOULD_RUN_COVERALLS -eq $True -and $Env:publish_on_success -eq $True)
113-
{
114-
Write-Host "Uploading code coverage result..." -ForegroundColor "Green"
115-
116-
.\packages\coveralls.net\tools\csmacnz.Coveralls.exe `
117-
--opencover -i opencoverCoverage.xml `
118-
--repoToken $Env:coveralls_token `
119-
--useRelativePaths `
120-
--basePath "$Env:APPVEYOR_BUILD_FOLDER\"`
121-
}
122-
123-
If ($Env:SHOULD_RUN_COVERITY_ANALYSIS -eq $True -and $Env:publish_on_success -eq $True)
124-
{
125-
7z a "$Env:APPVEYOR_BUILD_FOLDER\$Env:APPVEYOR_PROJECT_NAME.zip" "$Env:APPVEYOR_BUILD_FOLDER\cov-int\"
126-
127-
# cf. http://stackoverflow.com/a/25045154/335418
128-
Remove-item alias:curl
129-
130-
Write-Host "Uploading Coverity analysis result..." -ForegroundColor "Green"
131-
132-
curl --silent --show-error `
133-
--output curl-out.txt `
134-
--form token="$Env:coverity_token" `
135-
--form email="$Env:coverity_email" `
136-
--form "file=@$Env:APPVEYOR_BUILD_FOLDER\$Env:APPVEYOR_PROJECT_NAME.zip" `
137-
--form version="$Env:APPVEYOR_REPO_COMMIT" `
138-
--form description="CI server scheduled build." `
139-
https://scan.coverity.com/builds?project=libgit2%2Flibgit2sharp
140-
141-
cat .\curl-out.txt
142-
}
143-
144-
on_finish:
145-
- ps: Push-AppveyorArtifact "msbuild.log"
146-
147-
on_success:
148-
- ps: |
149-
if ($Env:publish_on_success -eq $True)
150-
{
151-
Get-ChildItem "bin\LibGit2Sharp\$env:configuration\*.nupkg" |% { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
152-
}
153-
154-
notifications:
155-
- provider: Email
156-
to:
157-
- emeric.fermas@gmail.com
158-
on_build_status_changed: true
3+
only:
4+
- NOTTHISONE

‎azure-pipelines.yml

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,10 @@ trigger:
33
- maint/*
44

55
variables:
6-
solution: '**/*.sln'
7-
buildPlatform: 'Any CPU'
8-
buildConfiguration: 'Release'
6+
TreatWarningsAsErrors: true
7+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
8+
BuildConfiguration: Release
9+
NUGET_PACKAGES: $(Agent.TempDirectory)/.nuget/packages
910

1011
jobs:
11-
- job: Windows
12-
pool:
13-
vmImage: 'windows-2019'
14-
steps:
15-
- pwsh: ./tools/Install-DotNetSdk.ps1
16-
displayName: Installing .NET Core SDK and runtimes
17-
- script: buildandtest.cmd
18-
displayName: Build and test
19-
- job: Linux
20-
pool:
21-
vmImage: 'Ubuntu 16.04'
22-
steps:
23-
- pwsh: ./tools/Install-DotNetSdk.ps1
24-
displayName: Installing .NET Core SDK and runtimes
25-
- script: ./buildandtest.sh
26-
displayName: Build and test
27-
- job: macOS
28-
pool:
29-
vmImage: 'macOS 10.13'
30-
steps:
31-
- pwsh: ./tools/Install-DotNetSdk.ps1
32-
displayName: Installing .NET Core SDK and runtimes
33-
- script: ./buildandtest.sh
34-
displayName: Build and test
12+
- template: azure-pipelines/build.yml
File renamed without changes.

‎azure-pipelines/artifacts/_all.ps1

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# This script returns all the artifacts that should be collected after a build.
2+
#
3+
# Each powershell artifact is expressed as an object with these properties:
4+
# Source - the full path to the source file
5+
# ArtifactName - the name of the artifact to upload to
6+
# ContainerFolder - the relative path within the artifact in which the file should appear
7+
#
8+
# Each artifact aggregating .ps1 script should return a hashtable:
9+
# Key = path to the directory from which relative paths within the artifact should be calculated
10+
# Value = an array of paths (absolute or relative to the BaseDirectory) to files to include in the artifact.
11+
# FileInfo objects are also allowed.
12+
13+
$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..")
14+
15+
Function EnsureTrailingSlash($path) {
16+
if ($path.length -gt 0 -and !$path.EndsWith('\') -and !$path.EndsWith('/')) {
17+
$path = $path + [IO.Path]::DirectorySeparatorChar
18+
}
19+
20+
$path.Replace('\', [IO.Path]::DirectorySeparatorChar)
21+
}
22+
23+
Get-ChildItem "$PSScriptRoot\*.ps1" -Exclude "_*" -Recurse |% {
24+
$ArtifactName = $_.BaseName
25+
26+
$fileGroups = & $_
27+
if (!$fileGroups -or $fileGroups.Count -eq 0) {
28+
Write-Warning "No files found for the `"$ArtifactName`" artifact."
29+
} else {
30+
$fileGroups.GetEnumerator() | % {
31+
$BaseDirectory = New-Object Uri ((EnsureTrailingSlash $_.Key), [UriKind]::Absolute)
32+
$_.Value | % {
33+
if ($_.GetType() -eq [IO.FileInfo] -or $_.GetType() -eq [IO.DirectoryInfo]) {
34+
$_ = $_.FullName
35+
}
36+
37+
$artifact = New-Object -TypeName PSObject
38+
Add-Member -InputObject $artifact -MemberType NoteProperty -Name ArtifactName -Value $ArtifactName
39+
40+
$SourceFullPath = New-Object Uri ($BaseDirectory, $_)
41+
Add-Member -InputObject $artifact -MemberType NoteProperty -Name Source -Value $SourceFullPath.LocalPath
42+
43+
$RelativePath = [Uri]::UnescapeDataString($BaseDirectory.MakeRelative($SourceFullPath))
44+
Add-Member -InputObject $artifact -MemberType NoteProperty -Name ContainerFolder -Value (Split-Path $RelativePath)
45+
46+
Write-Output $artifact
47+
}
48+
}
49+
}
50+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This script translates all the artifacts described by _all.ps1
2+
# into commands that instruct Azure Pipelines to actually collect those artifacts.
3+
4+
param (
5+
[string]$ArtifactNameSuffix
6+
)
7+
8+
& "$PSScriptRoot/_stage_all.ps1" -ArtifactNameSuffix $ArtifactNameSuffix |% {
9+
Write-Host "##vso[artifact.upload containerfolder=$($_.Name);artifactname=$($_.Name);]$($_.Path)"
10+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# This script links all the artifacts described by _all.ps1
2+
# into a staging directory, reading for uploading to a cloud build artifact store.
3+
# It returns a sequence of objects with Name and Path properties.
4+
5+
param (
6+
[string]$ArtifactNameSuffix
7+
)
8+
9+
$RepoRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot (Join-Path .. ..)))
10+
if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) {
11+
$ArtifactStagingFolder = $env:BUILD_ARTIFACTSTAGINGDIRECTORY
12+
} else {
13+
$ArtifactStagingFolder = Join-Path $RepoRoot (Join-Path obj _artifacts)
14+
if (Test-Path $ArtifactStagingFolder) {
15+
Remove-Item $ArtifactStagingFolder -Recurse -Force
16+
}
17+
}
18+
19+
function Create-SymbolicLink {
20+
param (
21+
$Link,
22+
$Target
23+
)
24+
25+
if ($Link -eq $Target) {
26+
return
27+
}
28+
29+
if (Test-Path $Link) { Remove-Item $Link }
30+
$LinkContainer = Split-Path $Link -Parent
31+
if (!(Test-Path $LinkContainer)) { mkdir $LinkContainer }
32+
Write-Verbose "Linking $Link to $Target"
33+
if ($IsMacOS -or $IsLinux) {
34+
ln $Target $Link | Out-Null
35+
} else {
36+
cmd /c mklink $Link $Target | Out-Null
37+
}
38+
}
39+
40+
# Stage all artifacts
41+
$Artifacts = & "$PSScriptRoot\_all.ps1"
42+
$Artifacts |% {
43+
$DestinationFolder = (Join-Path (Join-Path $ArtifactStagingFolder "$($_.ArtifactName)$ArtifactNameSuffix") $_.ContainerFolder).TrimEnd('\')
44+
$Name = "$(Split-Path $_.Source -Leaf)"
45+
46+
#Write-Host "$($_.Source) -> $($_.ArtifactName)\$($_.ContainerFolder)" -ForegroundColor Yellow
47+
48+
if (-not (Test-Path $DestinationFolder)) { New-Item -ItemType Directory -Path $DestinationFolder | Out-Null }
49+
if (Test-Path -PathType Leaf $_.Source) { # skip folders
50+
Create-SymbolicLink -Link (Join-Path $DestinationFolder $Name) -Target $_.Source
51+
}
52+
}
53+
54+
$Artifacts |% { "$($_.ArtifactName)$ArtifactNameSuffix" } | Get-Unique |% {
55+
$artifact = New-Object -TypeName PSObject
56+
Add-Member -InputObject $artifact -MemberType NoteProperty -Name Name -Value $_
57+
Add-Member -InputObject $artifact -MemberType NoteProperty -Name Path -Value (Join-Path $ArtifactStagingFolder $_)
58+
Write-Output $artifact
59+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
if ($env:BUILD_ARTIFACTSTAGINGDIRECTORY) {
2+
$artifactsRoot = $env:BUILD_ARTIFACTSTAGINGDIRECTORY
3+
} else {
4+
$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..")
5+
$artifactsRoot = "$RepoRoot\bin"
6+
}
7+
8+
if (!(Test-Path $artifactsRoot/build_logs)) { return }
9+
10+
@{
11+
"$artifactsRoot/build_logs" = (Get-ChildItem -Recurse "$artifactsRoot/build_logs")
12+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..")
2+
3+
# Prepare code coverage reports for merging on another machine
4+
if ($env:SYSTEM_DEFAULTWORKINGDIRECTORY) {
5+
Write-Host "Substituting $env:SYSTEM_DEFAULTWORKINGDIRECTORY with `"{reporoot}`""
6+
$reports = Get-ChildItem "$RepoRoot/bin/coverage.cobertura.xml" -Recurse
7+
$reports |% {
8+
$content = Get-Content -Path $_ |% { $_ -Replace [regex]::Escape($env:SYSTEM_DEFAULTWORKINGDIRECTORY), "{reporoot}" }
9+
Set-Content -Path $_ -Value $content -Encoding UTF8
10+
}
11+
} else {
12+
Write-Warning "coverageResults: Azure Pipelines not detected. Machine-neutral token replacement skipped."
13+
}
14+
15+
if (!((Test-Path $RepoRoot\bin) -and (Test-Path $RepoRoot\obj))) { return }
16+
17+
@{
18+
$RepoRoot = (
19+
@(Get-ChildItem "$RepoRoot\bin\coverage.cobertura.xml" -Recurse) +
20+
(Get-ChildItem "$RepoRoot\obj\*.cs" -Recurse)
21+
);
22+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
$RepoRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..")
2+
$BuildConfiguration = $env:BUILDCONFIGURATION
3+
if (!$BuildConfiguration) {
4+
$BuildConfiguration = 'Debug'
5+
}
6+
7+
$PackagesRoot = "$RepoRoot/bin/Packages/$BuildConfiguration"
8+
9+
if (!(Test-Path $PackagesRoot)) { return }
10+
11+
@{
12+
"$PackagesRoot" = (Get-ChildItem $PackagesRoot -Recurse)
13+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
$ObjRoot = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\..\obj")
2+
3+
if (!(Test-Path $ObjRoot)) { return }
4+
5+
@{
6+
"$ObjRoot" = (
7+
(Get-ChildItem "$ObjRoot\project.assets.json" -Recurse)
8+
);
9+
}

‎azure-pipelines/build.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
parameters:
2+
windowsPool: Hosted Windows 2019 with VS2019
3+
4+
jobs:
5+
- job: Windows
6+
pool: ${{ parameters.windowsPool }}
7+
steps:
8+
- template: install-dependencies.yml
9+
- template: dotnet.yml
10+
11+
- job: Linux
12+
pool:
13+
vmImage: Ubuntu 18.04
14+
steps:
15+
- template: install-dependencies.yml
16+
- template: dotnet.yml
17+
18+
- job: macOS
19+
pool:
20+
vmImage: macOS 10.13
21+
steps:
22+
- template: install-dependencies.yml
23+
- template: dotnet.yml
24+
25+
- job: WrapUp
26+
dependsOn:
27+
- Windows
28+
- Linux
29+
- macOS
30+
pool:
31+
vmImage: Ubuntu 18.04
32+
condition: succeededOrFailed()
33+
steps:
34+
- template: install-dependencies.yml
35+
parameters:
36+
initArgs: -NoRestore
37+
- template: publish-codecoverage.yml
38+
- template: publish-deployables.yml
39+
40+
- job: leak_check
41+
pool:
42+
vmImage: Ubuntu 18.04
43+
steps:
44+
- template: install-dependencies.yml
45+
- task: DotNetCoreCLI@2
46+
displayName: dotnet test -f netcoreapp2.1
47+
inputs:
48+
command: test
49+
arguments: --no-restore -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v m /p:ExtraDefine=LEAKS_IDENTIFYING
50+
testRunTitle: netcoreapp2.1-$(Agent.JobName)

‎azure-pipelines/dotnet.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
steps:
2+
3+
- script: dotnet build --no-restore -c $(BuildConfiguration) /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog"
4+
displayName: dotnet build
5+
6+
- script: dotnet pack --no-build -c $(BuildConfiguration) /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/pack.binlog"
7+
displayName: dotnet pack
8+
9+
- task: DotNetCoreCLI@2
10+
displayName: dotnet test -f net46 (w/ coverage)
11+
inputs:
12+
command: test
13+
arguments: --no-build -c $(BuildConfiguration) -f net46 --filter "TestCategory!=FailsInCloudTest & TestCategory!=FailsWhileInstrumented" -v n /p:CollectCoverage=true
14+
testRunTitle: net46-$(Agent.JobName)
15+
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
16+
17+
- task: DotNetCoreCLI@2
18+
displayName: dotnet test -f net46 (w/o coverage)
19+
inputs:
20+
command: test
21+
arguments: --no-build -c $(BuildConfiguration) -f net46 --filter "TestCategory!=FailsInCloudTest & TestCategory=FailsWhileInstrumented" -v n
22+
testRunTitle: net46-$(Agent.JobName)-nocoverage
23+
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
24+
25+
- task: DotNetCoreCLI@2
26+
displayName: dotnet test -f netcoreapp2.1
27+
inputs:
28+
command: test
29+
arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true
30+
testRunTitle: netcoreapp2.1-$(Agent.JobName)
31+
32+
- task: PowerShell@2
33+
inputs:
34+
filePath: azure-pipelines/artifacts/_pipelines.ps1
35+
arguments: -ArtifactNameSuffix "-$(Agent.JobName)"
36+
displayName: Publish artifacts
37+
condition: succeededOrFailed()
38+
39+
- bash: bash <(curl -s https://codecov.io/bash)
40+
displayName: Publish code coverage results to codecov.io
41+
timeoutInMinutes: 3
42+
continueOnError: true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
parameters:
2+
initArgs:
3+
4+
steps:
5+
6+
- powershell: |
7+
.\init.ps1 -AccessToken '$(System.AccessToken)' ${{ parameters['initArgs'] }} -UpgradePrerequisites
8+
dotnet --info
9+
displayName: Install prerequisites
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
steps:
2+
- download: current
3+
artifact: coverageResults-Windows
4+
displayName: Download Windows code coverage results
5+
continueOnError: true
6+
- download: current
7+
artifact: coverageResults-Linux
8+
displayName: Download Linux code coverage results
9+
continueOnError: true
10+
- download: current
11+
artifact: coverageResults-macOS
12+
displayName: Download macOS code coverage results
13+
continueOnError: true
14+
- powershell: |
15+
dotnet tool install --tool-path obj dotnet-reportgenerator-globaltool --version 4.2.2
16+
Copy-Item -Recurse $(Pipeline.Workspace)/coverageResults-Windows/obj/* $(System.DefaultWorkingDirectory)/obj
17+
Write-Host "Substituting {reporoot} with $(System.DefaultWorkingDirectory)"
18+
$reports = Get-ChildItem -Recurse "$(Pipeline.Workspace)/coverage.cobertura.xml"
19+
$reports |% {
20+
$content = Get-Content -Path $_ |% { $_.Replace("{reporoot}", "$(System.DefaultWorkingDirectory)") }
21+
Set-Content -Path $_ -Value $content -Encoding UTF8
22+
}
23+
$Inputs = [string]::join(';', ($reports |% { Resolve-Path -relative $_ }))
24+
obj/reportgenerator -reports:"$Inputs" -targetdir:coveragereport -reporttypes:Cobertura
25+
displayName: Merge coverage
26+
- task: PublishCodeCoverageResults@1
27+
displayName: Publish code coverage results to Azure DevOps
28+
inputs:
29+
codeCoverageTool: cobertura
30+
summaryFileLocation: 'coveragereport/Cobertura.xml'
31+
failIfCoverageEmpty: true
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
steps:
2+
- download: current
3+
displayName: Download deployables
4+
artifact: deployables-Windows
5+
6+
- task: NuGetCommand@2
7+
displayName: Push packages to CI feed
8+
inputs:
9+
command: push
10+
packagesToPush: $(Pipeline.Workspace)/deployables-Windows/*.nupkg
11+
nuGetFeedType: internal
12+
publishVstsFeed: $(ci_feed)
13+
allowPackageConflicts: true
14+
condition: and(succeeded(), ne(variables['ci_feed'], ''), ne(variables['Build.Reason'], 'PullRequest'))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$globalJson = Get-Content -Path "$PSScriptRoot\..\..\global.json" | ConvertFrom-Json
2+
$globalJson.sdk.version

‎buildandtest.cmd

Lines changed: 0 additions & 39 deletions
This file was deleted.

‎buildandtest.sh

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "2.1.802"
3+
"version": "3.1.100"
44
}
55
}

‎init.cmd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@echo off
2+
SETLOCAL
3+
set PS1UnderCmd=1
4+
powershell.exe -NoProfile -NoLogo -ExecutionPolicy bypass -Command "try { & '%~dpn0.ps1' %*; exit $LASTEXITCODE } catch { write-host $_; exit 1 }"

‎init.ps1

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<#
2+
.SYNOPSIS
3+
Installs dependencies required to build and test the projects in this repository.
4+
.DESCRIPTION
5+
This MAY not require elevation, as the SDK and runtimes are installed to a per-user location,
6+
unless the `-InstallLocality` switch is specified directing to a per-repo or per-machine location.
7+
See detailed help on that switch for more information.
8+
.PARAMETER InstallLocality
9+
A value indicating whether dependencies should be installed locally to the repo or at a per-user location.
10+
Per-user allows sharing the installed dependencies across repositories and allows use of a shared expanded package cache.
11+
Visual Studio will only notice and use these SDKs/runtimes if VS is launched from the environment that runs this script.
12+
Per-repo allows for high isolation, allowing for a more precise recreation of the environment within an Azure Pipelines build.
13+
When using 'repo', environment variables are set to cause the locally installed dotnet SDK to be used.
14+
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`.
15+
Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it.
16+
.PARAMETER NoPrerequisites
17+
Skips the installation of prerequisite software (e.g. SDKs, tools).
18+
.PARAMETER UpgradePrerequisites
19+
Takes time to install prerequisites even if they are already present in case they need to be upgraded.
20+
No effect if -NoPrerequisites is specified.
21+
.PARAMETER NoRestore
22+
Skips the package restore step.
23+
.PARAMETER AccessToken
24+
An optional access token for authenticating to Azure Artifacts authenticated feeds.
25+
#>
26+
[CmdletBinding(SupportsShouldProcess=$true)]
27+
Param (
28+
[ValidateSet('repo','user','machine')]
29+
[string]$InstallLocality='user',
30+
[Parameter()]
31+
[switch]$NoPrerequisites,
32+
[Parameter()]
33+
[switch]$UpgradePrerequisites,
34+
[Parameter()]
35+
[switch]$NoRestore,
36+
[Parameter()]
37+
[string]$AccessToken
38+
)
39+
40+
if (!$NoPrerequisites) {
41+
& "$PSScriptRoot\tools\Install-DotNetSdk.ps1" -InstallLocality $InstallLocality
42+
}
43+
44+
# Workaround nuget credential provider bug that causes very unreliable package restores on Azure Pipelines
45+
$env:NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS=20
46+
$env:NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS=20
47+
48+
Push-Location $PSScriptRoot
49+
try {
50+
$HeaderColor = 'Green'
51+
52+
if (!$NoRestore -and $PSCmdlet.ShouldProcess("NuGet packages", "Restore")) {
53+
Write-Host "Restoring NuGet packages" -ForegroundColor $HeaderColor
54+
dotnet restore
55+
if ($lastexitcode -ne 0) {
56+
throw "Failure while restoring packages."
57+
}
58+
}
59+
}
60+
catch {
61+
Write-Error $error[0]
62+
exit $lastexitcode
63+
}
64+
finally {
65+
Pop-Location
66+
}

‎tools/DotNetSdkVersion.ps1

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎tools/Install-DotNetSdk.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if (!(Test-Path $DotNetInstallScriptRoot)) { New-Item -ItemType Directory -Path
2525
$DotNetInstallScriptRoot = Resolve-Path $DotNetInstallScriptRoot
2626

2727
# Look up actual required .NET Core SDK version from global.json
28-
$sdkVersion = & "$PSScriptRoot/DotNetSdkVersion.ps1"
28+
$sdkVersion = & "$PSScriptRoot/../azure-pipelines/variables/DotNetSdkVersion.ps1"
2929

3030
# Search for all .NET Core runtime versions referenced from MSBuild projects and arrange to install them.
3131
$runtimeVersions = @()
@@ -156,5 +156,5 @@ $runtimeVersions | Get-Unique |% {
156156
}
157157

158158
if ($PSCmdlet.ShouldProcess("Set DOTNET environment variables to discover these installed runtimes?")) {
159-
& "$PSScriptRoot/Set-EnvVars.ps1" -Variables $envVars -PrependPath $DotNetInstallDir | Out-Null
159+
& "$PSScriptRoot/../azure-pipelines/Set-EnvVars.ps1" -Variables $envVars -PrependPath $DotNetInstallDir | Out-Null
160160
}

0 commit comments

Comments
 (0)
Please sign in to comment.