Skip to content

Commit fb0455e

Browse files
Merge pull request #127 from martincostello/Version-3
Support .NET Core 3.0
2 parents 548f6b2 + 21aeaad commit fb0455e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+861
-648
lines changed

.azure-pipelines/build-template.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ phases:
2020
${{ if and(eq(parameters.queueName, ''), eq(parameters.agentOS, 'macOS')) }}:
2121
name: Hosted macOS
2222
${{ if and(eq(parameters.queueName, ''), eq(parameters.agentOS, 'Windows')) }}:
23-
name: Hosted VS2017
23+
name: Hosted Windows 2019 with VS2019
2424
variables:
2525
AgentOSName: ${{ parameters.agentOS }}
2626
BuildArgs: ${{ parameters.buildArgs }}
@@ -39,7 +39,6 @@ phases:
3939
name: BuildAndTest
4040
displayName: Build and test
4141
env:
42-
DOTNET_MULTILEVEL_LOOKUP: 0
4342
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
4443
NUGET_XMLDOC_MODE: skip
4544
- ${{ if ne(parameters.agentOS, 'Windows') }}:
@@ -48,7 +47,6 @@ phases:
4847
name: BuildAndTest
4948
displayName: Build and test
5049
env:
51-
DOTNET_MULTILEVEL_LOOKUP: 0
5250
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
5351
NUGET_XMLDOC_MODE: skip
5452
- task: PublishTestResults@2

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ bin
1515
Bin
1616
BuildOutput
1717
coverage
18+
coverage.*
1819
node_modules
1920
obj
2021
packages
@@ -24,6 +25,7 @@ typings
2425
UpgradeLog*.htm
2526
UpgradeLog*.XML
2627
PublishProfiles
28+
*.coverage
2729
*.DotSettings
2830
*.GhostDoc.xml
2931
*.log

Build.ps1

Lines changed: 44 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ param(
22
[Parameter(Mandatory = $false)][string] $Configuration = "Release",
33
[Parameter(Mandatory = $false)][string] $VersionSuffix = "",
44
[Parameter(Mandatory = $false)][string] $OutputPath = "",
5-
[Parameter(Mandatory = $false)][switch] $SkipTests,
6-
[Parameter(Mandatory = $false)][switch] $DisableCodeCoverage
5+
[Parameter(Mandatory = $false)][switch] $SkipTests
76
)
87

8+
# These make CI builds faster
9+
$env:DOTNET_MULTILEVEL_LOOKUP = "0"
10+
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = "true"
11+
$env:NUGET_XMLDOC_MODE = "skip"
12+
913
$ErrorActionPreference = "Stop"
1014
$ProgressPreference = "SilentlyContinue"
1115

@@ -52,10 +56,16 @@ else {
5256
}
5357

