@@ -179,9 +179,17 @@ public DistributedApplicationBuilder(DistributedApplicationOptions options)
179
179
// account for the path the AppHost is running from to disambiguate between different projects
180
180
// with the same name as seen in https://github.com/dotnet/aspire/issues/5413. For publish scenarios,
181
181
// we want to use a stable hash based only on the project name.
182
- var appHostShaBytes = SHA256 . HashData ( Encoding . UTF8 . GetBytes ( AppHostPath ) ) ;
183
- var appHostNameShaBytes = SHA256 . HashData ( Encoding . UTF8 . GetBytes ( appHostName ) ) ;
184
- var appHostSha = ExecutionContext . IsPublishMode ? Convert . ToHexString ( appHostNameShaBytes ) : Convert . ToHexString ( appHostShaBytes ) ;
182
+ string appHostSha ;
183
+ if ( ExecutionContext . IsPublishMode )
184
+ {
185
+ var appHostNameShaBytes = SHA256 . HashData ( Encoding . UTF8 . GetBytes ( appHostName ) ) ;
186
+ appHostSha = Convert . ToHexString ( appHostNameShaBytes ) ;
187
+ }
188
+ else
189
+ {
190
+ var appHostShaBytes = SHA256 . HashData ( Encoding . UTF8 . GetBytes ( AppHostPath ) ) ;
191
+ appHostSha = Convert . ToHexString ( appHostShaBytes ) ;
192
+ }
185
193
_innerBuilder . Configuration . AddInMemoryCollection ( new Dictionary < string , string ? >
186
194
{
187
195
[ "AppHost:Sha256" ] = appHostSha
@@ -244,6 +252,16 @@ public DistributedApplicationBuilder(DistributedApplicationOptions options)
244
252
}
245
253
) ;
246
254
}
255
+ else
256
+ {
257
+ // The dashboard is enabled but is unsecured. Set auth mode config setting to reflect this state.
258
+ _innerBuilder . Configuration . AddInMemoryCollection (
259
+ new Dictionary < string , string ? >
260
+ {
261
+ [ "AppHost:ResourceService:AuthMode" ] = nameof ( ResourceServiceAuthMode . Unsecured )
262
+ }
263
+ ) ;
264
+ }
247
265
248
266
_innerBuilder . Services . AddSingleton < DashboardCommandExecutor > ( ) ;
249
267
_innerBuilder . Services . AddOptions < TransportOptions > ( ) . ValidateOnStart ( ) . PostConfigure ( MapTransportOptionsFromCustomKeys ) ;
0 commit comments