Use Sources RuntimeEnvironment
This commit is contained in:
parent
808ee7e965
commit
7808a47ccc
|
|
@ -9,10 +9,10 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.ExceptionServices;
|
using System.Runtime.ExceptionServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Encodings.Web;
|
using System.Text.Encodings.Web;
|
||||||
using Microsoft.Extensions.Internal;
|
using Microsoft.Extensions.Internal;
|
||||||
using Microsoft.Extensions.PlatformAbstractions;
|
|
||||||
using Microsoft.Extensions.StackTrace.Sources;
|
using Microsoft.Extensions.StackTrace.Sources;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Hosting
|
namespace Microsoft.AspNetCore.Hosting
|
||||||
|
|
@ -233,8 +233,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
|
|
||||||
private static string GenerateFooterEncoded()
|
private static string GenerateFooterEncoded()
|
||||||
{
|
{
|
||||||
var environment = PlatformServices.Default.Runtime;
|
var runtimeType = HtmlEncodeAndReplaceLineBreaks(Microsoft.Extensions.Internal.RuntimeEnvironment.RuntimeType);
|
||||||
var runtimeType = HtmlEncodeAndReplaceLineBreaks(environment.RuntimeType);
|
|
||||||
var runtimeDisplayName = runtimeType == "CoreCLR" ? ".NET Core" : runtimeType == "CLR" ? ".NET Framework" : "Mono";
|
var runtimeDisplayName = runtimeType == "CoreCLR" ? ".NET Core" : runtimeType == "CLR" ? ".NET Framework" : "Mono";
|
||||||
#if NETSTANDARD1_3
|
#if NETSTANDARD1_3
|
||||||
var systemRuntimeAssembly = typeof(System.ComponentModel.DefaultValueAttribute).GetTypeInfo().Assembly;
|
var systemRuntimeAssembly = typeof(System.ComponentModel.DefaultValueAttribute).GetTypeInfo().Assembly;
|
||||||
|
|
@ -243,13 +242,28 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
#else
|
#else
|
||||||
var clrVersion = HtmlEncodeAndReplaceLineBreaks(Environment.Version.ToString());
|
var clrVersion = HtmlEncodeAndReplaceLineBreaks(Environment.Version.ToString());
|
||||||
#endif
|
#endif
|
||||||
var runtimeArch = HtmlEncodeAndReplaceLineBreaks(environment.RuntimeArchitecture);
|
var runtimeArch = HtmlEncodeAndReplaceLineBreaks(RuntimeInformation.ProcessArchitecture.ToString());
|
||||||
var currentAssembly = typeof(StartupExceptionPage).GetTypeInfo().Assembly;
|
var currentAssembly = typeof(StartupExceptionPage).GetTypeInfo().Assembly;
|
||||||
var currentAssemblyVersion = currentAssembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
|
var currentAssemblyVersion = currentAssembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
|
||||||
currentAssemblyVersion = HtmlEncodeAndReplaceLineBreaks(currentAssemblyVersion);
|
currentAssemblyVersion = HtmlEncodeAndReplaceLineBreaks(currentAssemblyVersion);
|
||||||
|
|
||||||
var os = HtmlEncodeAndReplaceLineBreaks(environment.OperatingSystem);
|
var osName = string.Empty;
|
||||||
var osVersion = HtmlEncodeAndReplaceLineBreaks(environment.OperatingSystemVersion);
|
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,
|
return string.Format(CultureInfo.InvariantCulture, _errorFooterFormatString, runtimeDisplayName, runtimeArch, clrVersion,
|
||||||
currentAssemblyVersion, os, osVersion);
|
currentAssemblyVersion, os, osVersion);
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,10 @@
|
||||||
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
|
"Microsoft.Extensions.DependencyInjection": "1.0.0-*",
|
||||||
"Microsoft.Extensions.Logging": "1.0.0-*",
|
"Microsoft.Extensions.Logging": "1.0.0-*",
|
||||||
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-*",
|
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-*",
|
||||||
|
"Microsoft.Extensions.RuntimeEnvironment.Sources": {
|
||||||
|
"type": "build",
|
||||||
|
"version": "1.0.0-*"
|
||||||
|
},
|
||||||
"Microsoft.Extensions.StackTrace.Sources": {
|
"Microsoft.Extensions.StackTrace.Sources": {
|
||||||
"type": "build",
|
"type": "build",
|
||||||
"version": "1.0.0-*"
|
"version": "1.0.0-*"
|
||||||
|
|
@ -39,7 +43,8 @@
|
||||||
"type": "build"
|
"type": "build"
|
||||||
},
|
},
|
||||||
"System.Diagnostics.DiagnosticSource": "4.0.0-*",
|
"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": {
|
"frameworks": {
|
||||||
"net451": {
|
"net451": {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue