microsoft/aspire · error · InvalidOperationException
Resource ' ' cannot produce a " " launch configuration…
Error message
Resource '{resource.Name}' cannot produce a "{KnownLaunchConfigurationTypes.Project}" launch configuration because it has no project metadata. The "{KnownLaunchConfigurationTypes.Project}" launch configuration type is reserved for .NET project resources; use a resource that carries IProjectMetadata or a different launch configuration type. What it means
ProjectLaunchConfigurationFactory.Create only produces a 'Project' launch configuration for resources that carry IProjectMetadata. Given any other resource type (container, executable, connection), it throws InvalidOperationException because the 'Project' configuration type is reserved for .NET project resources.
Solutions
- Only request project launch configurations for resources where resource.TryGetProjectMetadata(out _) returns true
- Use the launch configuration factory that matches the resource's actual kind (e.g. container/executable configuration types)
- If the resource should be a project, add the project metadata annotation in the resource builder
Example fix
// before
var config = ProjectLaunchConfigurationFactory.Create(resource, mode);
// after
if (resource.TryGetProjectMetadata(out _))
{
var config = ProjectLaunchConfigurationFactory.Create(resource, mode);
} Defensive patterns
Strategy: type-guard
Validate before calling
if (!resource.TryGetProjectMetadata(out _))
throw new InvalidOperationException($"'{resource.Name}' is not a project resource."); Type guard
bool IsProjectResource(IResource r) => r.TryGetProjectMetadata(out _);
Try / catch
try { var cfg = ProjectLaunchConfigurationFactory.Create(resource, mode); } catch (InvalidOperationException) { /* use the resource's actual launch config type */ } Prevention
- Filter resource collections with TryGetProjectMetadata before requesting project configs
- Use the config type matching the resource kind
When it happens
Trigger: Requesting launch configurations for a resource whose annotation list lacks IProjectMetadata, e.g. resolving launch configurations for a container resource or a plain custom resource.
Common situations: Enumerating launch configurations over all resources in the app model where non-project resources are included; a custom resource builder forgot to add project metadata; dashboard/IDE tooling asking for a project config for a container.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- Launch arguments must contain at least one entry.
- Resource ' ' carries more than one IProjectMetadata…
- Resource ' ' does not carry an IProjectMetadata annotation.
- Resource ' ' project metadata was replaced after project…
- The leading resource argument to remove cannot be empty.
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/3efcaffecefeede3.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting/ApplicationModel/ProjectLaunchConfigurationFactory.cs:18
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#pragma warning disable ASPIREEXTENSION001
#pragma warning disable ASPIREPROJECTS001
namespace Aspire.Hosting.ApplicationModel;
/// <summary>
/// Builds the <see cref="ProjectLaunchConfiguration"/> that Aspire hands to the IDE for a .NET resource.
/// </summary>
internal static class ProjectLaunchConfigurationFactory
{
public static ProjectLaunchConfiguration Create(IResource resource, string mode)
{
if (!resource.TryGetProjectMetadata(out var projectMetadata))
{
throw new InvalidOperationException(
$"Resource '{resource.Name}' cannot produce a \"{KnownLaunchConfigurationTypes.Project}\" launch configuration because it has no project metadata. " +
$"The \"{KnownLaunchConfigurationTypes.Project}\" launch configuration type is reserved for .NET project resources; use a resource that carries {nameof(IProjectMetadata)} or a different launch configuration type.");
}
return Create(resource, projectMetadata, mode);
}
public static ProjectLaunchConfiguration Create(IResource resource, IProjectMetadata projectMetadata, string mode)
{
resource.TryGetLastAnnotation<ProjectLaunchDefaultsAnnotation>(out var launchDefaults);
var projectLaunchConfiguration = new ProjectLaunchConfiguration
{
Type = GetLaunchConfigurationType(resource, projectMetadata),
ProjectPath = projectMetadata.ProjectPath,
Mode = mode,
BuildConfiguration = launchDefaults?.BuildConfiguration,
BuildEnvironment = projectMetadata.BuildEnvironment.Count == 0
? nullView on GitHub (pinned to 25830f84bd)