abpframework/abp · error · CliUsageException
Project name cannot be "{illegalProjectName}"! Specify a dif
Error message
Project name cannot be "{illegalProjectName}"! Specify a different name. What it means
Thrown by ProjectNameValidator.ValidateIllegalProjectName when the project name exactly equals (case-insensitive) one of the reserved/template names: MyCompanyName.MyProjectName, MyProjectName, or Windows device names CON, AUX, PRN, COM1, LPT2. These names are blocked because they are either unmodified template placeholders or invalid Windows filenames.
Source
Thrown at framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/ProjectNameValidator.cs:47
throw new CliUsageException("Project name cannot contain \"..\"! Specify a different name.");
}
}
private static void ValidateSurrogateOrControlChar(string projectName)
{
if (projectName.Any(chr => char.IsControl(chr) || char.IsSurrogate(chr)))
{
throw new CliUsageException("Project name cannot contain surrogate or control characters! Specify a different name.");
}
}
private static void ValidateIllegalProjectName(string projectName)
{
foreach (var illegalProjectName in IllegalProjectNames)
{
if (projectName.Equals(illegalProjectName, StringComparison.OrdinalIgnoreCase))
{
throw new CliUsageException("Project name cannot be \"" + illegalProjectName + "\"! Specify a different name.");
}
}
}
private static void ValidateIllegalKeywords(string projectName)
{
foreach (var illegalKeyword in IllegalKeywords)
{
if (projectName.Split(".").Contains(illegalKeyword))
{
throw new CliUsageException("Project name cannot contain the word \"" + illegalKeyword + "\". Specify a different name.");
}
}
}
public static void Validate(string projectName)
{
ValidateSurrogateOrControlChar(projectName);
View on GitHub (pinned to 7ed43b1931)
Solutions
- Choose a real, unique project name (e.g. Acme.BookStore) instead of the template placeholder.
- Avoid Windows device names (CON, AUX, PRN, COM1-9, LPT1-9) regardless of OS for portability.
- If generating programmatically, validate the candidate name with ProjectNameValidator.Validate() first.
Example fix
// before abp new MyProjectName abp new CON // after abp new Acme.BookStore abp new Acme.ConsoleApp
Defensive patterns
Strategy: validation
Validate before calling
static readonly HashSet<string> Reserved = new(StringComparer.OrdinalIgnoreCase)
{ "MyCompanyName.MyProjectName","MyProjectName","CON","AUX","PRN","COM1","LPT2" };
static void EnsureNotReserved(string name)
{
if (Reserved.Contains(name)) throw new ArgumentException($"'{name}' is reserved/invalid");
Volo.Abp.Cli.Utils.ProjectNameValidator.Validate(name);
} Prevention
- Never use the template placeholder as the final name.
- Avoid Windows device names for portability.
- Validate candidate names with ProjectNameValidator before CLI invocation.
When it happens
Trigger: Running `abp new MyProjectName` or `abp new CON` without renaming from the template default, or using a Windows-reserved device name.
Common situations: Forgetting to rename the default template placeholder; scripting `abp new` with the literal example name; choosing a name that collides with a Windows device name and would fail to create a directory on Windows.
Related errors
- Project name cannot contain ".."! Specify a different name.
- Project name cannot contain surrogate or control characters!
- Project name cannot contain the word "{illegalKeyword}". Spe
- DbMigrations folder path is missing!
- Module name is missing!
AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13).
Data as JSON: /api/errors/5e66de34d9a46b0d.
Report an issue: GitHub.