abpframework/abp · error · CliUsageException

Angular project path can not be empty

Error message

Angular project path can not be empty

What it means

Thrown by CreateAngularLibraryAsync during ABP CLI project creation when the workingDirectory parameter (path to the Angular app folder) is null or whitespace. In the normal flow, this value comes from Path.Combine(Directory.GetCurrentDirectory(), "apps", "angular") in ConfigureAngularAfterMicroserviceServiceCreatedAsync, so it is effectively an internal/edge-case guard. The method then runs 'npx ng g @abp/ng.schematics:create-lib' in that directory to scaffold an Angular library for a microservice service template.

Source

Thrown at framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs:801

        Logger.LogInformation(result);
    }

    protected virtual async Task<string> CreateAngularLibraryAsync(
        string libraryName,
        string workingDirectory,
        bool isSecondaryEndpoint = false,
        bool isModuleTemplate = true,
        bool isOverride = true)
    {
        //TODO: Can we improve this validations ?
        if (string.IsNullOrWhiteSpace(libraryName))
        {
            throw new CliUsageException("Angular library name can not be empty");
        }

        if (string.IsNullOrWhiteSpace(workingDirectory))
        {
            throw new CliUsageException("Angular project path can not be empty");
        }

        var commandBuilder = new StringBuilder($"npx ng g @abp/ng.schematics:create-lib --package-name {libraryName}");

        commandBuilder.Append($" --is-secondary-entrypoint {isSecondaryEndpoint.ToString().ToLowerInvariant()}");
        commandBuilder.Append($" --is-module-template {isModuleTemplate.ToString().ToLowerInvariant()}");
        commandBuilder.Append($" --override {isOverride.ToString().ToLowerInvariant()}");

        var result = CmdHelper.RunCmdAndGetOutput(commandBuilder.ToString(), workingDirectory);
        return await Task.FromResult(result);
    }

    public static class Options
    {
        public static class Template
        {
            public const string Short = "t";
            public const string Long = "template";

View on GitHub (pinned to 7ed43b1931)

Solutions

  1. Ensure you run the 'abp' CLI from the solution root directory that still exists
  2. Verify the microservice solution has the expected folder structure (apps/angular should exist or be creatable)
  3. If subclassing ProjectCreationCommandBase, ensure you pass a valid non-empty workingDirectory to CreateAngularLibraryAsync
  4. Check that the output folder specified during 'abp new' exists and is writable
Defensive patterns

Strategy: validation

Validate before calling

// Before calling CreateAngularLibraryAsync in a subclass or test:
if (string.IsNullOrWhiteSpace(workingDirectory))
{
    throw new ArgumentException("workingDirectory must not be empty", nameof(workingDirectory));
}
if (!Directory.Exists(workingDirectory))
{
    throw new DirectoryNotFoundException($"Angular app directory not found: {workingDirectory}");
}

Try / catch

try
{
    var result = await CreateAngularLibraryAsync(libraryName, angularAppPath);
}
catch (CliUsageException ex) when (ex.Message.Contains("Angular project path"))
{
    Logger.LogError("Angular project path was empty. Ensure you are running from a valid solution root directory.");
    throw;
}

Prevention

When it happens

Trigger: Called during microservice service template creation (ConfigureAngularAfterMicroserviceServiceCreatedAsync at line 761) when the UI framework is Angular. The workingDirectory is computed as Path.Combine(rootPath, "apps", "angular") where rootPath = Directory.GetCurrentDirectory(). An empty/whitespace result would require the current working directory to be in an abnormal state (e.g., deleted at runtime, sandboxed environment with broken cwd).

Common situations: Running the CLI from a directory that was deleted or unmounted mid-operation, sandboxed/containerized environments where the working directory resolves to empty, or a custom subclass overriding CreateAngularLibraryAsync with a bad path argument. Extremely rare under normal usage.

Related errors


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