diff --git a/BlazorSwa.Template.csproj b/BlazorSwa.Template.csproj index 7638dd9..4b12821 100644 --- a/BlazorSwa.Template.csproj +++ b/BlazorSwa.Template.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 Template 0.3.0 BlazorSwa.Template diff --git a/README.md b/README.md index 99ed520..28c1218 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # BlazorSwa.Template -A project template for creating a Blazor WebAssembly app and an Azure Function api which will be hosted on Azure Static Web Apps. +A project template for creating a Blazor WebAssembly app and, optionally, an Azure Function api which will be hosted on Azure Static Web Apps. ## Requirements -.NET 6 SDK with Azure workload and Azure Functions v4 runtime must be installed. +.NET 8 SDK with Azure workload and Azure Functions v4 runtime must be installed. ## Installation You can install the package from [NuGet](https://www.nuget.org/packages/BlazorSwa.Template/) using this command from the .NET CLI: @@ -21,16 +21,12 @@ If you prefer Visual Studio to create the project, search *Blazor static web app ### Options The following option is available: -- **--api Isolated/InProcess**: specifies the Azure function project type (isolated runtime or in process). The default value is **Isolated**. +- **--include-api**: specifies whether add the azure function project (isolated runtime). The default value is **false**. ### Examples To create a Blazor WebAssembly project with an Azure Function project with isolated runtime, execute the following command from the .NET CLI: ``` -dotnet new blazorswa --api Isolated -n -``` -To create a Blazor WebAssembly project with an Azure Function project in process, execute the following command from the .NET CLI: -``` -dotnet new blazorswa --api InProcess -n +dotnet new blazorswa --include-api -n ``` ### Some tips diff --git a/content/BlazorSwaTemplate/.template.config/dotnetcli.host.json b/content/BlazorSwaTemplate/.template.config/dotnetcli.host.json index 432092e..2514813 100644 --- a/content/BlazorSwaTemplate/.template.config/dotnetcli.host.json +++ b/content/BlazorSwaTemplate/.template.config/dotnetcli.host.json @@ -1,8 +1,8 @@ { - "$schema": "http://json.schemastore.org/dotnetcli.host", + "$schema": "https://json.schemastore.org/dotnetcli.host", "symbolInfo": { - "IncludeAzureFunction": { - "longName": "include-func", + "IncludeApi": { + "longName": "include-api", "shortName": "" } } diff --git a/content/BlazorSwaTemplate/.template.config/template.json b/content/BlazorSwaTemplate/.template.config/template.json index 3aa58df..baf8446 100644 --- a/content/BlazorSwaTemplate/.template.config/template.json +++ b/content/BlazorSwaTemplate/.template.config/template.json @@ -1,5 +1,5 @@ { - "$schema": "http://json.schemastore.org/template", + "$schema": "https://json.schemastore.org/template", "author": "Alberto Mori", "classifications": [ "Web", "Blazor", "WebAssembly", "Azure", "Azure Functions", "Static Web Apps" ], "identity": "BlazorSwa.Template", @@ -33,13 +33,16 @@ ] }, { - "condition": "(IncludeAzureFunction)", + "condition": "(IncludeApi)", "rename": { "Api.Isolated": "Api" - } + }, + "exclude": [ + "BlazorSwaTemplate.Client/wwwroot/sample-data/**" + ] }, { - "condition": "(!IncludeAzureFunction)", + "condition": "(!IncludeApi)", "exclude": [ "BlazorSwaTemplate.Api.Isolated/**" ] @@ -53,10 +56,10 @@ } ], "symbols": { - "IncludeAzureFunction": { + "IncludeApi": { "type": "parameter", "datatype": "bool", - "defaultValue": "true", + "defaultValue": "false", "displayName": "Include Azure Function backend project", "description": "Whether to include the Azure Function backend project" }, diff --git a/content/BlazorSwaTemplate/BlazorSwaTemplate.Client/Pages/Weather.razor b/content/BlazorSwaTemplate/BlazorSwaTemplate.Client/Pages/Weather.razor index 253cf80..30efc3e 100644 --- a/content/BlazorSwaTemplate/BlazorSwaTemplate.Client/Pages/Weather.razor +++ b/content/BlazorSwaTemplate/BlazorSwaTemplate.Client/Pages/Weather.razor @@ -41,6 +41,10 @@ else protected override async Task OnInitializedAsync() { + @*#if (!IncludeApi) forecasts = await Http.GetFromJsonAsync("sample-data/weather.json"); + ##else + forecasts = await Http.GetFromJsonAsync("api/WeatherForecast"); + ##endif*@ } }