Skip to content

Commit d8476e5

Browse files
Support *.localhost TLD for local dev (#62593)
* Add *.localhost & *.internal SANs to dev cert Contributes to #62592 * Add --localhost-tld option to empty web * Add Kestrel support for .localhost TLD * Add --localhost-tld option to Blazor web template * Add --localhost-tld option to empty web F# template * Revert "Add --localhost-tld option to empty web F# template" This reverts commit b797233. * Fix blazor template * More blazor template fixes * Fix .sln file name in Blazor template * Address PR feedback * so optimal * Super optimal
1 parent c1f16b6 commit d8476e5

File tree

176 files changed

+351
-176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+351
-176
lines changed

src/Hosting/Hosting/src/GenericHost/GenericWebHostService.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ static string ExpandPorts(string ports, string scheme)
166166
foreach (var address in addresses)
167167
{
168168
Log.ListeningOnAddress(LifetimeLogger, address);
169+
if (LifetimeLogger.IsEnabled(LogLevel.Information))
170+
{
171+
if (address.Contains(".localhost", StringComparison.OrdinalIgnoreCase) && Uri.TryCreate(address, UriKind.Absolute, out var uri) && uri.Host.EndsWith(".localhost", StringComparison.OrdinalIgnoreCase))
172+
{
173+
// Log the localhost address without the sub-domain prefix too
174+
Log.ListeningOnAddress(LifetimeLogger, new UriBuilder(uri) { Host = "localhost" }.ToString());
175+
}
176+
}
169177
}
170178
}
171179

