stride3d/stride · error · InvalidOperationException
Ambiguous project name
Error message
Ambiguous project name '{_request.Project.Name}'. What it means
Inside GetProjectReferences, the helper matches the requested project name against the list of projects in the MSBuild workspace/closure. If more than one project matches the same name case-insensitively, the match is ambiguous and an InvalidOperationException is thrown rather than guessing which project to use.
Solutions
- Rename the duplicate project so each project name in the session is unique
- Use the PackageSpecProjectName (full unique name) instead of the plain project name when resolving
- Remove or unload the duplicate project from the solution/session
Example fix
// before: two projects named 'MyGame' in different folders // after: rename one and rebuild <AssemblyName>MyGame.Tests</AssemblyName> <!-- in the duplicate csproj -->
Defensive patterns
Strategy: validation
Validate before calling
var names = session.Projects.Select(p => p.Name);
if (names.GroupBy(n => n, StringComparer.OrdinalIgnoreCase).Any(g => g.Count() > 1))
logger.Warning("Duplicate project names in session; rename before resolving references"); Try / catch
try { ResolveProjectReferences(request); }
catch (InvalidOperationException ex) when (ex.Message.StartsWith("Ambiguous project name"))
{ logger.Error(ex, "Rename duplicate projects"); } Prevention
- Enforce unique project names in the solution
- Use fully qualified PackageSpecProjectName for lookups
- Audit solutions for duplicate AssemblyName values
When it happens
Trigger: Requesting external/project references for a project whose Name matches multiple projects loaded in the session/workspace (duplicate project names across different folders or solution configurations).
Common situations: Two .csproj files with the same assembly/project name in different directories, a solution containing a project and its tests with identical names, duplicated projects from nested package references.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Missing external reference metadata for
- Invalid relative path. Expecting an absolute project path
- Unable to find project
- Could not find a MSBuild installation (expected 16.0 or…
- Could not find a supported MSBuild toolset version…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/b366a015f2178f08.
Report an issue: GitHub.
Appendix: source
Thrown at sources/assets/Stride.Core.Assets/PackageSession.Dependencies.cs:621
if (_request.ExternalProjects.Count == 0)
{
// If no projects exist add the current project.json file to the project
// list so that it can be resolved.
updatedExternalProjects.Add(ToExternalProjectReference(_request.Project));
}
else if (_request.ExternalProjects.Count > 0)
{
// There should be at most one match in the external projects.
var rootProjectMatches = _request.ExternalProjects.Where(proj =>
string.Equals(
_request.Project.Name,
proj.PackageSpecProjectName,
StringComparison.OrdinalIgnoreCase))
.ToList();
if (rootProjectMatches.Count > 1)
{
throw new InvalidOperationException($"Ambiguous project name '{_request.Project.Name}'.");
}
var rootProject = rootProjectMatches.SingleOrDefault();
if (rootProject != null)
{
// Replace the project spec with the passed in package spec,
// for installs which are done in memory first this will be
// different from the one on disk
updatedExternalProjects.AddRange(_request.ExternalProjects
.Where(project =>
!project.UniqueName.Equals(rootProject.UniqueName, StringComparison.Ordinal)));
var updatedReference = new ExternalProjectReference(
rootProject.UniqueName,
_request.Project,
rootProject.MSBuildProjectPath,
rootProject.ExternalProjectReferences);View on GitHub (pinned to 96fad776d2)