{"record":{"id":"b366a015f2178f08","repo":"stride3d/stride","slug":"ambiguous-project-name-request-project-name","errorCode":null,"errorMessage":"Ambiguous project name '{_request.Project.Name}'.","messagePattern":"Ambiguous project name '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/PackageSession.Dependencies.cs","lineNumber":621,"sourceCode":"        if (_request.ExternalProjects.Count == 0)\n        {\n            // If no projects exist add the current project.json file to the project\n            // list so that it can be resolved.\n            updatedExternalProjects.Add(ToExternalProjectReference(_request.Project));\n        }\n        else if (_request.ExternalProjects.Count > 0)\n        {\n            // There should be at most one match in the external projects.\n            var rootProjectMatches = _request.ExternalProjects.Where(proj =>\n                    string.Equals(\n                        _request.Project.Name,\n                        proj.PackageSpecProjectName,\n                        StringComparison.OrdinalIgnoreCase))\n                    .ToList();\n\n            if (rootProjectMatches.Count > 1)\n            {\n                throw new InvalidOperationException($\"Ambiguous project name '{_request.Project.Name}'.\");\n            }\n\n            var rootProject = rootProjectMatches.SingleOrDefault();\n\n            if (rootProject != null)\n            {\n                // Replace the project spec with the passed in package spec,\n                // for installs which are done in memory first this will be\n                // different from the one on disk\n                updatedExternalProjects.AddRange(_request.ExternalProjects\n                    .Where(project =>\n                        !project.UniqueName.Equals(rootProject.UniqueName, StringComparison.Ordinal)));\n\n                var updatedReference = new ExternalProjectReference(\n                    rootProject.UniqueName,\n                    _request.Project,\n                    rootProject.MSBuildProjectPath,\n                    rootProject.ExternalProjectReferences);","sourceCodeStart":603,"sourceCodeEnd":639,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/PackageSession.Dependencies.cs#L603-L639","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before: two projects named 'MyGame' in different folders\n// after: rename one and rebuild\n<AssemblyName>MyGame.Tests</AssemblyName> <!-- in the duplicate csproj -->","handlingStrategy":"validation","validationCode":"var names = session.Projects.Select(p => p.Name);\nif (names.GroupBy(n => n, StringComparer.OrdinalIgnoreCase).Any(g => g.Count() > 1))\n    logger.Warning(\"Duplicate project names in session; rename before resolving references\");","typeGuard":null,"tryCatchPattern":"try { ResolveProjectReferences(request); }\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Ambiguous project name\"))\n{ logger.Error(ex, \"Rename duplicate projects\"); }","preventionTips":["Enforce unique project names in the solution","Use fully qualified PackageSpecProjectName for lookups","Audit solutions for duplicate AssemblyName values"],"tags":["ambiguity","projects","msbuild"],"backgroundTag":"internal-invariant-violation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}