From 390582dcf16a95015d90bf74fc949499613db2d7 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Sat, 20 May 2017 10:37:35 -0700 Subject: [PATCH] Target .NET Standard 2.0 (#1849) --- build/common.props | 4 ++-- build/dependencies.props | 4 ++-- .../LargeResponseApp/LargeResponseApp.csproj | 8 +++++-- samples/SampleApp/SampleApp.csproj | 8 +++++-- ...soft.AspNetCore.Server.Kestrel.Core.csproj | 3 ++- .../HttpsConnectionAdapter.cs | 22 ++++++++++++++++--- ...oft.AspNetCore.Server.Kestrel.Https.csproj | 2 +- ...rver.Kestrel.Transport.Abstractions.csproj | 6 +++-- ...Core.Server.Kestrel.Transport.Libuv.csproj | 2 +- ...re.Server.Kestrel.Transport.Sockets.csproj | 2 +- ...Microsoft.AspNetCore.Server.Kestrel.csproj | 2 +- .../FrameRequestStreamTests.cs | 2 +- ...spNetCore.Server.Kestrel.Core.Tests.csproj | 10 ++++++++- .../GeneratedCodeTests.cs | 7 +++++- ...Core.Server.Kestrel.FunctionalTests.csproj | 13 +++++++---- ...pNetCore.Server.Kestrel.Performance.csproj | 3 ++- ...oft.AspNetCore.Server.Kestrel.Tests.csproj | 3 ++- ...erver.Kestrel.Transport.Libuv.Tests.csproj | 10 ++++++++- test/shared/TestResources.cs | 5 ++--- 19 files changed, 85 insertions(+), 31 deletions(-) diff --git a/build/common.props b/build/common.props index e2f5702c6b..595790c41b 100644 --- a/build/common.props +++ b/build/common.props @@ -16,8 +16,8 @@ - - + + diff --git a/build/dependencies.props b/build/dependencies.props index 7cace7d06b..401361784f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,12 +1,12 @@ 2.0.0-* - 4.4.0-* + 4.4.0-* 2.1.0-* 1.10.0-* 9.0.1 4.7.1 - $(BundledNETStandardPackageVersion) + 2.0.0-* 15.3.0-* 2.3.0-beta2-* diff --git a/samples/LargeResponseApp/LargeResponseApp.csproj b/samples/LargeResponseApp/LargeResponseApp.csproj index be9cd35512..19e6a615fc 100644 --- a/samples/LargeResponseApp/LargeResponseApp.csproj +++ b/samples/LargeResponseApp/LargeResponseApp.csproj @@ -1,9 +1,9 @@  - + - netcoreapp2.0 + netcoreapp2.0;net461 false @@ -11,4 +11,8 @@ + + + + diff --git a/samples/SampleApp/SampleApp.csproj b/samples/SampleApp/SampleApp.csproj index 0387c8a91d..e63d766922 100644 --- a/samples/SampleApp/SampleApp.csproj +++ b/samples/SampleApp/SampleApp.csproj @@ -1,9 +1,9 @@  - + - netcoreapp2.0 + netcoreapp2.0;net461 false @@ -20,4 +20,8 @@ + + + + diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Core/Microsoft.AspNetCore.Server.Kestrel.Core.csproj b/src/Microsoft.AspNetCore.Server.Kestrel.Core/Microsoft.AspNetCore.Server.Kestrel.Core.csproj index f9f23ff830..a5a3ceb117 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel.Core/Microsoft.AspNetCore.Server.Kestrel.Core.csproj +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Core/Microsoft.AspNetCore.Server.Kestrel.Core.csproj @@ -4,7 +4,7 @@ Core components of ASP.NET Core Kestrel cross-platform web server. - netcoreapp2.0 + netstandard2.0 true aspnetcore;kestrel true @@ -19,6 +19,7 @@ + diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Https/HttpsConnectionAdapter.cs b/src/Microsoft.AspNetCore.Server.Kestrel.Https/HttpsConnectionAdapter.cs index 328f4263aa..5f17cfaf63 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel.Https/HttpsConnectionAdapter.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Https/HttpsConnectionAdapter.cs @@ -61,7 +61,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Https } else { - sslStream = new SslStream(context.ConnectionStream, leaveInnerStreamOpen: false, + sslStream = new SslStream(context.ConnectionStream, + leaveInnerStreamOpen: false, userCertificateValidationCallback: (sender, certificate, chain, sslPolicyErrors) => { if (certificate == null) @@ -77,7 +78,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Https } } - var certificate2 = (X509Certificate2)certificate; + var certificate2 = ConvertToX509Certificate2(certificate); if (certificate2 == null) { return false; @@ -112,12 +113,27 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Https // Always set the feature even though the cert might be null context.Features.Set(new TlsConnectionFeature { - ClientCertificate = (X509Certificate2)sslStream.RemoteCertificate + ClientCertificate = ConvertToX509Certificate2(sslStream.RemoteCertificate) }); return new HttpsAdaptedConnection(sslStream); } + private static X509Certificate2 ConvertToX509Certificate2(X509Certificate certificate) + { + if (certificate == null) + { + return null; + } + + if (certificate is X509Certificate2 cert2) + { + return cert2; + } + + return new X509Certificate2(certificate); + } + private class HttpsAdaptedConnection : IAdaptedConnection { private readonly SslStream _sslStream; diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Https/Microsoft.AspNetCore.Server.Kestrel.Https.csproj b/src/Microsoft.AspNetCore.Server.Kestrel.Https/Microsoft.AspNetCore.Server.Kestrel.Https.csproj index dc24ad8885..3631a1bd62 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel.Https/Microsoft.AspNetCore.Server.Kestrel.Https.csproj +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Https/Microsoft.AspNetCore.Server.Kestrel.Https.csproj @@ -4,7 +4,7 @@ HTTPS support for the ASP.NET Core Kestrel cross-platform web server. - netcoreapp2.0 + netstandard2.0 true aspnetcore;kestrel CS1591;$(NoWarn) diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions/Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.csproj b/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions/Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.csproj index cec4f50a65..b815a122bc 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions/Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.csproj +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions/Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.csproj @@ -4,7 +4,7 @@ Transport abstractions for the ASP.NET Core Kestrel cross-platform web server. - netcoreapp2.0 + netstandard2.0 true aspnetcore;kestrel CS1570;CS1571;CS1572;CS1573;CS1574;CS1591;$(NoWarn) @@ -18,7 +18,9 @@ - + + + diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.csproj b/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.csproj index 25552ef74c..19c7d923b2 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.csproj +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.csproj @@ -4,7 +4,7 @@ Libuv transport for the ASP.NET Core Kestrel cross-platform web server. - netcoreapp2.0 + netstandard2.0 true aspnetcore;kestrel true diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets/Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.csproj b/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets/Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.csproj index 69ce23ca38..eefdfe2be4 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets/Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.csproj +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets/Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.csproj @@ -4,7 +4,7 @@ Managed socket transport for the ASP.NET Core Kestrel cross-platform web server. - netcoreapp2.0 + netstandard2.0 true aspnetcore;kestrel true diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Microsoft.AspNetCore.Server.Kestrel.csproj b/src/Microsoft.AspNetCore.Server.Kestrel/Microsoft.AspNetCore.Server.Kestrel.csproj index 24171c9ed6..616830814d 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Microsoft.AspNetCore.Server.Kestrel.csproj +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Microsoft.AspNetCore.Server.Kestrel.csproj @@ -4,7 +4,7 @@ ASP.NET Core Kestrel cross-platform web server. - netcoreapp2.0 + netstandard2.0 true aspnetcore;kestrel CS1591;$(NoWarn) diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests/FrameRequestStreamTests.cs b/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests/FrameRequestStreamTests.cs index 8adad18cca..2250523f63 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests/FrameRequestStreamTests.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests/FrameRequestStreamTests.cs @@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests await Assert.ThrowsAsync(() => stream.WriteAsync(new byte[1], 0, 1)); } -#if NET46 +#if NET461 [Fact] public void BeginWriteThrows() { diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests/Microsoft.AspNetCore.Server.Kestrel.Core.Tests.csproj b/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests/Microsoft.AspNetCore.Server.Kestrel.Core.Tests.csproj index 59ed18e9b2..fb273003e7 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests/Microsoft.AspNetCore.Server.Kestrel.Core.Tests.csproj +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Core.Tests/Microsoft.AspNetCore.Server.Kestrel.Core.Tests.csproj @@ -3,8 +3,16 @@ - netcoreapp2.0 + netcoreapp2.0;net461 + netcoreapp2.0 true + + + true + win7-x64 diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/GeneratedCodeTests.cs b/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/GeneratedCodeTests.cs index 637756f2ba..99b8e9d88b 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/GeneratedCodeTests.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/GeneratedCodeTests.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +#if NETCOREAPP2_0 using System.IO; using Xunit; @@ -44,4 +45,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests } } } -} \ No newline at end of file +} +#elif NET461 +#else +#error Target framework needs to be updated +#endif diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.csproj b/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.csproj index 6eacb4bd2c..a7766fba47 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.csproj +++ b/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.csproj @@ -3,14 +3,16 @@ - netcoreapp2.0 + netcoreapp2.0;net461 + netcoreapp2.0 true - exe + true + win7-x64 @@ -19,10 +21,13 @@ + + + + - diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/Microsoft.AspNetCore.Server.Kestrel.Performance.csproj b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/Microsoft.AspNetCore.Server.Kestrel.Performance.csproj index 42fcca542b..281f7d50dc 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Performance/Microsoft.AspNetCore.Server.Kestrel.Performance.csproj +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Performance/Microsoft.AspNetCore.Server.Kestrel.Performance.csproj @@ -3,7 +3,8 @@ - netcoreapp2.0 + netcoreapp2.0;net461 + netcoreapp2.0 Exe true true diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Tests/Microsoft.AspNetCore.Server.Kestrel.Tests.csproj b/test/Microsoft.AspNetCore.Server.Kestrel.Tests/Microsoft.AspNetCore.Server.Kestrel.Tests.csproj index b694a050ec..dfe42a4b6c 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Tests/Microsoft.AspNetCore.Server.Kestrel.Tests.csproj +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Tests/Microsoft.AspNetCore.Server.Kestrel.Tests.csproj @@ -3,7 +3,8 @@ - netcoreapp2.0 + netcoreapp2.0;net461 + netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests.csproj b/test/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests.csproj index 70611f88a0..9fd8124c11 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests.csproj +++ b/test/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests/Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests.csproj @@ -3,9 +3,17 @@ - netcoreapp2.0 + netcoreapp2.0;net461 + netcoreapp2.0 true true + + + true + win7-x64 diff --git a/test/shared/TestResources.cs b/test/shared/TestResources.cs index 84a6880497..30e495bd2e 100644 --- a/test/shared/TestResources.cs +++ b/test/shared/TestResources.cs @@ -1,15 +1,14 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using System.IO; namespace Microsoft.AspNetCore.Testing { public static class TestResources { - private static readonly string _testCertificatePath = Path.Combine(AppContext.BaseDirectory, "testCert.pfx"); + private static readonly string _testCertificatePath = Path.Combine(Directory.GetCurrentDirectory(), "testCert.pfx"); public static string TestCertificatePath => _testCertificatePath; } -} \ No newline at end of file +}