Skip to content

Commit ff4e7e7

Browse files
benmccallumsungam3r
authored andcommitted
Support ASP.NET Core 3.0 (#280)
1 parent 9088c88 commit ff4e7e7

30 files changed

+333
-41743
lines changed

Directory.Build.props

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project>
2-
2+
33
<PropertyGroup Label="Сommon properties">
44
<LangVersion>latest</LangVersion>
55
<PackageProjectUrl>https://github.com/graphql-dotnet/server</PackageProjectUrl>
@@ -11,38 +11,47 @@
1111
<Company>graphql-dotnet</Company>
1212
</PropertyGroup>
1313

14+
<PropertyGroup>
15+
<IsNetCore30OnwardsTarget>$(TargetFramework.Equals('netcoreapp3.0'))</IsNetCore30OnwardsTarget>
16+
</PropertyGroup>
17+
1418
<PropertyGroup Label="Package dependency versions">
1519
<MicrosoftAspNetCoreVersion>2.2.0</MicrosoftAspNetCoreVersion>
1620
<MicrosoftAspNetCoreHttpAbstractionsVersion>2.2.0</MicrosoftAspNetCoreHttpAbstractionsVersion>
1721
<MicrosoftAspNetCoreHttpVersion>2.2.2</MicrosoftAspNetCoreHttpVersion>
18-
<MicrosoftAspNetCoreTestHostVersion>2.2.0</MicrosoftAspNetCoreTestHostVersion>
1922
<MicrosoftAspNetCoreWebSocketsVersion>2.2.1</MicrosoftAspNetCoreWebSocketsVersion>
2023
<MicrosoftAspNetCoreAuthorizationVersion>2.2.0</MicrosoftAspNetCoreAuthorizationVersion>
2124
<MicrosoftAspNetCoreHostingAbstractionsVersion>2.2.0</MicrosoftAspNetCoreHostingAbstractionsVersion>
22-
23-
<MicrosoftExtensionsLoggingVersion>2.2.0</MicrosoftExtensionsLoggingVersion>
24-
<MicrosoftExtensionsOptionsVersion>2.2.0</MicrosoftExtensionsOptionsVersion>
25-
<MicrosoftExtensionsDependencyInjectionVersion>2.2.0</MicrosoftExtensionsDependencyInjectionVersion>
26-
<MicrosoftExtensionsDependencyInjectionAbstractionsVersion>2.2.0</MicrosoftExtensionsDependencyInjectionAbstractionsVersion>
27-
28-
<MicrosoftNETTestSdkVersion>16.2.0</MicrosoftNETTestSdkVersion>
25+
<MicrosoftAspNetCoreTestHostVersion Condition="'$(IsNetCore30OnwardsTarget)' == 'False'">2.2.0</MicrosoftAspNetCoreTestHostVersion>
26+
<MicrosoftAspNetCoreTestHostVersion Condition="'$(IsNetCore30OnwardsTarget)' == 'True'">3.0.0</MicrosoftAspNetCoreTestHostVersion>
27+
28+
<MicrosoftExtensionsLoggingVersion Condition="'$(IsNetCore30OnwardsTarget)' == 'False'">2.2.0</MicrosoftExtensionsLoggingVersion>
29+
<MicrosoftExtensionsLoggingVersion Condition="'$(IsNetCore30OnwardsTarget)' == 'True'">3.0.0</MicrosoftExtensionsLoggingVersion>
30+
<MicrosoftExtensionsOptionsVersion Condition="'$(IsNetCore30OnwardsTarget)' == 'False'">2.2.0</MicrosoftExtensionsOptionsVersion>
31+
<MicrosoftExtensionsOptionsVersion Condition="'$(IsNetCore30OnwardsTarget)' == 'True'">3.0.0</MicrosoftExtensionsOptionsVersion>
32+
<MicrosoftExtensionsDependencyInjectionVersion Condition="'$(IsNetCore30OnwardsTarget)' == 'False'">2.2.0</MicrosoftExtensionsDependencyInjectionVersion>
33+
<MicrosoftExtensionsDependencyInjectionVersion Condition="'$(IsNetCore30OnwardsTarget)' == 'True'">3.0.0</MicrosoftExtensionsDependencyInjectionVersion>
34+
<MicrosoftExtensionsDependencyInjectionAbstractionsVersion Condition="'$(IsNetCore30OnwardsTarget)' == 'False'">2.2.0</MicrosoftExtensionsDependencyInjectionAbstractionsVersion>
35+
<MicrosoftExtensionsDependencyInjectionAbstractionsVersion Condition="'$(IsNetCore30OnwardsTarget)' == 'True'">3.0.0</MicrosoftExtensionsDependencyInjectionAbstractionsVersion>
36+
37+
<MicrosoftNETTestSdkVersion>16.3.0</MicrosoftNETTestSdkVersion>
2938
<CastleCoreVersion>4.4.0</CastleCoreVersion>
3039
<NSubstituteVersion>3.1.0</NSubstituteVersion>
3140
<NewtonsoftJsonVersion>12.0.2</NewtonsoftJsonVersion>
3241
<GraphQLVersion>3.0.0-preview-1294</GraphQLVersion>
33-
<MoqVersion>4.12.0</MoqVersion>
42+
<MoqVersion>4.13.1</MoqVersion>
3443
<ShouldlyVersion>3.0.2</ShouldlyVersion>
35-
44+
3645
<xunitVersion>2.4.1</xunitVersion>
3746
<xunitrunnervisualstudioVersion>2.4.1</xunitrunnervisualstudioVersion>
3847

3948
<SerilogVersion>2.8.0</SerilogVersion>
4049
<SerilogAspNetCoreVersion>2.1.1</SerilogAspNetCoreVersion>
4150
<SerilogSinksConsoleVersion>3.1.1</SerilogSinksConsoleVersion>
42-
51+
4352
<SystemThreadingTasksDataflowVersion>4.9.0</SystemThreadingTasksDataflowVersion>
4453
<SystemThreadingTasksExtensionsVersion>4.5.3</SystemThreadingTasksExtensionsVersion>
4554
<SystemReactiveVersion>4.1.5</SystemReactiveVersion>
4655
</PropertyGroup>
47-
56+
4857
</Project>

GraphQL.Server.sln

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27130.2036
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29411.108
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Transports.Subscriptions.WebSockets", "src\Transports.Subscriptions.WebSockets\Transports.Subscriptions.WebSockets.csproj", "{4DF1CB8E-30AA-4281-9056-D49FDBF4C496}"
77
EndProject
@@ -13,6 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{0FD61587
1313
ProjectSection(SolutionItems) = preProject
1414
appveyor.yml = appveyor.yml
1515
build.cake = build.cake
16+
Directory.Build.props = Directory.Build.props
1617
GitVersion.yml = GitVersion.yml
1718
nuget.config = nuget.config
1819
EndProjectSection

appveyor.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
os: Visual Studio 2017
1+
os: Visual Studio 2019
22

33
version: 0.0.0-{build}
44
pull_requests:
@@ -17,10 +17,7 @@ test: off
1717
skip_branch_with_pr: false
1818

1919
install:
20-
- ps: Install-Product node LTS
21-
- ps: choco install dotnetcore-sdk --no-progress --confirm --version 2.2.104
22-
- node --version
23-
- npm --version
20+
- ps: choco install dotnetcore-sdk --no-progress --confirm --version 3.0.100
2421
- dotnet --version
2522

2623
on_failure:

build.cake

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ var target = Argument<string>("target", "Default");
44
var configuration = Argument<string>("configuration", "Release");
55
var artifactsDir = Directory(Argument<string>("artifactsDir", "./artifacts"));
66
var publishDir = Directory(Argument<string>("publishDir", "./publish"));
7-
var framework = Argument<string>("framework", "netstandard2.0");
87
var runtime = Argument<string>("runtime", "win-x64");
98
var sln = "./GraphQL.Server.Transports.sln";
109
var projectFiles = new [] {
@@ -30,15 +29,14 @@ Task("Publish")
3029
{
3130
var settings = new DotNetCorePublishSettings
3231
{
33-
Framework = framework,
3432
Configuration = configuration,
3533
OutputDirectory = publishDir,
3634
Runtime = runtime
3735
};
3836

3937
foreach(var projectFile in projectFiles)
4038
{
41-
DotNetCorePublish(projectFile, settings);
39+
DotNetCorePublish(projectFile, settings);
4240
}
4341
});
4442

@@ -57,9 +55,9 @@ Task("Pack")
5755
MSBuildSettings = buildSettings
5856
};
5957

60-
foreach(var projectFile in projectFiles)
58+
foreach (var projectFile in projectFiles)
6159
{
62-
DotNetCorePack(projectFile, settings);
60+
DotNetCorePack(projectFile, settings);
6361
}
6462
});
6563

