From a40adab38dba34458b25ecc2b3884278a8b2394c Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Mon, 21 Aug 2017 16:40:25 -0700 Subject: [PATCH] In non-ASP.NET apps, default project path to current working directory. Fixes #1100. --- samples/misc/LatencyTest/Program.cs | 1 - .../Configuration/NodeServicesOptions.cs | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/samples/misc/LatencyTest/Program.cs b/samples/misc/LatencyTest/Program.cs index 9d426b6..bafe4b9 100755 --- a/samples/misc/LatencyTest/Program.cs +++ b/samples/misc/LatencyTest/Program.cs @@ -21,7 +21,6 @@ namespace ConsoleApplication // Since .NET Core 1.1, the HTTP hosting model has become basically as fast as the Socket hosting model //options.UseSocketHosting(); - options.ProjectPath = Directory.GetCurrentDirectory(); options.WatchFileExtensions = new string[] {}; // Don't watch anything }); var serviceProvider = services.BuildServiceProvider(); diff --git a/src/Microsoft.AspNetCore.NodeServices/Configuration/NodeServicesOptions.cs b/src/Microsoft.AspNetCore.NodeServices/Configuration/NodeServicesOptions.cs index 73dd228..384abad 100644 --- a/src/Microsoft.AspNetCore.NodeServices/Configuration/NodeServicesOptions.cs +++ b/src/Microsoft.AspNetCore.NodeServices/Configuration/NodeServicesOptions.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Threading; using Microsoft.AspNetCore.NodeServices.HostingModels; using Microsoft.Extensions.Logging; @@ -34,14 +35,18 @@ namespace Microsoft.AspNetCore.NodeServices InvocationTimeoutMilliseconds = DefaultInvocationTimeoutMilliseconds; WatchFileExtensions = (string[])DefaultWatchFileExtensions.Clone(); - // In an ASP.NET environment, we can use the IHostingEnvironment data to auto-populate a few - // things that you'd otherwise have to specify manually var hostEnv = serviceProvider.GetService(); if (hostEnv != null) { + // In an ASP.NET environment, we can use the IHostingEnvironment data to auto-populate a few + // things that you'd otherwise have to specify manually ProjectPath = hostEnv.ContentRootPath; EnvironmentVariables["NODE_ENV"] = hostEnv.IsDevelopment() ? "development" : "production"; // De-facto standard values for Node } + else + { + ProjectPath = Directory.GetCurrentDirectory(); + } var applicationLifetime = serviceProvider.GetService(); if (applicationLifetime != null)