Skip to content

Commit f3f0c04

Browse files
committed
Updates
1 parent 722aa51 commit f3f0c04

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

aspnetcore/blazor/fundamentals/environments.md

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,41 @@ For a standalone Blazor WebAssembly app, set the environment with the `<WasmAppl
4646

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

49-
The environment value for `<WasmApplicationEnvironmentName>` can be set during publish. For example, you can set the value based on the app's configuration in Visual Studio:
49+
There are several approaches for setting the environment in a standalone Blazor WebAssembly app:
5050

51-
```xml
52-
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
53-
<WasmApplicationEnvironmentName>Development</WasmApplicationEnvironmentName>
54-
</PropertyGroup>
51+
* 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:
5552

56-
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
57-
<WasmApplicationEnvironmentName>Production</WasmApplicationEnvironmentName>
58-
</PropertyGroup>
59-
```
53+
```dotnetcli
54+
dotnet publish -p:WasmApplicationEnvironmentName=Staging
55+
```
56+
57+
* 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.
58+
59+
```xml
60+
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
61+
<WasmApplicationEnvironmentName>Development</WasmApplicationEnvironmentName>
62+
</PropertyGroup>
63+
64+
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
65+
<WasmApplicationEnvironmentName>Production</WasmApplicationEnvironmentName>
66+
</PropertyGroup>
67+
```
68+
69+
* 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:
70+
71+
```xml
72+
<PropertyGroup>
73+
<WasmApplicationEnvironmentName Condition="'$(PublishProfile)' != ''">
74+
Production
75+
</WasmApplicationEnvironmentName>
76+
77+
<WasmApplicationEnvironmentName Condition="'$(PublishProfile)' == ''">
78+
Development
79+
</WasmApplicationEnvironmentName>
80+
</PropertyGroup>
81+
```
6082

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

6385
:::moniker-end
6486

0 commit comments

Comments
 (0)