.net core 单文件发布,找不到appsettings.json的问题

解决方案

builder.Configuration.SetBasePath(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule?.FileName));
builder.Configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

来源:
https://stackoverflow.com/questions/58307558/how-can-i-get-my-net-core-3-single-file-app-to-find-the-appsettings-json-file

posted @ 2023-08-07 23:38  trykle  阅读(128)  评论(0编辑  收藏  举报