Fix creating projects with GB18030 chars#11015
Merged
danmoseley merged 1 commit intodotnet:mainfrom Aug 19, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where creating Aspire projects with GB18030 characters (Chinese characters) in the project name would fail due to encoding problems in MSBuild. The fix involves adding a UTF-8 byte order mark (BOM) to solution template files and re-enabling tests for this scenario.
Key changes:
- Re-enabled previously disabled test for project names with GB18030 characters
- Added UTF-8 BOM to all Aspire solution template files (.sln)
- Updated .NET SDK version from 9.0.200 to 9.0.304 to expose and validate the bug fix
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
tests/Aspire.Templates.Tests/TemplateTestsBase.cs |
Re-enabled test case for GB18030 character project names and updated test name |
src/Aspire.ProjectTemplates/templates/aspire-starter/9.4/Aspire-StarterApplication.1.sln |
Added UTF-8 BOM to solution template file |
src/Aspire.ProjectTemplates/templates/aspire-starter/9.3/Aspire-StarterApplication.1.sln |
Added UTF-8 BOM to solution template file |
src/Aspire.ProjectTemplates/templates/aspire-empty/9.4/AspireApplication.1.sln |
Added UTF-8 BOM to solution template file |
src/Aspire.ProjectTemplates/templates/aspire-empty/9.3/AspireApplication.1.sln |
Added UTF-8 BOM to solution template file |
eng/Versions.props |
Updated .NET SDK version from 9.0.200 to 9.0.304 and fixed comment |
davidfowl
approved these changes
Aug 19, 2025
Member
Author
|
if we do a 9.4.3 this possibly should be included |
Member
Author
|
/backport to release/9.4 |
Contributor
|
Started backporting to release/9.4: https://github.com/dotnet/aspire/actions/runs/17109951692 |
Contributor
|
@danmoseley backporting to "release/9.4" failed, the patch most likely resulted in conflicts: $ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: fixbom
Using index info to reconstruct a base tree...
M eng/Versions.props
M tests/Aspire.Templates.Tests/TemplateTestsBase.cs
Falling back to patching base and 3-way merge...
Auto-merging eng/Versions.props
CONFLICT (content): Merge conflict in eng/Versions.props
Auto-merging tests/Aspire.Templates.Tests/TemplateTestsBase.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 fixbom
Error: The process '/usr/bin/git' failed with exit code 128Please backport manually! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix #10528
Our template .sln files do not have a BOM. Until recently, MSBuild would read these with "Encoding.Default" ie., UTF-8 on .NET Core. They changed back to old code to reading with "Encoding.GetEncoding(0)" which on Windows gives "Western European (Windows)" - not the same. (Docs being fixed in dotnet/dotnet-api-docs#11712)
Reading a file containing GB18030 characters in UTF-8 encoding using "Western European" corrupts them. The solution parser does not validate they exist; the first place that discovers they don't are the Nuget targets.
Checklist
<remarks />and<code />elements on your triple slash comments?doc-ideatemplatebreaking-changetemplatediagnostictemplate