File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
src/Aspire.Hosting.Testing
tests/Aspire.Hosting.Testing.Tests Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -162,7 +162,6 @@ private static void PreConfigureBuilderOptions(
162
162
} ;
163
163
applicationOptions . Args = hostBuilderOptions . Args ;
164
164
165
- hostBuilderOptions . EnvironmentName = Environments . Development ;
166
165
hostBuilderOptions . ApplicationName = entryPointAssembly . GetName ( ) . Name ?? string . Empty ;
167
166
applicationOptions . AssemblyName = entryPointAssembly . GetName ( ) . Name ?? string . Empty ;
168
167
applicationOptions . DisableDashboard = true ;
@@ -264,6 +263,18 @@ private static void PostConfigureBuilderOptions(
264
263
foreach ( var ( key , value ) in envVars )
265
264
{
266
265
SetDefault ( key , value ) ;
266
+
267
+ // See https://github.com/dotnet/runtime/blob/8edaf7460777e791b6279b395a68a77533db2d20/src/libraries/Microsoft.Extensions.Hosting/src/HostApplicationBuilder.cs#L96
268
+ if ( key . StartsWith ( "DOTNET_" , StringComparison . OrdinalIgnoreCase ) )
269
+ {
270
+ SetDefault ( key [ "DOTNET_" . Length ..] , value ) ;
271
+ }
272
+
273
+ // See https://github.com/dotnet/aspnetcore/blob/4ce2db7b8d85c07cad2c59242edc19af6a91b0d7/src/DefaultBuilder/src/WebApplicationBuilder.cs#L38
274
+ if ( key . StartsWith ( "ASPNETCORE_" , StringComparison . OrdinalIgnoreCase ) )
275
+ {
276
+ SetDefault ( key [ "ASPNETCORE_" . Length ..] , value ) ;
277
+ }
267
278
}
268
279
}
269
280
}
Original file line number Diff line number Diff line change @@ -107,6 +107,20 @@ public async Task CreateAsyncWithOptions(bool genericEntryPoint)
107
107
}
108
108
}
109
109
110
+ [ Fact ]
111
+ public async Task CanSetEnvironment ( )
112
+ {
113
+ var builder = await DistributedApplicationTestingBuilder . CreateAsync < Projects . TestingAppHost1_AppHost > ( [ "--environment=Testing" ] ) ;
114
+ Assert . Equal ( "Testing" , builder . Environment . EnvironmentName ) ;
115
+ }
116
+
117
+ [ Fact ]
118
+ public async Task EnvironmentDefaultsToDevelopment ( )
119
+ {
120
+ var builder = await DistributedApplicationTestingBuilder . CreateAsync < Projects . TestingAppHost1_AppHost > ( ) ;
121
+ Assert . Equal ( Environments . Development , builder . Environment . EnvironmentName ) ;
122
+ }
123
+
110
124
[ Theory ]
111
125
[ RequiresDocker ]
112
126
[ InlineData ( false ) ]
You can’t perform that action at this time.
0 commit comments