src/OpenApi/sample/Properties/launchSettings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
"$schema": "https://json.schemastore.org/launchsettings.json",
33
"iisSettings": {
44
"windowsAuthentication": false,
@@ -13,7 +13,7 @@
1313
"commandName": "Project",
1414
"dotnetRunMessages": true,
1515
"launchBrowser": true,
16-
"applicationUrl": "http://localhost:5051",
16+
"applicationUrl": "http://sample.localhost:5051",
1717
"environmentVariables": {
1818
"ASPNETCORE_ENVIRONMENT": "Development"
1919
}
@@ -22,7 +22,7 @@
2222
"commandName": "Project",
2323
"dotnetRunMessages": true,
2424
"launchBrowser": true,
25-
"applicationUrl": "https://localhost:7174;http://localhost:5051",
25+
"applicationUrl": "https://sample.localhost:7174;http://sample.localhost:5051",
2626
"environmentVariables": {
2727
"ASPNETCORE_ENVIRONMENT": "Development"
2828
}

src/ProjectTemplates/Web.ProjectTemplates/BlazorWeb-CSharp.Client.csproj.in renamed to src/ProjectTemplates/Web.ProjectTemplates/BlazorWebCSharp.Client.csproj.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<Nullable>enable</Nullable>
77
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
88
<StaticWebAssetProjectMode>Default</StaticWebAssetProjectMode>
9-
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">BlazorWeb-CSharp.Client</RootNamespace>
9+
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">BlazorWebCSharp._1.Client</RootNamespace>
1010
<AssemblyName Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">`$(AssemblyName.Replace(' ', '_'))</AssemblyName>
1111
<BlazorDisableThrowNavigationException>true</BlazorDisableThrowNavigationException>
1212
</PropertyGroup>

src/ProjectTemplates/Web.ProjectTemplates/BlazorWeb-CSharp.csproj.in renamed to src/ProjectTemplates/Web.ProjectTemplates/BlazorWebCSharp.csproj.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
7-
<UserSecretsId Condition="'$(IndividualLocalAuth)' == 'True'">aspnet-BlazorWeb-CSharp-53bc9b9d-9d6a-45d4-8429-2a2761773502</UserSecretsId>
7+
<UserSecretsId Condition="'$(IndividualLocalAuth)' == 'True'">aspnet-BlazorWebCSharp__1-53bc9b9d-9d6a-45d4-8429-2a2761773502</UserSecretsId>
88
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
9-
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">BlazorWeb-CSharp</RootNamespace>
9+
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">BlazorWebCSharp._1</RootNamespace>
1010
<AssemblyName Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">`$(AssemblyName.Replace(' ', '_'))</AssemblyName>
1111
<BlazorDisableThrowNavigationException>true</BlazorDisableThrowNavigationException>
1212
</PropertyGroup>
@@ -19,7 +19,7 @@
1919
<!--#endif -->
2020
<!--#if (UseWebAssembly || IndividualLocalAuth) -->
2121
<ItemGroup>
22-
<ProjectReference Include="..\BlazorWeb-CSharp.Client\BlazorWeb-CSharp.Client.csproj" Condition="'$(UseWebAssembly)' == 'True'" />
22+
<ProjectReference Include="..\BlazorWebCSharp.1.Client\BlazorWebCSharp.1.Client.csproj" Condition="'$(UseWebAssembly)' == 'True'" />
2323
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="${MicrosoftAspNetCoreComponentsWebAssemblyServerVersion}" Condition="'$(UseWebAssembly)' == 'True'" />
2424
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="${MicrosoftAspNetCoreDiagnosticsEntityFrameworkCoreVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" />
2525
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="${MicrosoftAspNetCoreIdentityEntityFrameworkCoreVersion}" Condition="'$(IndividualLocalAuth)' == 'True'" />

src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
<GeneratedContent Include="WebApi-FSharp.fsproj.in" OutputPath="content/WebApi-FSharp/Company.WebApplication1.fsproj" />
6161
<GeneratedContent Include="Worker-CSharp.csproj.in" OutputPath="content/Worker-CSharp/Company.Application1.csproj" />
6262
<GeneratedContent Include="Worker-FSharp.fsproj.in" OutputPath="content/Worker-FSharp/Company.Application1.fsproj" />
63-
<GeneratedContent Include="BlazorWeb-CSharp.csproj.in" OutputPath="content/BlazorWeb-CSharp/BlazorWeb-CSharp/BlazorWeb-CSharp.csproj" />
64-
<GeneratedContent Include="BlazorWeb-CSharp.Client.csproj.in" OutputPath="content/BlazorWeb-CSharp/BlazorWeb-CSharp.Client/BlazorWeb-CSharp.Client.csproj" />
63+
<GeneratedContent Include="BlazorWebCSharp.csproj.in" OutputPath="content/BlazorWeb-CSharp/BlazorWebCSharp.1/BlazorWebCSharp.1.csproj" />
64+
<GeneratedContent Include="BlazorWebCSharp.Client.csproj.in" OutputPath="content/BlazorWeb-CSharp/BlazorWebCSharp.1.Client/BlazorWebCSharp.1.Client.csproj" />
6565
<GeneratedContent Include="ComponentsWebAssembly-CSharp.csproj.in" OutputPath="content/ComponentsWebAssembly-CSharp/ComponentsWebAssembly-CSharp.csproj" />
6666
</ItemGroup>
6767

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/.template.config/dotnetcli.host.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
"UseProgramMain": {
5454
"longName": "use-program-main",
5555
"shortName": ""
56+
},
57+
"LocalhostTld": {
58+
"longName": "localhost-tld",
59+
"shortName": ""
5660
}
5761
},
5862
"usageExamples": [

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/.template.config/ide.host.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
"isVisible": true,
2626
"persistenceScope": "shared",
2727
"persistenceScopeName": "Microsoft"
28+
},
29+
{
30+
"id": "LocalhostTld",
31+
"isVisible": true,
32+
"persistenceScope": "shared",
33+
"persistenceScopeName": "Microsoft"
2834
}
2935
]
3036
}

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/.template.config/localize/templatestrings.cs.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
"symbols/NoHttps/description": "Určuje, jestli se má vypnout protokol HTTPS. Tato možnost platí jenom v případě, že se pro --auth nepoužívá jednotlivec.",
4040
"symbols/UseProgramMain/displayName": "Nepoužívat _příkazy nejvyšší úrovně",
4141
"symbols/UseProgramMain/description": "Určuje, jestli se má místo příkazů nejvyšší úrovně generovat explicitní třída Program a metoda Main.",
42+
"symbols/LocalhostTld/displayName": "Use the .localhost TLD in the aplication URL",
43+
"symbols/LocalhostTld/description": "Whether to combine the project name with the .localhost TLD in the application URL for local development, e.g. https://myapp.localhost:12345.",
4244
"postActions/restore/description": "Obnoví balíčky NuGet vyžadované tímto projektem.",
4345
"postActions/restore/manualInstructions/default/text": "Spustit dotnet restore"
4446
}

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/.template.config/localize/templatestrings.de.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
"symbols/NoHttps/description": "Ob HTTPS deaktiviert werden soll. Diese Option gilt nur, wenn \"Individual\" nicht für \"--auth\" verwendet wird.",
4040
"symbols/UseProgramMain/displayName": "Keine Anweisungen_der obersten Ebene verwenden",
4141
"symbols/UseProgramMain/description": "Gibt an, ob anstelle von Anweisungen der obersten Ebene eine explizite Programmklasse und eine Main-Methode generiert werden soll.",
42+
"symbols/LocalhostTld/displayName": "Use the .localhost TLD in the aplication URL",
43+
"symbols/LocalhostTld/description": "Whether to combine the project name with the .localhost TLD in the application URL for local development, e.g. https://myapp.localhost:12345.",
4244
"postActions/restore/description": "„NuGet-Pakete“ wiederherstellen, die für dieses Projekt erforderlich sind.",
4345
"postActions/restore/manualInstructions/default/text": "„dotnet restore“ ausführen"
4446
}

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/.template.config/localize/templatestrings.en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
"symbols/NoHttps/description": "Whether to turn off HTTPS. This option only applies if Individual isn't used for --auth.",
4040
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
4141
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
42+
"symbols/LocalhostTld/displayName": "Use the .localhost TLD in the aplication URL",
43+
"symbols/LocalhostTld/description": "Whether to combine the project name with the .localhost TLD in the application URL for local development, e.g. https://myapp.localhost:12345.",
4244
"postActions/restore/description": "Restore NuGet packages required by this project.",
4345
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
4446
}

0 commit comments

Comments
 (0)