[net11] Templates: Fix duplicate Empty/empty parameter crash in maui-blazor templates#34609
Conversation
There was a problem hiding this comment.
Pull request overview
Removes a case-insensitive duplicate template parameter (Empty vs empty) from the MAUI Blazor templates to prevent System.ArgumentException failures in newer .NET SDK templating when parsing template.json.
Changes:
- Removed the deprecated
Emptyboolean parameter from both Blazor templatetemplate.jsonfiles. - Updated the
SampleContentcomputed symbol expressions to rely only onemptyfor dotnet CLI hosts.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Templates/src/templates/maui-blazor/.template.config/template.json | Removes Empty symbol and updates SampleContent computed expression to use only empty. |
| src/Templates/src/templates/maui-blazor-solution/.template.config/template.json | Removes Empty symbol and updates SampleContent computed expression to use only empty. |
Comments suppressed due to low confidence (2)
src/Templates/src/templates/maui-blazor/.template.config/template.json:173
Emptywas removed from this template’ssymbols, butsrc/Templates/src/templates/maui-blazor/.template.config/dotnetcli.host.jsonstill containssymbolInfoforEmpty. That entry is now stale and can be removed to keep the CLI host configuration aligned with the template’s symbols (and avoid future confusion about whether--Emptyis supported).
"empty": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Configures whether to omit sample pages and styling that demonstrate basic usage patterns."
src/Templates/src/templates/maui-blazor-solution/.template.config/template.json:411
Emptywas removed from this template’ssymbols, butsrc/Templates/src/templates/maui-blazor-solution/.template.config/dotnetcli.host.jsonstill containssymbolInfoforEmpty. That entry is now stale and can be removed to keep the CLI host configuration aligned with the template’s symbols (and avoid future confusion about whether--Emptyis supported).
"empty": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Configures whether to omit sample pages and styling that demonstrate basic usage patterns."
7566d3e to
bce0075
Compare
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34609Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34609" |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/Templates/src/templates/maui-blazor-solution/.template.config/template.json:412
- After removing the
Emptysymbol, the template’s localization files still containsymbols/Empty/descriptionentries but nosymbols/empty/description. This can leave the--emptyparameter without localized help text (or cause stale localization keys to linger). Regenerate/update.template.config/localize/templatestrings*.jsonso the description is keyed toempty.
"IncludeSampleContent": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "true",
"displayName": "_Include sample pages",
"description": "Configures whether to add sample pages and styling to demonstrate basic usage patterns."
},
"empty": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Configures whether to omit sample pages and styling that demonstrate basic usage patterns."
},
| "IncludeSampleContent": { | ||
| "type": "parameter", | ||
| "datatype": "bool", | ||
| "defaultValue": "true", | ||
| "displayName": "_Include sample pages", | ||
| "description": "Configures whether to add sample pages and styling to demonstrate basic usage patterns." | ||
| }, | ||
| "Empty": { | ||
| "type": "parameter", | ||
| "datatype": "bool", | ||
| "defaultValue": "false", | ||
| "description": "Configures whether to omit sample pages and styling that demonstrate basic usage patterns." | ||
| }, | ||
| "empty": { | ||
| "type": "parameter", | ||
| "datatype": "bool", | ||
| "defaultValue": "false", | ||
| "description": "Configures whether to omit sample pages and styling that demonstrate basic usage patterns." | ||
| }, |
There was a problem hiding this comment.
After removing the Empty symbol, the template’s localization files still only define symbols/Empty/description (and there is no symbols/empty/description). This likely means the --empty option’s description won’t be localized (or will be looked up under a stale key). Regenerate/update the .template.config/localize/templatestrings*.json entries to use the empty symbol key instead of Empty.
|
|
Co-authored-by: mattleibow <1096616+mattleibow@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/maui/sessions/5d92997c-8acf-44d6-8eb7-bc127a174184
The Empty parameter was removed from template.json but references remained in the dotnetcli.host.json files for both maui-blazor and maui-blazor-solution templates. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rename the localization key to match the remaining lowercase 'empty' parameter after the PascalCase 'Empty' duplicate was removed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
e22344e to
9ce8709
Compare
|
|
|
/backport to release/11.0.1xx-preview3 |
|
Started backporting to |
…pty parameter crash in maui-blazor templates (#34646) Backport of #34609 to release/11.0.1xx-preview3 /cc @mattleibow @Copilot --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: mattleibow <1096616+mattleibow@users.noreply.github.com> Co-authored-by: Matthew Leibowitz <mattleibow@live.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Root Cause
The
maui-blazorandmaui-blazor-webtemplate.json files defined two symbols with effectively the same name:Empty(PascalCase) andempty(lowercase). This was intentional when added in #32227 —Emptywas kept as a hidden backward-compat alias for users who had used the old CLI flag.However, .NET 11's templating engine now performs case-insensitive key comparison when loading template symbols, causing it to throw:
This makes
dotnet new maui-blazoranddotnet new maui-blazor-webcompletely broken.Description of Change
maui-blazor/.template.config/template.json: Remove the duplicate"Empty"(PascalCase) parameter block.maui-blazor-solution/.template.config/template.json: Remove the duplicate"Empty"(PascalCase) parameter block.SampleContentcomputed expression (both files): Simplified from(!Empty && ...) && (!empty && ...)to just!empty && ...since theEmptyalias is gone.No other templates were found to have duplicate case-insensitive parameter keys.
Issues Fixed
Related: dotnet/templating#10025
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.