@@ -410,6 +410,35 @@ public async Task ProjectWithLaunchProfileAddsHttpOrHttpsEndpointAddsToEnv()
410
410
Assert . False ( config . ContainsKey ( "ASPNETCORE_HTTPS_PORT" ) ) ;
411
411
}
412
412
413
+ [ Fact ]
414
+ public async Task ProjectWithMultipleLaunchProfileAppUrlsGetsAllUrls ( )
415
+ {
416
+ var appBuilder = CreateBuilder ( operation : DistributedApplicationOperation . Run ) ;
417
+
418
+ var builder = appBuilder . AddProject < TestProjectWithManyAppUrlsInLaunchSettings > ( "projectName" ) ;
419
+
420
+ // Need to allocated all the endpoints we get from the launch profile applicationUrl
421
+ var index = 0 ;
422
+ foreach ( var q in new [ ] { "http" , "http2" , "https" , "https2" , "https3" } )
423
+ {
424
+ builder . WithEndpoint ( q , e =>
425
+ {
426
+ e . AllocatedEndpoint = new ( e , "localhost" , e . Port ! . Value , targetPortExpression : $ "p{ index ++ } ") ;
427
+ } ) ;
428
+ }
429
+
430
+ using var app = appBuilder . Build ( ) ;
431
+ var appModel = app . Services . GetRequiredService < DistributedApplicationModel > ( ) ;
432
+ var projectResources = appModel . GetProjectResources ( ) ;
433
+ var resource = Assert . Single ( projectResources ) ;
434
+ var config = await EnvironmentVariableEvaluator . GetEnvironmentVariablesAsync ( resource , DistributedApplicationOperation . Run , TestServiceProvider . Instance ) ;
435
+
436
+ Assert . Equal ( "https://localhost:p2;http://localhost:p0;http://localhost:p1;https://localhost:p3;https://localhost:p4" , config [ "ASPNETCORE_URLS" ] ) ;
437
+
438
+ // The first https port is the one that should be used for ASPNETCORE_HTTPS_PORT
439
+ Assert . Equal ( "7144" , config [ "ASPNETCORE_HTTPS_PORT" ] ) ;
440
+ }
441
+
413
442
[ Fact ]
414
443
public void DisabledForwardedHeadersAddsAnnotationToProject ( )
415
444
{
@@ -618,4 +647,25 @@ public TestProjectWithLaunchSettings()
618
647
} ;
619
648
}
620
649
}
650
+
651
+ private sealed class TestProjectWithManyAppUrlsInLaunchSettings : BaseProjectWithProfileAndConfig
652
+ {
653
+ public TestProjectWithManyAppUrlsInLaunchSettings ( )
654
+ {
655
+ Profiles = new ( )
656
+ {
657
+ [ "https" ] = new ( )
658
+ {
659
+ CommandName = "Project" ,
660
+ CommandLineArgs = "arg1 arg2" ,
661
+ LaunchBrowser = true ,
662
+ ApplicationUrl = "https://localhost:7144;http://localhost:5193;http://localhost:5194;https://localhost:7145;https://localhost:7146" ,
663
+ EnvironmentVariables = new ( )
664
+ {
665
+ [ "ASPNETCORE_ENVIRONMENT" ] = "Development"
666
+ }
667
+ }
668
+ } ;
669
+ }
670
+ }
621
671
}
0 commit comments