.net core 单文件发布,找不到appsettings.json的问题
解决方案
config.SetBasePath(GetBasePath());
config.AddJsonFile("appsettings.json", false);
private string GetBasePath()
{
using var processModule = Process.GetCurrentProcess().MainModule;
return Path.GetDirectoryName(processModule?.FileName);
}
来源:
https://stackoverflow.com/questions/58307558/how-can-i-get-my-net-core-3-single-file-app-to-find-the-appsettings-json-file
文章结尾