{"record":{"id":"7888b0b95863b69b","repo":"microsoft/aspire","slug":"the-configured-launch-profile-launchprofilename-was-not","errorCode":null,"errorMessage":"The configured launch profile, '{launchProfileName}', was not found in the launch settings file.","messagePattern":"The configured launch profile, '(.+?)', was not found in the launch settings file\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Testing/DistributedApplicationFactory.cs","lineNumber":294,"sourceCode":"        var launchProfileName = existingConfig[\"DOTNET_LAUNCH_PROFILE\"];\n\n        // Load the launch profile and populate configuration with environment variables.\n        if (appHostLaunchSettings is not null)\n        {\n            var launchProfiles = appHostLaunchSettings.Profiles;\n            LaunchProfile? launchProfile;\n            if (string.IsNullOrEmpty(launchProfileName))\n            {\n                // If a launch profile was not specified, select the first launch profile.\n                var firstLaunchProfile = launchProfiles.FirstOrDefault();\n                launchProfile = firstLaunchProfile.Value;\n                SetDefault(\"DOTNET_LAUNCH_PROFILE\", firstLaunchProfile.Key);\n            }\n            else\n            {\n                if (!launchProfiles.TryGetValue(launchProfileName, out launchProfile))\n                {\n                    throw new InvalidOperationException($\"The configured launch profile, '{launchProfileName}', was not found in the launch settings file.\");\n                }\n            }\n\n            // Populate config from env vars.\n            if (launchProfile?.EnvironmentVariables is { Count: > 0 } envVars)\n            {\n                foreach (var (key, value) in envVars)\n                {\n                    SetDefault(key, value);\n\n                    // See https://github.com/dotnet/runtime/blob/8edaf7460777e791b6279b395a68a77533db2d20/src/libraries/Microsoft.Extensions.Hosting/src/HostApplicationBuilder.cs#L96\n                    if (key.StartsWith(\"DOTNET_\", StringComparison.OrdinalIgnoreCase))\n                    {\n                        SetDefault(key[\"DOTNET_\".Length..], value);\n                    }\n\n                    // See https://github.com/dotnet/aspnetcore/blob/4ce2db7b8d85c07cad2c59242edc19af6a91b0d7/src/DefaultBuilder/src/WebApplicationBuilder.cs#L38\n                    if (key.StartsWith(\"ASPNETCORE_\", StringComparison.OrdinalIgnoreCase))","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Testing/DistributedApplicationFactory.cs#L276-L312","documentation":"Thrown by DistributedApplicationFactory's PostConfigureBuilderOptions when the launch profile name configured via DistributedApplicationTestingOptions or TestingBuilderOptions does not exist in the project's launchSettings.json. The factory resolves the target project's launch profiles at startup and requires the configured name to match one exactly.","triggerScenarios":"Calling DistributedApplicationTesting.CreateAsync<TEntryPoint>(\"my-profile\") or setting options.LaunchProfileName to a name that is not a key in the test project's Properties/launchSettings.json.","commonSituations":"Typos or case mismatches in the profile name; renaming a profile in launchSettings.json without updating tests; CI environments where launchSettings.json is absent so only defaults exist; copying tests between projects with different profile names.","solutions":["Open the test project's Properties/launchSettings.json and verify the configured profile name matches a key exactly (case-sensitive).","Remove the explicit launch profile argument/option to let the factory pick the first available profile.","Add the missing profile to launchSettings.json with the required environment variables and applicationUrl.","If running in CI, ensure launchSettings.json is included in the build output (it should be copied via the default globbing) or don't rely on a custom profile."],"exampleFix":"// before\nvar appHost = await DistributedApplicationTesting.CreateAsync<Projects.AspireApp_AppHost>(\"prod-like\");\n// after\nvar appHost = await DistributedApplicationTesting.CreateAsync<Projects.AspireApp_AppHost>(\"http\"); // 'http' exists in launchSettings.json","handlingStrategy":"validation","validationCode":"var launchSettingsPath = Path.Combine(appHostProjectDir, \"Properties\", \"launchSettings.json\");\nvar profiles = JsonDocument.Parse(File.ReadAllText(launchSettingsPath)).RootElement.GetProperty(\"profiles\")\n    .EnumerateObject().Select(p => p.Name).ToHashSet();\nif (!profiles.Contains(options.LaunchProfileName))\n    throw new InvalidOperationException($\"Profile '{options.LaunchProfileName}' not in launchSettings.json. Available: {string.Join(\", \", profiles)}\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep launch profile names in a shared constant referenced by both launchSettings.json-adjacent tooling and tests.","Don't rely on custom launch profiles in CI; use the default first profile.","After renaming a profile in launchSettings.json, grep the test suite for the old name."],"tags":["launch-profiles","configuration","testing","config-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}