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