Is there an existing issue for this?
Describe the bug
When using dotnet new aichatweb --provider [azureopenai,openai,ollama,githubmodels] --aspire -o my.aichatweb.project, if the project name or a related template class contains a dot (e.g. some.name), the generator creates a normalized class name with underscores (some_name) in the Projects namespace. However, in the generated Program.cs within the AppHost project, the original (non-normalized) name (some.name) is used in:
var webApp = builder.AddProject<Projects.some.name>("aichatweb-app");
This causes a build error because Projects.some.name does not exist, only Projects.some_name does. The issue appears with any of the providers and requires manual editing of Program.cs to use the normalized name. This should be handled automatically by the template or generator logic.
Expected Behavior
The generated Program.cs should use the normalized class name, e.g. Projects.some_name, to match the generated class and avoid build errors.
Steps To Reproduce
- Run
dotnet new aichatweb --provider openai --aspire -o my.aichatweb.project
- Use a project name or template parameter that contains a dot (e.g.
some.name)
- Configure the AI Model Provider
- Try to build the solution
- Observe the CS0234 build error referencing a missing type or namespace name
some.name in the namespace 'Projects'
- Manually change to
Projects.some_name in some.name.AppHost/Program.cs to fix the build
Exceptions (if any)
Build error: error CS0234: The type or namespace name 'some' does not exist in the namespace 'Projects' (are you missing an assembly reference?)
.NET Version info
dotnet --info
.NET SDK:
Version: 9.0.304
Commit: f12f5f689e
Workload version: 9.0.300-manifests.75243b89
MSBuild version: 17.14.16+5d8159c5f
Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.304\
Anything else?
- .NET Aspire version: 9.4.0-preview.1.25378.8
- The IDE: VS/VS Code
- This issue occurs with all listed providers: azureopenai, openai, ollama, githubmodels
- The issue is not reported in the issue tracker as of this writing.
Side note:
There is a related issue with template-generated class and namespace normalization when project or folder names contain characters not allowed in C# identifiers (such as #). While the code generator correctly normalizes these names (e.g., converting on#ly to on_ly) for type and namespace declarations, it fails to apply the same normalization in all code references—such as those in Web/Program.cs. This inconsistency causes build errors due to mismatched identifiers and requires manual intervention to resolve. For robust code generation, identifier normalization should be applied consistently across all generated files and references.
Is there an existing issue for this?
Describe the bug
When using
dotnet new aichatweb --provider [azureopenai,openai,ollama,githubmodels] --aspire -o my.aichatweb.project, if the project name or a related template class contains a dot (e.g.some.name), the generator creates a normalized class name with underscores (some_name) in theProjectsnamespace. However, in the generatedProgram.cswithin the AppHost project, the original (non-normalized) name (some.name) is used in:This causes a build error because
Projects.some.namedoes not exist, onlyProjects.some_namedoes. The issue appears with any of the providers and requires manual editing ofProgram.csto use the normalized name. This should be handled automatically by the template or generator logic.Expected Behavior
The generated
Program.csshould use the normalized class name, e.g.Projects.some_name, to match the generated class and avoid build errors.Steps To Reproduce
dotnet new aichatweb --provider openai --aspire -o my.aichatweb.projectsome.name)some.namein the namespace 'Projects'Projects.some_nameinsome.name.AppHost/Program.csto fix the buildExceptions (if any)
Build error:
error CS0234: The type or namespace name 'some' does not exist in the namespace 'Projects' (are you missing an assembly reference?).NET Version info
Anything else?