diff --git a/src/Microsoft.AspNetCore.Hosting/Startup/StartupExceptionPage.cs b/src/Microsoft.AspNetCore.Hosting/Startup/StartupExceptionPage.cs index a77a9aa636..eb06f9388e 100644 --- a/src/Microsoft.AspNetCore.Hosting/Startup/StartupExceptionPage.cs +++ b/src/Microsoft.AspNetCore.Hosting/Startup/StartupExceptionPage.cs @@ -9,10 +9,10 @@ using System.IO; using System.Linq; using System.Reflection; using System.Runtime.ExceptionServices; +using System.Runtime.InteropServices; using System.Text; using System.Text.Encodings.Web; using Microsoft.Extensions.Internal; -using Microsoft.Extensions.PlatformAbstractions; using Microsoft.Extensions.StackTrace.Sources; namespace Microsoft.AspNetCore.Hosting @@ -233,8 +233,7 @@ namespace Microsoft.AspNetCore.Hosting private static string GenerateFooterEncoded() { - var environment = PlatformServices.Default.Runtime; - var runtimeType = HtmlEncodeAndReplaceLineBreaks(environment.RuntimeType); + var runtimeType = HtmlEncodeAndReplaceLineBreaks(Microsoft.Extensions.Internal.RuntimeEnvironment.RuntimeType); var runtimeDisplayName = runtimeType == "CoreCLR" ? ".NET Core" : runtimeType == "CLR" ? ".NET Framework" : "Mono"; #if NETSTANDARD1_3 var systemRuntimeAssembly = typeof(System.ComponentModel.DefaultValueAttribute).GetTypeInfo().Assembly; @@ -243,13 +242,28 @@ namespace Microsoft.AspNetCore.Hosting #else var clrVersion = HtmlEncodeAndReplaceLineBreaks(Environment.Version.ToString()); #endif - var runtimeArch = HtmlEncodeAndReplaceLineBreaks(environment.RuntimeArchitecture); + var runtimeArch = HtmlEncodeAndReplaceLineBreaks(RuntimeInformation.ProcessArchitecture.ToString()); var currentAssembly = typeof(StartupExceptionPage).GetTypeInfo().Assembly; var currentAssemblyVersion = currentAssembly.GetCustomAttribute().InformationalVersion; currentAssemblyVersion = HtmlEncodeAndReplaceLineBreaks(currentAssemblyVersion); - var os = HtmlEncodeAndReplaceLineBreaks(environment.OperatingSystem); - var osVersion = HtmlEncodeAndReplaceLineBreaks(environment.OperatingSystemVersion); + var osName = string.Empty; + var osVersion = string.Empty; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + osName = OSPlatform.Windows.ToString(); + osVersion = Microsoft.Extensions.Internal.RuntimeEnvironment.OperatingSystemVersion; + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + osName = OSPlatform.Linux.ToString(); + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + osName = OSPlatform.OSX.ToString(); + } + var os = HtmlEncodeAndReplaceLineBreaks(osName); + osVersion = HtmlEncodeAndReplaceLineBreaks(osVersion); return string.Format(CultureInfo.InvariantCulture, _errorFooterFormatString, runtimeDisplayName, runtimeArch, clrVersion, currentAssemblyVersion, os, osVersion); diff --git a/src/Microsoft.AspNetCore.Hosting/project.json b/src/Microsoft.AspNetCore.Hosting/project.json index 6d8e6efb1e..12a7336b40 100644 --- a/src/Microsoft.AspNetCore.Hosting/project.json +++ b/src/Microsoft.AspNetCore.Hosting/project.json @@ -30,6 +30,10 @@ "Microsoft.Extensions.DependencyInjection": "1.0.0-*", "Microsoft.Extensions.Logging": "1.0.0-*", "Microsoft.Extensions.PlatformAbstractions": "1.0.0-*", + "Microsoft.Extensions.RuntimeEnvironment.Sources": { + "type": "build", + "version": "1.0.0-*" + }, "Microsoft.Extensions.StackTrace.Sources": { "type": "build", "version": "1.0.0-*" @@ -39,7 +43,8 @@ "type": "build" }, "System.Diagnostics.DiagnosticSource": "4.0.0-*", - "System.Reflection.Metadata": "1.3.0-*" + "System.Reflection.Metadata": "1.3.0-*", + "System.Runtime.InteropServices.RuntimeInformation": "4.0.0-*" }, "frameworks": { "net451": {