Replace some of PlatformAbstractions with RuntimeInformation
This commit is contained in:
parent
92553ae77c
commit
f60aa7aa70
|
|
@ -4,10 +4,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.Extensions.Internal;
|
using Microsoft.Extensions.Internal;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.PlatformAbstractions;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Server.Testing
|
namespace Microsoft.AspNetCore.Server.Testing
|
||||||
{
|
{
|
||||||
|
|
@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Server.Testing
|
||||||
// app being run when running dotnet run
|
// app being run when running dotnet run
|
||||||
public static readonly string DotnetArgumentSeparator = "--";
|
public static readonly string DotnetArgumentSeparator = "--";
|
||||||
private static readonly bool IsWindows =
|
private static readonly bool IsWindows =
|
||||||
PlatformServices.Default.Runtime.OperatingSystem.Equals("Windows", StringComparison.OrdinalIgnoreCase);
|
RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
|
||||||
|
|
||||||
private readonly Stopwatch _stopwatch = new Stopwatch();
|
private readonly Stopwatch _stopwatch = new Stopwatch();
|
||||||
|
|
||||||
|
|
@ -200,14 +200,19 @@ namespace Microsoft.AspNetCore.Server.Testing
|
||||||
|
|
||||||
protected static string GetOSPrefix()
|
protected static string GetOSPrefix()
|
||||||
{
|
{
|
||||||
switch (PlatformServices.Default.Runtime.OperatingSystemPlatform)
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
{
|
{
|
||||||
case Platform.Linux: return "linux";
|
return "win";
|
||||||
case Platform.Darwin: return "darwin";
|
|
||||||
case Platform.Windows: return "win";
|
|
||||||
default:
|
|
||||||
throw new InvalidOperationException("Unrecognized operating system");
|
|
||||||
}
|
}
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||||
|
{
|
||||||
|
return "linux";
|
||||||
|
}
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||||
|
{
|
||||||
|
return "darwin";
|
||||||
|
}
|
||||||
|
throw new InvalidOperationException("Unrecognized operating system");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4,10 +4,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.AspNetCore.Server.Testing.Common;
|
using Microsoft.AspNetCore.Server.Testing.Common;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.PlatformAbstractions;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Server.Testing
|
namespace Microsoft.AspNetCore.Server.Testing
|
||||||
{
|
{
|
||||||
|
|
@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Server.Testing
|
||||||
DeploymentParameters.ApplicationType == ApplicationType.Portable ? ".dll" : "";
|
DeploymentParameters.ApplicationType == ApplicationType.Portable ? ".dll" : "";
|
||||||
var executable = Path.Combine(DeploymentParameters.PublishedApplicationRootPath, new DirectoryInfo(DeploymentParameters.ApplicationPath).Name + executableExtension);
|
var executable = Path.Combine(DeploymentParameters.PublishedApplicationRootPath, new DirectoryInfo(DeploymentParameters.ApplicationPath).Name + executableExtension);
|
||||||
|
|
||||||
if (DeploymentParameters.RuntimeFlavor == RuntimeFlavor.Clr && PlatformServices.Default.Runtime.OperatingSystemPlatform != Platform.Windows)
|
if (DeploymentParameters.RuntimeFlavor == RuntimeFlavor.Clr && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
{
|
{
|
||||||
executableName = "mono";
|
executableName = "mono";
|
||||||
executableArgs = executable;
|
executableArgs = executable;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
"Deployers/RemoteWindowsDeployer/RemotePSSessionHelper.ps1",
|
"Deployers/RemoteWindowsDeployer/RemotePSSessionHelper.ps1",
|
||||||
"Deployers/RemoteWindowsDeployer/StartServer.ps1",
|
"Deployers/RemoteWindowsDeployer/StartServer.ps1",
|
||||||
"Deployers/RemoteWindowsDeployer/StopServer.ps1"
|
"Deployers/RemoteWindowsDeployer/StopServer.ps1"
|
||||||
],
|
]
|
||||||
},
|
},
|
||||||
"description": "ASP.NET Core helpers to deploy applications to IIS Express, IIS, WebListener and Kestrel for testing.",
|
"description": "ASP.NET Core helpers to deploy applications to IIS Express, IIS, WebListener and Kestrel for testing.",
|
||||||
"packOptions": {
|
"packOptions": {
|
||||||
|
|
@ -25,10 +25,10 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0-*",
|
||||||
"Microsoft.AspNetCore.Testing": "1.0.0-*",
|
"Microsoft.AspNetCore.Testing": "1.0.0-*",
|
||||||
"Microsoft.Extensions.Logging.Abstractions": "1.0.0-*",
|
"Microsoft.Extensions.Logging.Abstractions": "1.0.0-*",
|
||||||
"Microsoft.Extensions.FileProviders.Embedded": "1.0.0-*",
|
"Microsoft.Extensions.FileProviders.Embedded": "1.0.0-*",
|
||||||
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-*",
|
|
||||||
"Microsoft.Extensions.Process.Sources": {
|
"Microsoft.Extensions.Process.Sources": {
|
||||||
"type": "build",
|
"type": "build",
|
||||||
"version": "1.0.0-*"
|
"version": "1.0.0-*"
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting.Fakes;
|
using Microsoft.AspNetCore.Hosting.Fakes;
|
||||||
|
|
@ -398,7 +399,7 @@ namespace Microsoft.AspNetCore.Hosting
|
||||||
[Fact]
|
[Fact]
|
||||||
public void RelativeContentRootIsResolved()
|
public void RelativeContentRootIsResolved()
|
||||||
{
|
{
|
||||||
var contentRootNet451 = PlatformServices.Default.Runtime.OperatingSystemPlatform == Platform.Windows ?
|
var contentRootNet451 = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
|
||||||
"testroot" : "../../../../test/Microsoft.AspNetCore.Hosting.Tests/testroot";
|
"testroot" : "../../../../test/Microsoft.AspNetCore.Hosting.Tests/testroot";
|
||||||
|
|
||||||
var host = new WebHostBuilder()
|
var host = new WebHostBuilder()
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"System.Runtime.InteropServices.RuntimeInformation": "4.0.0-*",
|
||||||
"dotnet-test-xunit": "1.0.0-*",
|
"dotnet-test-xunit": "1.0.0-*",
|
||||||
"Microsoft.NETCore.Platforms": "1.0.1-*",
|
"Microsoft.NETCore.Platforms": "1.0.1-*",
|
||||||
"Microsoft.AspNetCore.Hosting": "1.0.0-*",
|
"Microsoft.AspNetCore.Hosting": "1.0.0-*",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue