Skip to content

[release/10.0] Backport fixes to templates derived *.dev.localhost hostnames in launch profiles#65048

Merged
wtgodbe merged 2 commits intorelease/10.0from
damianedwards/backport-template-hostname-fixes
Jan 14, 2026
Merged

[release/10.0] Backport fixes to templates derived *.dev.localhost hostnames in launch profiles#65048
wtgodbe merged 2 commits intorelease/10.0from
damianedwards/backport-template-hostname-fixes

Conversation

@DamianEdwards
Copy link
Member

@DamianEdwards DamianEdwards commented Jan 13, 2026

Backport fixes to templates derived *.dev.localhost hostnames in launch profiles

Backports fixes to the empty and blazor web templates that ensure that host name prefixes generated for new projects that opt-in to the --localhost-tld option don't violate RFC 952/1123.

Description

The template/tooling generates DNS names (e.g., hostnames or domain labels) that contain underscores (_) when the user opts-in to the --localhost-tld template option and the project name includes characters that are invalid in a C# class name. According to DNS hostname specifications (RFC 952 and RFC 1123), underscores are not valid characters in hostnames. This causes failures in environments and libraries that strictly validate DNS names (e.g., Kubernetes, Docker, cloud DNS, and DNS client libraries).

Fixes #64978

Customer Impact

Currently when opting in to using *.dev.localhost host names for a new project using the empty or blazor web project templates, depending on the name given to the project the generated host name prefix used in the project launch profiles may violate rules in RFC 952/1123 which can lead to it causing errors or being rejected in other systems during local development, e.g.:

  • DNS resolution errors in client libraries.
  • Browser can refuse to parse the host name if it starts with xn-- and is followed by characters that would make it an invalid IDN name.
  • Operational inconsistencies if environments silently mutate invalid names.
  • Developer confusion when template output contradicts DNS standards.

The generated host name can be edited directly in the project's Properties/launchSettings.json file to workaround this issue once the project is created.

Regression?

  • No

The option was newly added in .NET 10 and has had this behavior since its inclusion.

Risk

  • Low

Change to the template declared symbols and transforms only using established templating system capabilities.

Verification

  • Manual (required)
  • Automated

Unit tests are included.

Packaging changes reviewed?

  • N/A

Copilot AI and others added 2 commits January 13, 2026 13:14
…64988)

* Initial plan

* Add DNS-safe hostname forms and symbols to templates

Co-authored-by: DamianEdwards <249088+DamianEdwards@users.noreply.github.com>

* Add trimming of leading/trailing hyphens for DNS-safe hostnames

Co-authored-by: DamianEdwards <249088+DamianEdwards@users.noreply.github.com>

* Use distinct placeholder LocalhostTldHostNamePrefix for hostname replacement

Co-authored-by: DamianEdwards <249088+DamianEdwards@users.noreply.github.com>

* Add tests for DNS-compliant hostname generation with --localhost-tld

Co-authored-by: DamianEdwards <249088+DamianEdwards@users.noreply.github.com>

* Add tests for DNS-compliant hostname generation in Blazor templates

Co-authored-by: DamianEdwards <249088+DamianEdwards@users.noreply.github.com>

* Move VerifyDnsCompliantHostname to shared Project class

Co-authored-by: DamianEdwards <249088+DamianEdwards@users.noreply.github.com>

* Fix -n parameter conflict and add tests with numbers in project names

Co-authored-by: DamianEdwards <249088+DamianEdwards@users.noreply.github.com>

* Refactor DNS hostname tests to use Theory with InlineData

Co-authored-by: DamianEdwards <249088+DamianEdwards@users.noreply.github.com>

* Fix razorcomponent item test

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: DamianEdwards <249088+DamianEdwards@users.noreply.github.com>
Co-authored-by: Damian Edwards <damian@damianedwards.com>
@DamianEdwards DamianEdwards requested review from BrennanConroy and Copilot and removed request for Copilot January 13, 2026 21:16
@DamianEdwards DamianEdwards added the Servicing-consider Shiproom approval is required for the issue label Jan 13, 2026
@DamianEdwards DamianEdwards changed the title [release/10.0] Backport fixes to templates derived *.dev.localhost hostnames [release/10.0] Backport fixes to templates derived *.dev.localhost hostnames in launch profiles Jan 13, 2026
@DamianEdwards DamianEdwards requested a review from wtgodbe January 13, 2026 21:30
@wtgodbe wtgodbe added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Jan 14, 2026
@wtgodbe
Copy link
Member

wtgodbe commented Jan 14, 2026

Approved over email

@wtgodbe wtgodbe merged commit ae5295f into release/10.0 Jan 14, 2026
33 of 34 checks passed
@wtgodbe wtgodbe deleted the damianedwards/backport-template-hostname-fixes branch January 14, 2026 17:51
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0.3 milestone Jan 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Servicing-approved Shiproom has approved the issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments