From 4ad38625c776dbc636394cb912b890423efd4a2c Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Wed, 28 Oct 2015 15:45:33 -0700 Subject: [PATCH] Get the current runtime path via PlatformServices.Default - This fixes an issue whith ApplicationDeployer on Mono. Instead of giving the dnx path, Process.GetCurrentProcess().MainModule.FileName would give the path to the Mono executable. --- .../Deployers/ApplicationDeployer.cs | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/Microsoft.AspNet.Server.Testing/Deployers/ApplicationDeployer.cs b/src/Microsoft.AspNet.Server.Testing/Deployers/ApplicationDeployer.cs index a8dfd0e17a..477348f7af 100644 --- a/src/Microsoft.AspNet.Server.Testing/Deployers/ApplicationDeployer.cs +++ b/src/Microsoft.AspNet.Server.Testing/Deployers/ApplicationDeployer.cs @@ -10,6 +10,7 @@ using System.Text.RegularExpressions; using System.Threading; using Microsoft.AspNet.Testing; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.PlatformAbstractions; namespace Microsoft.AspNet.Server.Testing { @@ -99,23 +100,7 @@ namespace Microsoft.AspNet.Server.Testing protected string PopulateChosenRuntimeInformation() { - string currentRuntimeBinPath = string.Empty; - if (TestPlatformHelper.IsMac && DeploymentParameters.RuntimeFlavor == RuntimeFlavor.CoreClr) - { - var path = Environment.GetEnvironmentVariable("PATH"); - currentRuntimeBinPath = path.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries). - Where(c => c.Contains("dnx-coreclr-darwin") || c.Contains("dnx-mono")).FirstOrDefault(); - - if (string.IsNullOrWhiteSpace(currentRuntimeBinPath)) - { - throw new Exception("Runtime not detected on the machine."); - } - } - else - { - // ex: runtimes/dnx-coreclr-win-x64.1.0.0-rc1-15844/bin - currentRuntimeBinPath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); - } + string currentRuntimeBinPath = PlatformServices.Default.Runtime.RuntimePath; Logger.LogInformation($"Current runtime path is : {currentRuntimeBinPath}"); var targetRuntimeName = new StringBuilder()