@@ -70,13 +68,12 @@ Task("Build")
7068
{
7169
var settings = new DotNetCoreBuildSettings
7270
{
73-
Framework = framework,
7471
Configuration = configuration
7572
};
7673

77-
foreach(var projectFile in projectFiles)
74+
foreach (var projectFile in projectFiles)
7875
{
79-
DotNetCoreBuild(projectFile, settings);
76+
DotNetCoreBuild(projectFile, settings);
8077
}
8178
});
8279

@@ -92,32 +89,34 @@ Task("Clean")
9289
Task("Restore")
9390
.Does(()=>
9491
{
95-
foreach(var projectFile in projectFiles)
92+
foreach (var projectFile in projectFiles)
9693
{
97-
DotNetCoreRestore(projectFile);
94+
DotNetCoreRestore(projectFile);
9895
}
9996
});
10097

10198
Task("SetVersion")
102-
.Does(()=> {
103-
var versionInfo = GitVersion(new GitVersionSettings {
104-
RepositoryPath = "."
105-
});
106-
version = versionInfo.NuGetVersion;
107-
Information($"Version: {version}, FullSemVer: {versionInfo.FullSemVer}");
99+
.Does(()=>
100+
{
101+
var versionInfo = GitVersion(new GitVersionSettings {
102+
RepositoryPath = "."
103+
});
104+
version = versionInfo.NuGetVersion;
105+
Information($"Version: {version}, FullSemVer: {versionInfo.FullSemVer}");
108106

109-
if(AppVeyor.IsRunningOnAppVeyor) {
110-
AppVeyor.UpdateBuildVersion(version);
111-
}
112-
});
107+
if (AppVeyor.IsRunningOnAppVeyor) {
108+
AppVeyor.UpdateBuildVersion(version);
109+
}
110+
});
113111

