- Notifications
You must be signed in to change notification settings - Fork845
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When usingdotnet 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 theProjects namespace. However, in the generatedProgram.cs within the AppHost project, the original (non-normalized) name (some.name) is used in:
varwebApp=builder.AddProject<Projects.some.name>("aichatweb-app");
This causes a build error becauseProjects.some.name does not exist, onlyProjects.some_name does. The issue appears with any of the providers and requires manual editing ofProgram.cs to use the normalized name. This should be handled automatically by the template or generator logic.
Expected Behavior
The generatedProgram.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.namein the namespace 'Projects' - Manually change to
Projects.some_nameinsome.name.AppHost/Program.csto 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+5d8159c5fRuntime 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., convertingon#lytoon_ly) for type and namespace declarations, it fails to apply the same normalization in all code references—such as those inWeb/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.