From 340f604fa6539918ab3da79de2ab79045c1633f7 Mon Sep 17 00:00:00 2001 From: Brennan Date: Fri, 8 Dec 2023 11:33:30 -0800 Subject: [PATCH] Revert "Missing applicationUrl does not inherit dashboard url (#1169)" (#1303) This reverts commit d1753a22fed7a49a49d2e28755f4bc3f368bea02. --- Aspire.sln | 7 ----- src/Aspire.Hosting/Dcp/ApplicationExecutor.cs | 12 ++++----- .../DistributedApplicationTests.cs | 26 ------------------- .../TestProject.AppHost.csproj | 1 - .../TestProject.LaunchSettings/Program.cs | 10 ------- .../Properties/launchSettings.json | 12 --------- .../TestProject.LaunchSettings.csproj | 9 ------- .../appsettings.Development.json | 8 ------ .../appsettings.json | 9 ------- 9 files changed, 6 insertions(+), 88 deletions(-) delete mode 100644 tests/testproject/TestProject.LaunchSettings/Program.cs delete mode 100644 tests/testproject/TestProject.LaunchSettings/Properties/launchSettings.json delete mode 100644 tests/testproject/TestProject.LaunchSettings/TestProject.LaunchSettings.csproj delete mode 100644 tests/testproject/TestProject.LaunchSettings/appsettings.Development.json delete mode 100644 tests/testproject/TestProject.LaunchSettings/appsettings.json diff --git a/Aspire.sln b/Aspire.sln index a76dfced01..a8ca025ec6 100644 --- a/Aspire.sln +++ b/Aspire.sln @@ -164,8 +164,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.MongoDB.Driver", "sr EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspire.MongoDB.Driver.Tests", "tests\Aspire.MongoDB.Driver.Tests\Aspire.MongoDB.Driver.Tests.csproj", "{E592E447-BA3C-44FA-86C1-EBEDC864A644}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestProject.LaunchSettings", "tests\testproject\TestProject.LaunchSettings\TestProject.LaunchSettings.csproj", "{A734177E-213B-4D68-98A4-6F5C00234053}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -448,10 +446,6 @@ Global {6472D59F-7C04-43DE-AD33-9F20BE3804BF}.Debug|Any CPU.Build.0 = Debug|Any CPU {6472D59F-7C04-43DE-AD33-9F20BE3804BF}.Release|Any CPU.ActiveCfg = Release|Any CPU {6472D59F-7C04-43DE-AD33-9F20BE3804BF}.Release|Any CPU.Build.0 = Release|Any CPU - {A734177E-213B-4D68-98A4-6F5C00234053}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A734177E-213B-4D68-98A4-6F5C00234053}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A734177E-213B-4D68-98A4-6F5C00234053}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A734177E-213B-4D68-98A4-6F5C00234053}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -529,7 +523,6 @@ Global {20A5A907-A135-4735-B4BF-E13514F360E3} = {27381127-6C45-4B4C-8F18-41FF48DFE4B2} {E592E447-BA3C-44FA-86C1-EBEDC864A644} = {4981B3A5-4AFD-4191-BF7D-8692D9783D60} {DCF2D47A-921A-4900-B5B2-CF97B3531CE8} = {975F6F41-B455-451D-A312-098DE4A167B6} - {A734177E-213B-4D68-98A4-6F5C00234053} = {975F6F41-B455-451D-A312-098DE4A167B6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6DCEDFEC-988E-4CB3-B45B-191EB5086E0C} diff --git a/src/Aspire.Hosting/Dcp/ApplicationExecutor.cs b/src/Aspire.Hosting/Dcp/ApplicationExecutor.cs index f60fa13b0c..8e7ce80f23 100644 --- a/src/Aspire.Hosting/Dcp/ApplicationExecutor.cs +++ b/src/Aspire.Hosting/Dcp/ApplicationExecutor.cs @@ -399,6 +399,12 @@ private async Task CreateExecutablesAsync(IEnumerable executableRes } else { + // If there is no launch profile, we want to make sure that certain environment variables are NOT inherited + foreach (var envVar in s_doNotInheritEnvironmentVars) + { + config.Add(envVar, ""); + } + if (er.ServicesProduced.Count > 0) { if (er.ModelResource is ProjectResource) @@ -436,12 +442,6 @@ private async Task CreateExecutablesAsync(IEnumerable executableRes } } - // We want to make sure that certain environment variables are NOT inherited - foreach (var envVar in s_doNotInheritEnvironmentVars) - { - config.TryAdd(envVar, ""); - } - spec.Env = new(); foreach (var c in config) { diff --git a/tests/Aspire.Hosting.Tests/DistributedApplicationTests.cs b/tests/Aspire.Hosting.Tests/DistributedApplicationTests.cs index 5460f49a18..033b4519a6 100644 --- a/tests/Aspire.Hosting.Tests/DistributedApplicationTests.cs +++ b/tests/Aspire.Hosting.Tests/DistributedApplicationTests.cs @@ -423,32 +423,6 @@ public async Task VerifyDockerAppWorks() await app.StopAsync(); } - [LocalOnlyFact] - public async Task NoUrlInLaunchSettings() - { - var testProgram = CreateTestProgram(); - testProgram.AppBuilder.Services.AddLogging(b => b.AddXunit(_testOutputHelper)); - - testProgram.AppBuilder.AddProject("launch", new Projects.TestProject_LaunchSettings().ProjectPath); - - await using var app = testProgram.Build(); - - await app.StartAsync(); - - var s = app.Services.GetRequiredService(); - var list = await s.ListAsync(); - - var proj = list.FirstOrDefault(x => x.Spec.WorkingDirectory?.Contains("LaunchSettings") == true); - - Assert.NotNull(proj); - Assert.NotNull(proj.Spec.Env); - - // URLs isn't set in launch settings, and shouldn't be inherited from dashboard - Assert.Null(proj.Spec.Env.First(x => x.Name == "ASPNETCORE_URLS").Value); - - await app.StopAsync(); - } - private static TestProgram CreateTestProgram(string[]? args = null, bool includeIntegrationServices = false, bool includeNodeApp = false) => TestProgram.Create(args, includeIntegrationServices: includeIntegrationServices, includeNodeApp: includeNodeApp); } diff --git a/tests/testproject/TestProject.AppHost/TestProject.AppHost.csproj b/tests/testproject/TestProject.AppHost/TestProject.AppHost.csproj index 457ab02a45..2e869fe6c6 100644 --- a/tests/testproject/TestProject.AppHost/TestProject.AppHost.csproj +++ b/tests/testproject/TestProject.AppHost/TestProject.AppHost.csproj @@ -15,7 +15,6 @@ - diff --git a/tests/testproject/TestProject.LaunchSettings/Program.cs b/tests/testproject/TestProject.LaunchSettings/Program.cs deleted file mode 100644 index 9a62273fa0..0000000000 --- a/tests/testproject/TestProject.LaunchSettings/Program.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -var builder = WebApplication.CreateBuilder(args); -var app = builder.Build(); - -app.MapGet("/", () => "Hello World!"); -app.MapGet("/pid", () => Environment.ProcessId); - -app.Run(); diff --git a/tests/testproject/TestProject.LaunchSettings/Properties/launchSettings.json b/tests/testproject/TestProject.LaunchSettings/Properties/launchSettings.json deleted file mode 100644 index 25f4d1bd5e..0000000000 --- a/tests/testproject/TestProject.LaunchSettings/Properties/launchSettings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "profiles": { - "TestProject.LaunchSettings": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - //"applicationUrl": Purposefully not included - } - } -} diff --git a/tests/testproject/TestProject.LaunchSettings/TestProject.LaunchSettings.csproj b/tests/testproject/TestProject.LaunchSettings/TestProject.LaunchSettings.csproj deleted file mode 100644 index 1b28a01c81..0000000000 --- a/tests/testproject/TestProject.LaunchSettings/TestProject.LaunchSettings.csproj +++ /dev/null @@ -1,9 +0,0 @@ - - - - net8.0 - enable - enable - - - diff --git a/tests/testproject/TestProject.LaunchSettings/appsettings.Development.json b/tests/testproject/TestProject.LaunchSettings/appsettings.Development.json deleted file mode 100644 index 0c208ae918..0000000000 --- a/tests/testproject/TestProject.LaunchSettings/appsettings.Development.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - } -} diff --git a/tests/testproject/TestProject.LaunchSettings/appsettings.json b/tests/testproject/TestProject.LaunchSettings/appsettings.json deleted file mode 100644 index 10f68b8c8b..0000000000 --- a/tests/testproject/TestProject.LaunchSettings/appsettings.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, - "AllowedHosts": "*" -}