abpframework/abp · error · FileNotFoundException
appsettings file could not be found. Path:{settingsFilePath}
Error message
appsettings file could not be found. Path:{settingsFilePath} What it means
Thrown by `ConfigReader.Read` when it cannot find `appsettings.json` in the supplied directory. Unlike most CLI errors this is a raw `FileNotFoundException` (not `CliUsageException`), so it surfaces as an unhandled exception. `ConfigReader` supplies CLI configuration such as proxy/API keys.
Source
Thrown at framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Configuration/ConfigReader.cs:18
using System.IO;
using System.Text.Json;
using System.Text.Json.Serialization;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.Cli.Configuration;
public class ConfigReader : IConfigReader, ITransientDependency
{
const string appSettingFileName = "appsettings.json";
public AbpCliConfig Read(string directory)
{
var settingsFilePath = Path.Combine(directory, appSettingFileName);
if (!File.Exists(settingsFilePath))
{
throw new FileNotFoundException($"appsettings file could not be found. Path:{settingsFilePath}");
}
var settingsFileContent = File.ReadAllText(settingsFilePath);
var documentOptions = new JsonDocumentOptions
{
CommentHandling = JsonCommentHandling.Skip
};
using (var document = JsonDocument.Parse(settingsFileContent, documentOptions))
{
if (document.RootElement.TryGetProperty("AbpCli", out var element))
{
var configJson = element.GetRawText();
var options = new JsonSerializerOptions
{
Converters =
{View on GitHub (pinned to 7ed43b1931)
Solutions
- Ensure `appsettings.json` exists in the directory passed to `ConfigReader.Read` (create an empty `{}` if you only need defaults).
- If calling from code, pass the correct base directory (e.g. `AppContext.BaseDirectory`).
- Reinstall/repair the ABP CLI global tool so its `appsettings.json` is restored: `dotnet tool uninstall -g Volo.Abp.Cli && dotnet tool install -g Volo.Abp.Cli`.
Example fix
// before
var config = new ConfigReader().Read("/wrong/path");
// after
var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (!File.Exists(Path.Combine(dir, "appsettings.json")))
File.WriteAllText(Path.Combine(dir, "appsettings.json"), "{}");
var config = new ConfigReader().Read(dir); Defensive patterns
Strategy: try-catch
Validate before calling
var dir = AppContext.BaseDirectory;
var settingsPath = Path.Combine(dir, "appsettings.json");
if (!File.Exists(settingsPath))
File.WriteAllText(settingsPath, "{}"); // defaults
var config = new ConfigReader().Read(dir); Try / catch
AbpCliConfig config;
try { config = new ConfigReader().Read(dir); }
catch (FileNotFoundException ex) when (ex.FileName?.Contains("appsettings") == true)
{
logger.LogWarning("appsettings.json missing in {Dir}; using default config.", dir);
config = new AbpCliConfig();
} Prevention
- Ship a default `appsettings.json` next to the CLI tool.
- Pass `AppContext.BaseDirectory` rather than relative paths to ConfigReader.
- If writing tooling on top, fall back to an empty config when the file is absent.
When it happens
Trigger: The CLI's configuration loader is invoked with a directory that lacks `appsettings.json`, e.g. the ABP CLI tool directory, a fresh checkout, or a directory where the file was removed.
Common situations: Custom tooling that calls `ConfigReader.Read` directly with a wrong path; the CLI installed as a global tool whose directory is missing the default `appsettings.json`; permissions preventing the file from being read (the `File.Exists` returns false).
Related errors
- There are more than 1 config (abp-build-config.json) file in
- There is no solution file (*.sln or *.slnx) and {_buildConfi
- Remote origin is null for given repository !
- Couldn't find repository name using remote origin url !
- File {path} does not exist!
AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13).
Data as JSON: /api/errors/9840cdd3d1b06093.
Report an issue: GitHub.