mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
In non-ASP.NET apps, default project path to current working directory. Fixes #1100.
This commit is contained in:
@@ -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
|
// Since .NET Core 1.1, the HTTP hosting model has become basically as fast as the Socket hosting model
|
||||||
//options.UseSocketHosting();
|
//options.UseSocketHosting();
|
||||||
|
|
||||||
options.ProjectPath = Directory.GetCurrentDirectory();
|
|
||||||
options.WatchFileExtensions = new string[] {}; // Don't watch anything
|
options.WatchFileExtensions = new string[] {}; // Don't watch anything
|
||||||
});
|
});
|
||||||
var serviceProvider = services.BuildServiceProvider();
|
var serviceProvider = services.BuildServiceProvider();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.AspNetCore.NodeServices.HostingModels;
|
using Microsoft.AspNetCore.NodeServices.HostingModels;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@@ -34,14 +35,18 @@ namespace Microsoft.AspNetCore.NodeServices
|
|||||||
InvocationTimeoutMilliseconds = DefaultInvocationTimeoutMilliseconds;
|
InvocationTimeoutMilliseconds = DefaultInvocationTimeoutMilliseconds;
|
||||||
WatchFileExtensions = (string[])DefaultWatchFileExtensions.Clone();
|
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<IHostingEnvironment>();
|
var hostEnv = serviceProvider.GetService<IHostingEnvironment>();
|
||||||
if (hostEnv != null)
|
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;
|
ProjectPath = hostEnv.ContentRootPath;
|
||||||
EnvironmentVariables["NODE_ENV"] = hostEnv.IsDevelopment() ? "development" : "production"; // De-facto standard values for Node
|
EnvironmentVariables["NODE_ENV"] = hostEnv.IsDevelopment() ? "development" : "production"; // De-facto standard values for Node
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ProjectPath = Directory.GetCurrentDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
var applicationLifetime = serviceProvider.GetService<IApplicationLifetime>();
|
var applicationLifetime = serviceProvider.GetService<IApplicationLifetime>();
|
||||||
if (applicationLifetime != null)
|
if (applicationLifetime != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user