Update Program.cs (#9988)

pull/9990/head
Pavel Krymets 2018-12-12 12:59:37 -08:00 committed by Luke Latham
parent 28f0f5459e
commit ad6e6062bd
1 changed files with 5 additions and 4 deletions

View File

@ -15,16 +15,17 @@ namespace SampleApp
public static void Main(string[] args)
{
var isService = !(Debugger.IsAttached || args.Contains("--console"));
var builder = CreateWebHostBuilder(
args.Where(arg => arg != "--console").ToArray());
if (isService)
{
var pathToExe = Process.GetCurrentProcess().MainModule.FileName;
var pathToContentRoot = Path.GetDirectoryName(pathToExe);
builder.UseContentRoot(pathToContentRoot);
Directory.SetCurrentDirectory(pathToContentRoot);
}
var builder = CreateWebHostBuilder(
args.Where(arg => arg != "--console").ToArray());
var host = builder.Build();
if (isService)