Skip to content

Commit 426b8b4

Browse files
authored
[Blazor] Add new Blazor Web Template (#48285)
* Adds the new template `blazor` with options to use webassembly components and server components via `--use-wasm` and `--use-server`. * The template changes `fetchdata` found in other templates for `showdata` as the data is rendered from the server. * It includes the `counter` component only when server or webassembly modes have been selected.
1 parent 6c49e7b commit 426b8b4

Some content is hidden

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

61 files changed

+2567
-2
lines changed

src/ProjectTemplates/Shared/AspNetProcess.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ public async Task AssertPagesOk(IEnumerable<Page> pages)
117117
foreach (var page in pages)
118118
{
119119
await AssertOk(page.Url);
120-
await ContainsLinks(page);
120+
if (page.Links?.Count() > 0)
121+
{
122+
await ContainsLinks(page);
123+
}
121124
}
122125
}
123126

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<!--#if UseWebAssembly -->
5+
<TargetFrameworks>${DefaultNetCoreTargetFramework};${DefaultNetCoreTargetFramework}-browser</TargetFrameworks>
6+
<!--#else -->
7+
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
8+
<!--#endif -->
9+
<Nullable>enable</Nullable>
10+
<ImplicitUsings>enable</ImplicitUsings>
11+
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
12+
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">ComponentsWebAssembly-CSharp.Server</RootNamespace>
13+
<AssemblyName Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">`$(AssemblyName.Replace(' ', '_'))</AssemblyName>
14+
<!--#if UseWebAssembly && PWA -->
15+
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
16+
<!--#endif -->
17+
</PropertyGroup>
18+
<!--#if UseWebAssembly -->
19+
20+
<ItemGroup Condition="'$([MSBuild]::GetTargetPlatformIdentifier($(TargetFramework)))' == 'browser'">
21+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="${MicrosoftAspNetCoreComponentsWebAssemblyVersion}" />
22+
</ItemGroup>
23+
24+
<ItemGroup Condition="'$([MSBuild]::GetTargetPlatformIdentifier($(TargetFramework)))' == ''">
25+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="${MicrosoftAspNetCoreComponentsWebAssemblyServerVersion}" />
26+
</ItemGroup>
27+
<!--#endif -->
28+
<!--#if UseWebAssembly && PWA -->
29+
30+
<ItemGroup>
31+
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
32+
</ItemGroup>
33+
<!--#endif -->
34+
35+
</Project>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<GeneratedContent Include="WebApi-FSharp.fsproj.in" OutputPath="content/WebApi-FSharp/Company.WebApplication1.fsproj" />
6666
<GeneratedContent Include="Worker-CSharp.csproj.in" OutputPath="content/Worker-CSharp/Company.Application1.csproj" />
6767
<GeneratedContent Include="Worker-FSharp.fsproj.in" OutputPath="content/Worker-FSharp/Company.Application1.fsproj" />
68+
<GeneratedContent Include="Components-CSharp.csproj.in" OutputPath="content/Components-CSharp/Components-CSharp.csproj" />
6869
<GeneratedContent Include="ComponentsWebAssembly-CSharp.Client.csproj.in" OutputPath="content/ComponentsWebAssembly-CSharp/Client/ComponentsWebAssembly-CSharp.Client.csproj" />
6970
<GeneratedContent Include="ComponentsWebAssembly-CSharp.Shared.csproj.in" OutputPath="content/ComponentsWebAssembly-CSharp/Shared/ComponentsWebAssembly-CSharp.Shared.csproj" />
7071
<GeneratedContent Include="ComponentsWebAssembly-CSharp.Server.csproj.in" OutputPath="content/ComponentsWebAssembly-CSharp/Server/ComponentsWebAssembly-CSharp.Server.csproj" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"$schema": "http://json.schemastore.org/dotnetcli.host",
3+
"symbolInfo": {
4+
"skipRestore": {
5+
"longName": "no-restore",
6+
"shortName": ""
7+
},
8+
"PWA": {
9+
"longName": "pwa",
10+
"isHidden": true
11+
},
12+
"UseServer": {
13+
"longName": "use-server",
14+
"isHidden": true
15+
},
16+
"UseWebAssembly": {
17+
"longName": "use-wasm",
18+
"isHidden": true
19+
},
20+
"Framework": {
21+
"longName": "framework"
22+
},
23+
"kestrelHttpPort": {
24+
"isHidden": true
25+
},
26+
"kestrelHttpsPort": {
27+
"isHidden": true
28+
},
29+
"iisHttpPort": {
30+
"isHidden": true
31+
},
32+
"iisHttpsPort": {
33+
"isHidden": true
34+
},
35+
"ExcludeLaunchSettings": {
36+
"longName": "exclude-launch-settings",
37+
"shortName": ""
38+
},
39+
"UserSecretsId": {
40+
"isHidden": true
41+
},
42+
"NoHttps": {
43+
"longName": "no-https",
44+
"shortName": ""
45+
},
46+
"UseProgramMain": {
47+
"longName": "use-program-main",
48+
"shortName": ""
49+
}
50+
}
51+
}
Loading
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"$schema": "http://json.schemastore.org/ide.host",
3+
"order": 610,
4+
"icon": "icon.png",
5+
"disableHttpsSymbol": "NoHttps",
6+
"symbolInfo": [
7+
{
8+
"id": "UseServer",
9+
"isVisible": false,
10+
"persistenceScope": "templateGroup"
11+
},
12+
{
13+
"id": "UseWebAssembly",
14+
"isVisible": false,
15+
"persistenceScope": "templateGroup"
16+
},
17+
{
18+
"id": "PWA",
19+
"isVisible": false,
20+
"persistenceScope": "templateGroup"
21+
},
22+
{
23+
"id": "UseProgramMain",
24+
"isVisible": true,
25+
"persistenceScope": "shared",
26+
"persistenceScopeName": "Microsoft"
27+
}
28+
]
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"author": "Microsoft",
3+
"name": "Blazor Web App",
4+
"description": "A project template for creating a Blazor app hosted inside an ASP.NET app that runs on the server. This template can be used for web apps with rich dynamic user interfaces (UIs).",
5+
"symbols/Framework/description": "The target framework for the project.",
6+
"symbols/Framework/choices/net8.0/description": "Target net8.0",
7+
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
8+
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
9+
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
10+
"symbols/kestrelHttpsPort/description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used).",
11+
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
12+
"symbols/iisHttpsPort/description": "Port number to use for the IIS Express HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used).",
13+
"symbols/UseWebAssembly/displayName": "_Use interactive webassembly components",
14+
"symbols/UseWebAssembly/description": "If specified, configures the project to render components interactively on the browser using webassembly.",
15+
"symbols/UseServer/displayName": "_Use interactive server components",
16+
"symbols/UseServer/description": "If specified, configures the project to render components interactively on the server.",
17+
"symbols/PWA/displayName": "_Progressive Web Application",
18+
"symbols/PWA/description": "If specified, produces a Progressive Web Application (PWA) supporting installation and offline use.",
19+
"symbols/NoHttps/description": "Whether to turn off HTTPS. This option only applies if Individual, IndividualB2C, SingleOrg, or MultiOrg aren't used for --auth.",
20+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
21+
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
22+
"postActions/restore/description": "Restore NuGet packages required by this project.",
23+
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"author": "Microsoft",
3+
"name": "Blazor Web App",
4+
"description": "A project template for creating a Blazor app hosted inside an ASP.NET app that runs on the server. This template can be used for web apps with rich dynamic user interfaces (UIs).",
5+
"symbols/Framework/description": "The target framework for the project.",
6+
"symbols/Framework/choices/net8.0/description": "Target net8.0",
7+
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
8+
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
9+
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
10+
"symbols/kestrelHttpsPort/description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used).",
11+
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
12+
"symbols/iisHttpsPort/description": "Port number to use for the IIS Express HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used).",
13+
"symbols/UseWebAssembly/displayName": "_Use interactive webassembly components",
14+
"symbols/UseWebAssembly/description": "If specified, configures the project to render components interactively on the browser using webassembly.",
15+
"symbols/UseServer/displayName": "_Use interactive server components",
16+
"symbols/UseServer/description": "If specified, configures the project to render components interactively on the server.",
17+
"symbols/PWA/displayName": "_Progressive Web Application",
18+
"symbols/PWA/description": "If specified, produces a Progressive Web Application (PWA) supporting installation and offline use.",
19+
"symbols/NoHttps/description": "Whether to turn off HTTPS. This option only applies if Individual, IndividualB2C, SingleOrg, or MultiOrg aren't used for --auth.",
20+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
21+
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
22+
"postActions/restore/description": "Restore NuGet packages required by this project.",
23+
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"author": "Microsoft",
3+
"name": "Blazor Web App",
4+
"description": "A project template for creating a Blazor app hosted inside an ASP.NET app that runs on the server. This template can be used for web apps with rich dynamic user interfaces (UIs).",
5+
"symbols/Framework/description": "The target framework for the project.",
6+
"symbols/Framework/choices/net8.0/description": "Target net8.0",
7+
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
8+
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
9+
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
10+
"symbols/kestrelHttpsPort/description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used).",
11+
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
12+
"symbols/iisHttpsPort/description": "Port number to use for the IIS Express HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used).",
13+
"symbols/UseWebAssembly/displayName": "_Use interactive webassembly components",
14+
"symbols/UseWebAssembly/description": "If specified, configures the project to render components interactively on the browser using webassembly.",
15+
"symbols/UseServer/displayName": "_Use interactive server components",
16+
"symbols/UseServer/description": "If specified, configures the project to render components interactively on the server.",
17+
"symbols/PWA/displayName": "_Progressive Web Application",
18+
"symbols/PWA/description": "If specified, produces a Progressive Web Application (PWA) supporting installation and offline use.",
19+
"symbols/NoHttps/description": "Whether to turn off HTTPS. This option only applies if Individual, IndividualB2C, SingleOrg, or MultiOrg aren't used for --auth.",
20+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
21+
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
22+
"postActions/restore/description": "Restore NuGet packages required by this project.",
23+
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"author": "Microsoft",
3+
"name": "Blazor Web App",
4+
"description": "A project template for creating a Blazor app hosted inside an ASP.NET app that runs on the server. This template can be used for web apps with rich dynamic user interfaces (UIs).",
5+
"symbols/Framework/description": "The target framework for the project.",
6+
"symbols/Framework/choices/net8.0/description": "Target net8.0",
7+
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
8+
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
9+
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
10+
"symbols/kestrelHttpsPort/description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used).",
11+
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
12+
"symbols/iisHttpsPort/description": "Port number to use for the IIS Express HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used).",
13+
"symbols/UseWebAssembly/displayName": "_Use interactive webassembly components",
14+
"symbols/UseWebAssembly/description": "If specified, configures the project to render components interactively on the browser using webassembly.",
15+
"symbols/UseServer/displayName": "_Use interactive server components",
16+
"symbols/UseServer/description": "If specified, configures the project to render components interactively on the server.",
17+
"symbols/PWA/displayName": "_Progressive Web Application",
18+
"symbols/PWA/description": "If specified, produces a Progressive Web Application (PWA) supporting installation and offline use.",
19+
"symbols/NoHttps/description": "Whether to turn off HTTPS. This option only applies if Individual, IndividualB2C, SingleOrg, or MultiOrg aren't used for --auth.",
20+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
21+
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
22+
"postActions/restore/description": "Restore NuGet packages required by this project.",
23+
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"author": "Microsoft",
3+
"name": "Blazor Web App",
4+
"description": "A project template for creating a Blazor app hosted inside an ASP.NET app that runs on the server. This template can be used for web apps with rich dynamic user interfaces (UIs).",
5+
"symbols/Framework/description": "The target framework for the project.",
6+
"symbols/Framework/choices/net8.0/description": "Target net8.0",
7+
"symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.",
8+
"symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.",
9+
"symbols/kestrelHttpPort/description": "Port number to use for the HTTP endpoint in launchSettings.json.",
10+
"symbols/kestrelHttpsPort/description": "Port number to use for the HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used).",
11+
"symbols/iisHttpPort/description": "Port number to use for the IIS Express HTTP endpoint in launchSettings.json.",
12+
"symbols/iisHttpsPort/description": "Port number to use for the IIS Express HTTPS endpoint in launchSettings.json. This option is only applicable when the parameter no-https is not used (no-https will be ignored if either IndividualAuth or OrganizationalAuth is used).",
13+
"symbols/UseWebAssembly/displayName": "_Use interactive webassembly components",
14+
"symbols/UseWebAssembly/description": "If specified, configures the project to render components interactively on the browser using webassembly.",
15+
"symbols/UseServer/displayName": "_Use interactive server components",
16+
"symbols/UseServer/description": "If specified, configures the project to render components interactively on the server.",
17+
"symbols/PWA/displayName": "_Progressive Web Application",
18+
"symbols/PWA/description": "If specified, produces a Progressive Web Application (PWA) supporting installation and offline use.",
19+
"symbols/NoHttps/description": "Whether to turn off HTTPS. This option only applies if Individual, IndividualB2C, SingleOrg, or MultiOrg aren't used for --auth.",
20+
"symbols/UseProgramMain/displayName": "Do not use _top-level statements",
21+
"symbols/UseProgramMain/description": "Whether to generate an explicit Program class and Main method instead of top-level statements.",
22+
"postActions/restore/description": "Restore NuGet packages required by this project.",
23+
"postActions/restore/manualInstructions/default/text": "Run 'dotnet restore'"
24+
}

0 commit comments

Comments
 (0)