From 722aa519c2a447c2d2471c53d7f87c9fab1754c5 Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Mon, 24 Nov 2025 06:52:09 -0500 Subject: [PATCH 1/7] Further work on standalone WASM environments --- aspnetcore/blazor/fundamentals/environments.md | 16 +++++++++++++++- .../aspnetcore-10/includes/blazor.md | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/aspnetcore/blazor/fundamentals/environments.md b/aspnetcore/blazor/fundamentals/environments.md index 2b7d3da2993d..ea303a78f57e 100644 --- a/aspnetcore/blazor/fundamentals/environments.md +++ b/aspnetcore/blazor/fundamentals/environments.md @@ -38,7 +38,7 @@ On the client for a Blazor Web App, the environment is determined from the serve ``` -For a standalone Blazor WebAssembly app, set the environment with the `` property in the app's project file (`.csproj`). The following example sets the `Staging` environment: +For a standalone Blazor WebAssembly app, set the environment with the `` MSBuild property in the app's project file (`.csproj`). The following example sets the `Staging` environment: ```xml Staging @@ -46,6 +46,20 @@ For a standalone Blazor WebAssembly app, set the environment with the `` can be set during publish. For example, you can set the value based on the app's configuration in Visual Studio: + +```xml + + Development + + + + Production + +``` + +Another alternative is to create a custom server-side web API endpoint. The standalone Blazor WebAssembly app requests its environment from the web API either at app startup or on-demand while it's running. For general information on calling a web API from a Blazor app, see . + :::moniker-end :::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0" diff --git a/aspnetcore/release-notes/aspnetcore-10/includes/blazor.md b/aspnetcore/release-notes/aspnetcore-10/includes/blazor.md index 649280c8c0ef..65a17c54b44a 100644 --- a/aspnetcore/release-notes/aspnetcore-10/includes/blazor.md +++ b/aspnetcore/release-notes/aspnetcore-10/includes/blazor.md @@ -207,6 +207,8 @@ The default environments are: * `Development` for build. * `Production` for publish. +For more information, see . + ### Boot configuration file inlined Blazor's boot configuration, which prior to the release of .NET 10 existed in a file named `blazor.boot.json`, has been inlined into the `dotnet.js` script. This only affects developers who are interacting directly with the `blazor.boot.json` file, such as when developers are: From f3f0c04e3460cd959f584aee6594733a0ec351bb Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Mon, 24 Nov 2025 07:19:14 -0500 Subject: [PATCH 2/7] Updates --- .../blazor/fundamentals/environments.md | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/aspnetcore/blazor/fundamentals/environments.md b/aspnetcore/blazor/fundamentals/environments.md index ea303a78f57e..e3e482f49f76 100644 --- a/aspnetcore/blazor/fundamentals/environments.md +++ b/aspnetcore/blazor/fundamentals/environments.md @@ -46,19 +46,41 @@ For a standalone Blazor WebAssembly app, set the environment with the `` can be set during publish. For example, you can set the value based on the app's configuration in Visual Studio: +There are several approaches for setting the environment in a standalone Blazor WebAssembly app: -```xml - - Development - +* Set the property value when `dotnet build` or `dotnet publish` is executed. The following example sets the environment to `Staging` when an app is published: - - Production - -``` + ```dotnetcli + dotnet publish -p:WasmApplicationEnvironmentName=Staging + ``` + +* Set the property during build or publish based on the app's configuration in Visual Studio. The following property groups can be used in the app's project file or any publish configuration file (`.pubxml`). Add additional property groups for other build configurations in use. + + ```xml + + Development + + + + Production + + ``` + +* The environment can be set based on the use of a publish profile. The first condition in the following example covers setting the environment when any publish profile is used, while the second condition sets the environment to `Development` when building the app: + + ```xml + + + Production + + + + Development + + + ``` -Another alternative is to create a custom server-side web API endpoint. The standalone Blazor WebAssembly app requests its environment from the web API either at app startup or on-demand while it's running. For general information on calling a web API from a Blazor app, see . +* Create a custom server-side web API endpoint. The standalone Blazor WebAssembly app requests its environment from the web API either at app startup or on-demand while it's running. For general information on calling a web API from a Blazor app, see . :::moniker-end From 91e87950557cce41be580105c861559557be4ac8 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Mon, 24 Nov 2025 07:26:36 -0500 Subject: [PATCH 3/7] Update aspnetcore/blazor/fundamentals/environments.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- aspnetcore/blazor/fundamentals/environments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/blazor/fundamentals/environments.md b/aspnetcore/blazor/fundamentals/environments.md index e3e482f49f76..a8273b11867e 100644 --- a/aspnetcore/blazor/fundamentals/environments.md +++ b/aspnetcore/blazor/fundamentals/environments.md @@ -66,7 +66,7 @@ There are several approaches for setting the environment in a standalone Blazor ``` -* The environment can be set based on the use of a publish profile. The first condition in the following example covers setting the environment when any publish profile is used, while the second condition sets the environment to `Development` when building the app: +* The environment can be set based on the use of a publish profile. The first condition in the following example covers setting the environment when any publish profile is used, while the second condition sets the environment to `Development` when no publish profile is used (applies to both build and publish operations without a profile): ```xml From 147e4b49b41b2953b313000d2d3d3edb341e1d46 Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Mon, 24 Nov 2025 07:29:21 -0500 Subject: [PATCH 4/7] Updates --- aspnetcore/blazor/fundamentals/environments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/blazor/fundamentals/environments.md b/aspnetcore/blazor/fundamentals/environments.md index a8273b11867e..2542e2c36e74 100644 --- a/aspnetcore/blazor/fundamentals/environments.md +++ b/aspnetcore/blazor/fundamentals/environments.md @@ -46,7 +46,7 @@ For a standalone Blazor WebAssembly app, set the environment with the ` Date: Wed, 26 Nov 2025 07:36:58 -0500 Subject: [PATCH 5/7] Updates --- aspnetcore/blazor/fundamentals/environments.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/aspnetcore/blazor/fundamentals/environments.md b/aspnetcore/blazor/fundamentals/environments.md index 2542e2c36e74..706dcb346d12 100644 --- a/aspnetcore/blazor/fundamentals/environments.md +++ b/aspnetcore/blazor/fundamentals/environments.md @@ -69,18 +69,18 @@ There are several approaches for setting the environment in a standalone Blazor * The environment can be set based on the use of a publish profile. The first condition in the following example covers setting the environment when any publish profile is used, while the second condition sets the environment to `Development` when no publish profile is used (applies to both build and publish operations without a profile): ```xml - - - Production - - - - Development - + + Production + + + + Development ``` -* Create a custom server-side web API endpoint. The standalone Blazor WebAssembly app requests its environment from the web API either at app startup or on-demand while it's running. For general information on calling a web API from a Blazor app, see . +* Create a custom server-side web API endpoint. The standalone Blazor WebAssembly app requests its environment from the web API either at app startup or on-demand while it's running. The value should be passed to [`WebAssemblyStartOptions`](https://github.com/dotnet/aspnetcore/blob/main/src/Components/Web.JS/src/Platform/WebAssemblyStartOptions.ts#L7) or with [`withApplicationEnvironment`](https://github.com/dotnet/aspnetcore/blob/main/src/Components/dotnet-runtime-js/dotnet.d.ts#L110). + + [!INCLUDE[](~/includes/aspnetcore-repo-ref-source-links.md)] :::moniker-end From fd0718ddbdf27dfcf2b31c0c10fb9d61e7991340 Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Wed, 26 Nov 2025 07:42:18 -0500 Subject: [PATCH 6/7] Updates --- aspnetcore/blazor/fundamentals/environments.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/aspnetcore/blazor/fundamentals/environments.md b/aspnetcore/blazor/fundamentals/environments.md index 706dcb346d12..c79ef7cfa263 100644 --- a/aspnetcore/blazor/fundamentals/environments.md +++ b/aspnetcore/blazor/fundamentals/environments.md @@ -66,16 +66,16 @@ There are several approaches for setting the environment in a standalone Blazor ``` -* The environment can be set based on the use of a publish profile. The first condition in the following example covers setting the environment when any publish profile is used, while the second condition sets the environment to `Development` when no publish profile is used (applies to both build and publish operations without a profile): +* The environment can be set based on the use of a publish profile. The first condition in the following example sets the environment to `Development` when no publish profile is used (applies to both build and publish operations without a profile), while the second condition covers setting the environment to `Production` when any publish profile is used: ```xml - - Production - - Development + + + Production + ``` * Create a custom server-side web API endpoint. The standalone Blazor WebAssembly app requests its environment from the web API either at app startup or on-demand while it's running. The value should be passed to [`WebAssemblyStartOptions`](https://github.com/dotnet/aspnetcore/blob/main/src/Components/Web.JS/src/Platform/WebAssemblyStartOptions.ts#L7) or with [`withApplicationEnvironment`](https://github.com/dotnet/aspnetcore/blob/main/src/Components/dotnet-runtime-js/dotnet.d.ts#L110). From acc8ff059983364d8014ae33db555203b096043e Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Wed, 26 Nov 2025 07:43:33 -0500 Subject: [PATCH 7/7] Updates --- aspnetcore/blazor/fundamentals/environments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/blazor/fundamentals/environments.md b/aspnetcore/blazor/fundamentals/environments.md index c79ef7cfa263..373a1cf17a09 100644 --- a/aspnetcore/blazor/fundamentals/environments.md +++ b/aspnetcore/blazor/fundamentals/environments.md @@ -66,7 +66,7 @@ There are several approaches for setting the environment in a standalone Blazor ``` -* The environment can be set based on the use of a publish profile. The first condition in the following example sets the environment to `Development` when no publish profile is used (applies to both build and publish operations without a profile), while the second condition covers setting the environment to `Production` when any publish profile is used: +* The environment can be set based on the use of a publish profile. In the following example, the first condition sets the environment to `Development` when no publish profile is used (applies to both build and publish operations without a profile), while the second condition covers setting the environment to `Production` when any publish profile is used: ```xml