Skip to content

Conversation

@danmoseley
Copy link
Member

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.

  • Re-enable test for this case
  • Update 9.0 SDK we use to move from 9.0.200 (which works) to 9.0.304 (which exposes the bug) and validate tests fail.
  • Add BOM to our sln's.
  • Verified the whole solution now builds, ie., BOM is not necessary in the csproj or source files, as they assume UTF-8.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • [ x] Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • [x ] No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • [ x] No
  • Does the change require an update in our Aspire docs?

Copilot AI review requested due to automatic review settings August 19, 2025 22:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@danmoseley danmoseley enabled auto-merge (squash) August 19, 2025 23:11
@danmoseley danmoseley merged commit c563c45 into dotnet:main Aug 19, 2025
293 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 9.5 milestone Aug 19, 2025
@danmoseley danmoseley deleted the fixbom branch August 20, 2025 18:29
@danmoseley
Copy link
Member Author

if we do a 9.4.3 this possibly should be included

@danmoseley
Copy link
Member Author

/backport to release/9.4

@github-actions
Copy link
Contributor

@github-actions
Copy link
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 128

Please backport manually!

@github-actions github-actions bot locked and limited conversation to collaborators Sep 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AspireE2E][GB18030] An error occurred when creating an Aspire project using Chinese characters as the project name.

2 participants