Skip to content

Commit

Permalink
[fix] 提前设置好当前目录,避免后续各种问题。fix: #4
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Sep 10, 2023
1 parent 5f4e2c2 commit c5caae2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions NewLife.Agent/ServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static void InitService()
if (!isService)
XTrace.UseConsole();

// 提前设置好当前目录,避免后续各种问题
Environment.CurrentDirectory = ".".GetBasePath();

typeof(ServiceBase).Assembly.WriteVersion();
Expand Down
4 changes: 4 additions & 0 deletions Zero.Web/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Threading;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
Expand Down Expand Up @@ -48,6 +49,9 @@ protected override void StartWork(String reason)
{
WriteLog("业务开始……");

// 提前设置好当前目录,避免后续各种问题
//Environment.CurrentDirectory = ".".GetFullPath();

_source = new CancellationTokenSource();
CreateHostBuilder(Args).Build().RunAsync(_source.Token);

Expand Down

0 comments on commit c5caae2

Please sign in to comment.