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

  1. Ensure `appsettings.json` exists in the directory passed to `ConfigReader.Read` (create an empty `{}` if you only need defaults).
  2. If calling from code, pass the correct base directory (e.g. `AppContext.BaseDirectory`).
  3. 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

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


AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13). Data as JSON: /api/errors/9840cdd3d1b06093. Report an issue: GitHub.