From c5caae275e0ff5ae41010514bbd9564a0c87de9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=9F=B3=E5=A4=B4?= Date: Sun, 10 Sep 2023 17:10:10 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E6=8F=90=E5=89=8D=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=A5=BD=E5=BD=93=E5=89=8D=E7=9B=AE=E5=BD=95=EF=BC=8C=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E5=90=8E=E7=BB=AD=E5=90=84=E7=A7=8D=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82fix:=20https://github.com/NewLifeX/NewLife.Agent/issue?= =?UTF-8?q?s/4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NewLife.Agent/ServiceBase.cs | 1 + Zero.Web/Program.cs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/NewLife.Agent/ServiceBase.cs b/NewLife.Agent/ServiceBase.cs index 9fc7660..ec2b059 100644 --- a/NewLife.Agent/ServiceBase.cs +++ b/NewLife.Agent/ServiceBase.cs @@ -51,6 +51,7 @@ public static void InitService() if (!isService) XTrace.UseConsole(); + // 提前设置好当前目录,避免后续各种问题 Environment.CurrentDirectory = ".".GetBasePath(); typeof(ServiceBase).Assembly.WriteVersion(); diff --git a/Zero.Web/Program.cs b/Zero.Web/Program.cs index 42ae407..d98923c 100644 --- a/Zero.Web/Program.cs +++ b/Zero.Web/Program.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Threading; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Hosting; @@ -48,6 +49,9 @@ protected override void StartWork(String reason) { WriteLog("业务开始……"); + // 提前设置好当前目录,避免后续各种问题 + //Environment.CurrentDirectory = ".".GetFullPath(); + _source = new CancellationTokenSource(); CreateHostBuilder(Args).Build().RunAsync(_source.Token);