Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion aspnetcore/blazor/fundamentals/environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,50 @@ On the client for a Blazor Web App, the environment is determined from the serve
<!--Blazor-WebAssembly:{"environmentName":"Development", ...}-->
```

For a standalone Blazor WebAssembly app, set the environment with the `<WasmApplicationEnvironmentName>` 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 `<WasmApplicationEnvironmentName>` MSBuild property in the app's project file (`.csproj`). The following example sets the `Staging` environment:

```xml
<WasmApplicationEnvironmentName>Staging</WasmApplicationEnvironmentName>
```

The default environments are `Development` for build and `Production` for publish.

There are several approaches for setting the environment in a standalone Blazor WebAssembly app:

* 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:

```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
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<WasmApplicationEnvironmentName>Development</WasmApplicationEnvironmentName>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<WasmApplicationEnvironmentName>Production</WasmApplicationEnvironmentName>
</PropertyGroup>
```

* 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
<PropertyGroup>
<WasmApplicationEnvironmentName Condition="'$(PublishProfile)' != ''">
Production
</WasmApplicationEnvironmentName>

<WasmApplicationEnvironmentName Condition="'$(PublishProfile)' == ''">
Development
</WasmApplicationEnvironmentName>
</PropertyGroup>
```

* 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 <xref:blazor/call-web-api>.

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
Expand Down
2 changes: 2 additions & 0 deletions aspnetcore/release-notes/aspnetcore-10/includes/blazor.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ The default environments are:
* `Development` for build.
* `Production` for publish.

For more information, see <xref:blazor/fundamentals/environments#set-the-environment>.

### 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:
Expand Down