abpframework/abp · error · CliUsageException
Option folder should be a directory.
Error message
Option folder should be a directory.
What it means
CheckFolder throws a CliUsageException when --folder is non-empty and Path.HasExtension(folder) returns true, i.e. the value looks like a file (has an extension) rather than a directory. The folder option must be a directory path used as the proxy output location.
Source
Thrown at framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/CSharp/CSharpServiceProxyGenerator.cs:666
private static void CheckWorkDirectory(string directory)
{
if (!Directory.Exists(directory))
{
throw new CliUsageException("Specified directory does not exist.");
}
var projectFiles = Directory.GetFiles(directory, "*.csproj");
if (!projectFiles.Any())
{
throw new CliUsageException("No project file(csproj) found in the directory.");
}
}
private static void CheckFolder(string folder)
{
if (!folder.IsNullOrWhiteSpace() && Path.HasExtension(folder))
{
throw new CliUsageException("Option folder should be a directory.");
}
}
}
View on GitHub (pinned to 7ed43b1931)
Solutions
- Pass a directory path without a file extension: --folder src/app/proxies rather than --folder src/app/proxies.ts.
- If you intended to specify an output file, omit --folder and use the generator's default output convention.
- Re-run after correcting the value.
Example fix
// before abp generate-proxy -t csharp --folder Proxies/Service.cs // after abp generate-proxy -t csharp --folder Proxies/Service
Defensive patterns
Strategy: validation
Validate before calling
if (!string.IsNullOrWhiteSpace(folder) && Path.HasExtension(folder))
{ Console.Error.WriteLine($"--folder '{folder}' looks like a file; pass a directory."); return; } Type guard
static bool IsValidFolderOption(string folder) =>
string.IsNullOrWhiteSpace(folder) || !Path.HasExtension(folder); Prevention
- Document that --folder expects a directory, not a file.
- Validate user-supplied options in your wrapper script.
When it happens
Trigger: Passing --folder with a value like 'Proxies.cs' or 'src/Services/File.cs' that contains a dot-separated extension. Path.HasExtension treats anything after the last dot as an extension.
Common situations: Confusing --folder (output directory) with a file path; copy-pasting a file path from a tutorial; trailing '.ts' or '.cs' mistakenly appended.
Related errors
- Couldn't find any project/solution.
- package.json file not found
- angular.json file not found. You must run this command in th
- Specified directory does not exist.
- No project file(csproj) found in the directory.
AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13).
Data as JSON: /api/errors/2975846b60b65857.
Report an issue: GitHub.