114112
Task("Test")
115-
.Does(()=> {
113+
.Does(()=>
114+
{
116115
var projectFiles = GetFiles("./tests/**/*.csproj");
117-
foreach(var file in projectFiles)
116+
foreach (var file in projectFiles)
118117
{
119118
DotNetCoreTest(file.FullPath);
120119
}
121-
});
120+
});
122121

123122
RunTarget(target);

build.ps1

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ Specifies the amount of information to be displayed.
2525
Shows description about tasks.
2626
.PARAMETER DryRun
2727
Performs a dry run.
28-
.PARAMETER Experimental
29-
Uses the nightly builds of the Roslyn script engine.
30-
.PARAMETER Mono
31-
Uses the Mono Compiler rather than the Roslyn script engine.
3228
.PARAMETER SkipToolPackageRestore
3329
Skips restoring of packages.
3430
.PARAMETER ScriptArgs
@@ -49,13 +45,28 @@ Param(
4945
[switch]$ShowDescription,
5046
[Alias("WhatIf", "Noop")]
5147
[switch]$DryRun,
52-
[switch]$Experimental,
53-
[switch]$Mono,
5448
[switch]$SkipToolPackageRestore,
5549
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
5650
[string[]]$ScriptArgs
5751
)
5852

53+
# Attempt to set highest encryption available for SecurityProtocol.
54+
# PowerShell will not set this by default (until maybe .NET 4.6.x). This
55+
# will typically produce a message for PowerShell v2 (just an info
56+
# message though)
57+
try {
58+
# Set TLS 1.2 (3072), then TLS 1.1 (768), then TLS 1.0 (192), finally SSL 3.0 (48)
59+
# Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't
60+
# exist in .NET 4.0, even though they are addressable if .NET 4.5+ is
61+
# installed (.NET 4.5 is an in-place upgrade).
62+
# PowerShell Core already has support for TLS 1.2 so we can skip this if running in that.
63+
if (-not $IsCoreCLR) {
64+
[System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48
65+
}
66+
} catch {
67+
Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to upgrade to .NET Framework 4.5+ and PowerShell v3'
68+
}
69+
5970
[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
6071
function MD5HashFile([string] $filePath)
6172
{
@@ -85,7 +96,7 @@ function GetProxyEnabledWebClient
8596
{
8697
$wc = New-Object System.Net.WebClient
8798
$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
88-
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
99+
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
89100
$wc.Proxy = $proxy
90101
return $wc
91102
}
@@ -110,15 +121,16 @@ $MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config"
110121
# Make sure tools folder exists
111122
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
112123
Write-Verbose -Message "Creating tools directory..."
113-
New-Item -Path $TOOLS_DIR -Type directory | out-null
124+
New-Item -Path $TOOLS_DIR -Type Directory | Out-Null
114125
}
115126

116127
# Make sure that packages.config exist.
117128
if (!(Test-Path $PACKAGES_CONFIG)) {
118-
Write-Verbose -Message "Downloading packages.config..."
119-
try {
129+
Write-Verbose -Message "Downloading packages.config..."
130+
try {
120131
$wc = GetProxyEnabledWebClient
121-
$wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch {
132+
$wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG)
133+
} catch {
122134
Throw "Could not download packages.config."
123135
}
124136
}
@@ -146,24 +158,30 @@ if (!(Test-Path $NUGET_EXE)) {
146158
}
147159

148160
# Save nuget.exe path to environment to be available to child processed
149-
$ENV:NUGET_EXE = $NUGET_EXE
161+
$env:NUGET_EXE = $NUGET_EXE
162+
$env:NUGET_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
163+
"mono `"$NUGET_EXE`""
164+
} else {
165+
"`"$NUGET_EXE`""
166+
}
150167

151168
# Restore tools from NuGet?
152169
if(-Not $SkipToolPackageRestore.IsPresent) {
153170
Push-Location
154171
Set-Location $TOOLS_DIR
155172

156173
# Check for changes in packages.config and remove installed tools if true.
157-
[string] $md5Hash = MD5HashFile($PACKAGES_CONFIG)
174+
[string] $md5Hash = MD5HashFile $PACKAGES_CONFIG
158175
if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
159-
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
176+
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
160177
Write-Verbose -Message "Missing or changed package.config hash..."
161178
Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery |
162-
Remove-Item -Recurse
179+
Remove-Item -Recurse -Force
163180
}
164181

165182
Write-Verbose -Message "Restoring tools from NuGet..."
166-
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
183+
184+
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
167185

168186
if ($LASTEXITCODE -ne 0) {
169187
Throw "An error occurred while restoring NuGet tools."
@@ -172,7 +190,7 @@ if(-Not $SkipToolPackageRestore.IsPresent) {
172190
{
173191
$md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
174192
}
175-
Write-Verbose -Message ($NuGetOutput | out-string)
193+
Write-Verbose -Message ($NuGetOutput | Out-String)
176194

177195
Pop-Location
178196
}
@@ -183,13 +201,13 @@ if (Test-Path $ADDINS_PACKAGES_CONFIG) {
183201
Set-Location $ADDINS_DIR
184202

185203
Write-Verbose -Message "Restoring addins from NuGet..."
186-
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""
204+
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""
187205

188206
if ($LASTEXITCODE -ne 0) {
189207
Throw "An error occurred while restoring NuGet addins."
190208
}
191209

192-
Write-Verbose -Message ($NuGetOutput | out-string)
210+
Write-Verbose -Message ($NuGetOutput | Out-String)
193211

194212
Pop-Location
195213
}
@@ -200,13 +218,13 @@ if (Test-Path $MODULES_PACKAGES_CONFIG) {
200218
Set-Location $MODULES_DIR
201219

202220
Write-Verbose -Message "Restoring modules from NuGet..."
203-
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""
221+
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""
204222

205223
if ($LASTEXITCODE -ne 0) {
206224
Throw "An error occurred while restoring NuGet modules."
207225
}
208226

209-
Write-Verbose -Message ($NuGetOutput | out-string)
227+
Write-Verbose -Message ($NuGetOutput | Out-String)
210228

211229
Pop-Location
212230
}
@@ -216,20 +234,23 @@ if (!(Test-Path $CAKE_EXE)) {
216234
Throw "Could not find Cake.exe at $CAKE_EXE"
217235
}
218236

237+
$CAKE_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
238+
"mono `"$CAKE_EXE`""
239+
} else {
240+
"`"$CAKE_EXE`""
241+
}
219242

220-
221-
# Build Cake arguments
222-
$cakeArguments = @("$Script");
223-
if ($Target) { $cakeArguments += "-target=$Target" }
243+
# Build an array (not a string) of Cake arguments to be joined later
244+
$cakeArguments = @()
245+
if ($Script) { $cakeArguments += "`"$Script`"" }
246+
if ($Target) { $cakeArguments += "-target=`"$Target`"" }
224247
if ($Configuration) { $cakeArguments += "-configuration=$Configuration" }
225248
if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" }
226249
if ($ShowDescription) { $cakeArguments += "-showdescription" }
227250
if ($DryRun) { $cakeArguments += "-dryrun" }
228-
if ($Experimental) { $cakeArguments += "-experimental" }
229-
if ($Mono) { $cakeArguments += "-mono" }
230251
$cakeArguments += $ScriptArgs
231252

232253
# Start Cake
233254
Write-Host "Running build script..."
234-
&$CAKE_EXE $cakeArguments
255+
Invoke-Expression "& $CAKE_EXE_INVOCATION $($cakeArguments -join " ")"
235256
exit $LASTEXITCODE

0 commit comments

Comments
 (0)