5458
if ($installDotNetSdk -eq $true) {
55-
$env:DOTNET_INSTALL_DIR = Join-Path "$(Convert-Path "$PSScriptRoot")" ".dotnetcli"
59+
60+
if (($null -ne $env:TF_BUILD)) {
61+
$env:DOTNET_INSTALL_DIR = Join-Path $env:ProgramFiles "dotnet"
62+
} else {
63+
$env:DOTNET_INSTALL_DIR = Join-Path "$(Convert-Path "$PSScriptRoot")" ".dotnetcli"
64+
}
65+
5666
$sdkPath = Join-Path $env:DOTNET_INSTALL_DIR "sdk\$dotnetVersion"
5767

58-
if (!(Test-Path $sdkPath)) {
68+
if (($null -ne $env:TF_BUILD) -or (!(Test-Path $sdkPath))) {
5969
if (!(Test-Path $env:DOTNET_INSTALL_DIR)) {
6070
mkdir $env:DOTNET_INSTALL_DIR | Out-Null
6171
}
@@ -64,12 +74,15 @@ if ($installDotNetSdk -eq $true) {
6474
Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile $installScript -UseBasicParsing
6575
& $installScript -Version "$dotnetVersion" -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath
6676
}
67-
68-
$env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
69-
$dotnet = Join-Path "$env:DOTNET_INSTALL_DIR" "dotnet.exe"
7077
}
7178
else {
72-
$dotnet = "dotnet"
79+
$env:DOTNET_INSTALL_DIR = Split-Path -Path (Get-Command dotnet.exe).Path
80+
}
81+
82+
$dotnet = Join-Path "$env:DOTNET_INSTALL_DIR" "dotnet.exe"
83+
84+
if (($installDotNetSdk -eq $true) -And ($null -eq $env:TF_BUILD)) {
85+
$env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
7386
}
7487

7588
function DotNetPack {
@@ -89,48 +102,29 @@ function DotNetPack {
89102
function DotNetTest {
90103
param([string]$Project)
91104

92-
if ($DisableCodeCoverage -eq $true) {
93-
if ($null -ne $env:TF_BUILD) {
94-
& $dotnet test $Project --output $OutputPath --logger trx
95-
}
96-
else {
97-
& $dotnet test $Project --output $OutputPath
98-
}
99-
}
100-
else {
101-
102-
if ($installDotNetSdk -eq $true) {
103-
$dotnetPath = $dotnet
104-
}
105-
else {
106-
$dotnetPath = (Get-Command "dotnet.exe").Source
107-
}
105+
$nugetPath = Join-Path $env:USERPROFILE ".nuget\packages"
106+
$propsFile = Join-Path $solutionPath "Directory.Build.props"
107+
$reportGeneratorVersion = (Select-Xml -Path $propsFile -XPath "//PackageReference[@Include='ReportGenerator']/@Version").Node.'#text'
108+
$reportGeneratorPath = Join-Path $nugetPath "ReportGenerator\$reportGeneratorVersion\tools\netcoreapp2.0\ReportGenerator.dll"
108109

109-
$nugetPath = Join-Path $env:USERPROFILE ".nuget\packages"
110-
$propsFile = Join-Path $solutionPath "Directory.Build.props"
110+
$coverageOutput = Join-Path $OutputPath "coverage.cobertura.xml"
111+
$reportOutput = Join-Path $OutputPath "coverage"
111112

112-
$reportGeneratorVersion = (Select-Xml -Path $propsFile -XPath "//PackageReference[@Include='ReportGenerator']/@Version").Node.'#text'
113-
$reportGeneratorPath = Join-Path $nugetPath "ReportGenerator\$reportGeneratorVersion\tools\netcoreapp2.0\ReportGenerator.dll"
114-
115-
$coverageOutput = Join-Path $OutputPath "coverage.cobertura.xml"
116-
$reportOutput = Join-Path $OutputPath "coverage"
117-
118-
if ($null -ne $env:TF_BUILD) {
119-
& $dotnetPath test $Project --output $OutputPath --logger trx
120-
}
121-
else {
122-
& $dotnetPath test $Project --output $OutputPath
123-
}
113+
if ($null -ne $env:TF_BUILD) {
114+
& $dotnet test $Project --output $OutputPath --logger trx
115+
}
116+
else {
117+
& $dotnet test $Project --output $OutputPath
118+
}
124119

125-
$dotNetTestExitCode = $LASTEXITCODE
120+
$dotNetTestExitCode = $LASTEXITCODE
126121

127-
& $dotnet `
128-
$reportGeneratorPath `
129-
`"-reports:$coverageOutput`" `
130-
`"-targetdir:$reportOutput`" `
131-
-reporttypes:HTML `
132-
-verbosity:Warning
133-
}
122+
& $dotnet `
123+
$reportGeneratorPath `
124+
`"-reports:$coverageOutput`" `
125+
`"-targetdir:$reportOutput`" `
126+
-reporttypes:HTML `
127+
-verbosity:Warning
134128

135129
if ($dotNetTestExitCode -ne 0) {
136130
throw "dotnet test failed with exit code $dotNetTestExitCode"
@@ -141,10 +135,8 @@ Write-Host "Packaging solution..." -ForegroundColor Green
141135

142136
DotNetPack $libraryProject
143137

144-
if ($SkipTests -eq $false) {
145-
Write-Host "Running tests..." -ForegroundColor Green
146-
Remove-Item -Path (Join-Path $OutputPath "coverage.json") -Force -ErrorAction SilentlyContinue | Out-Null
147-
ForEach ($testProject in $testProjects) {
148-
DotNetTest $testProject
149-
}
138+
Write-Host "Running tests..." -ForegroundColor Green
139+
Remove-Item -Path (Join-Path $OutputPath "coverage.json") -Force -ErrorAction SilentlyContinue | Out-Null
140+
ForEach ($testProject in $testProjects) {
141+
DotNetTest $testProject
150142
}

Directory.Build.props

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project>
22
<PropertyGroup>
33
<AnalyzersVersion>2.9.4</AnalyzersVersion>
4+
<MicrosoftNETFrameworkReferenceAssembliesVersion>1.0.0-preview.2</MicrosoftNETFrameworkReferenceAssembliesVersion>
45
</PropertyGroup>
56
<ItemGroup>
67
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
@@ -13,6 +14,9 @@
1314
<PackageReference Include="ReportGenerator" Version="4.2.20" PrivateAssets="All" />
1415
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
1516
</ItemGroup>
17+
<ItemGroup>
18+
<None Include="$(MSBuildThisFileDirectory)package-icon.png" Pack="True" PackagePath="" />
19+
</ItemGroup>
1620
<PropertyGroup>
1721
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
1822
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)justeat-oss.snk</AssemblyOriginatorKeyFile>
@@ -27,7 +31,7 @@
2731
<NeutralLanguage>en-US</NeutralLanguage>
2832
<NoWarn>$(NoWarn);CA1054;CA2234</NoWarn>
2933
<NoWarn Condition=" '$(GenerateDocumentationFile)' != 'true' ">$(NoWarn);SA0001</NoWarn>
30-
<PackageIconUrl>https://avatars3.githubusercontent.com/u/1516790?s=64</PackageIconUrl>
34+
<PackageIcon>package-icon.png</PackageIcon>
3135
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
3236
<PackageProjectUrl>https://github.com/justeat/httpclient-interception</PackageProjectUrl>
3337
<PackageReleaseNotes>$(PackageProjectUrl)/releases</PackageReleaseNotes>
@@ -38,8 +42,8 @@
3842
<RepositoryUrl>$(PackageProjectUrl).git</RepositoryUrl>
3943
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
4044
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
41-
<AssemblyVersion>2.0.0.0</AssemblyVersion>
42-
<VersionPrefix>2.0.3</VersionPrefix>
45+
<AssemblyVersion>3.0.0.0</AssemblyVersion>
46+
<VersionPrefix>3.0.0</VersionPrefix>
4347
<VersionSuffix Condition=" '$(VersionSuffix)' == '' AND '$(APPVEYOR)' == 'true' AND '$(APPVEYOR_REPO_TAG)' != 'true'">beta$([System.Convert]::ToInt32(`$(APPVEYOR_BUILD_NUMBER)`).ToString(`0000`))</VersionSuffix>
4448
<VersionSuffix Condition=" '$(VersionSuffix)' == '' AND '$(TF_BUILD)' == 'True'">beta$([System.Convert]::ToInt32(`$(BUILD_BUILDID)`).ToString(`0000`))</VersionSuffix>
4549
<VersionSuffix Condition=" '$(VersionSuffix)' == '' AND '$(TRAVIS)' == 'true'">beta$([System.Convert]::ToInt32(`$(TRAVIS_BUILD_NUMBER)`).ToString(`0000`))</VersionSuffix>
@@ -50,9 +54,9 @@
5054
</PropertyGroup>
5155
<PropertyGroup>
5256
<CollectCoverage>true</CollectCoverage>
53-
<CoverletOutput>$(OutputPath)\</CoverletOutput>
57+
<CoverletOutput Condition=" '$(OutputPath)' != '' ">$(OutputPath)\</CoverletOutput>
5458
<CoverletOutputFormat>cobertura,json</CoverletOutputFormat>
55-
<Exclude>[*.Benchmarks]*,[*.Tests]*,[SampleApp]*,[xunit.*]*</Exclude>
59+
<Exclude>[*.Benchmarks]*,[*.Tests]*,[Refit]*,[SampleApp]*,[xunit.*]*</Exclude>
5660
<ExcludeByAttribute>System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute</ExcludeByAttribute>
5761
<MergeWith>$(CoverletOutput)coverage.json</MergeWith>
5862
<Threshold>95</Threshold>

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
os: Visual Studio 2017
2-
version: 2.0.3.{build}
1+
os: Visual Studio 2019
2+
version: 3.0.0.{build}
33

44
environment:
55
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true

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.2.401"
3+
"version": "3.0.100"
44
}
55
}

package-icon.png

3.65 KB
Loading

samples/SampleApp.Tests/HttpServerFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ public HttpServerFixture()
3232
public HttpClientInterceptorOptions Interceptor { get; }
3333

3434
public void ClearOutputHelper()
35-
=> Server.Host.Services.GetRequiredService<ITestOutputHelperAccessor>().OutputHelper = null;
35+
=> Server.Services.GetRequiredService<ITestOutputHelperAccessor>().OutputHelper = null;
3636

3737
public void SetOutputHelper(ITestOutputHelper value)
38-
=> Server.Host.Services.GetRequiredService<ITestOutputHelperAccessor>().OutputHelper = value;
38+
=> Server.Services.GetRequiredService<ITestOutputHelperAccessor>().OutputHelper = value;
3939

4040
protected override void ConfigureWebHost(IWebHostBuilder builder)
4141
{

samples/SampleApp.Tests/ReposTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public async Task Can_Get_Organization_Repositories()
4646
.ForPath("orgs/weyland-yutani/repos")
4747
.ForQuery("per_page=2")
4848
.Responds()
49-
.WithJsonContent(
49+
.WithSystemTextJsonContent(
5050
new[]
5151
{
5252
new { id = 1, name = "foo" },

samples/SampleApp.Tests/SampleApp.Tests.csproj

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<NoWarn>$(NoWarn);CA1056;CA1062;CA1707;CA2007</NoWarn>
4-
<TargetFramework>netcoreapp2.2</TargetFramework>
3+
<NoWarn>$(NoWarn);CA1056;CA1062;CA1707;CA2007;SA1600</NoWarn>
4+
<TargetFramework>netcoreapp3.0</TargetFramework>
55
</PropertyGroup>
66
<ItemGroup>
77
<Content Include="testsettings.json;xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
@@ -15,12 +15,9 @@
1515
Priority="-1" />
1616
</ItemGroup>
1717
<ItemGroup>
18+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
1819
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.1.0" />
19-
<PackageReference Include="Microsoft.AspNetCore.App" />
20-
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.7" />
21-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="2.2.0" />
22-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
23-
<PackageReference Include="Microsoft.Extensions.Http" Version="2.2.0" />
20+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.0.0" />
2421
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
2522
<PackageReference Include="Shouldly" Version="3.0.2" />
2623
<PackageReference Include="xunit" Version="2.4.1" />

0 commit comments

Comments
 (0)