{"record":{"id":"67f367262acf3b85","repo":"stride3d/stride","slug":"invalid-relative-path-expecting-an-absolute-project-path","errorCode":null,"errorMessage":"Invalid relative path. Expecting an absolute project path","messagePattern":"Invalid relative path\\. Expecting an absolute project path","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/PackageSession.cs","lineNumber":701,"sourceCode":"                return sourceTracker ??= new AssetSourceTracker(this);\n            }\n        }\n    }\n\n    /// <summary>\n    /// Adds an existing package to the current session.\n    /// </summary>\n    /// <param name=\"projectPath\">The project or package path.</param>\n    /// <param name=\"logger\">The session result.</param>\n    /// <param name=\"loadParametersArg\">The load parameters argument.</param>\n    /// <exception cref=\"ArgumentNullException\">packagePath</exception>\n    /// <exception cref=\"ArgumentException\">Invalid relative path. Expecting an absolute package path;packagePath</exception>\n    /// <exception cref=\"FileNotFoundException\">Unable to find package</exception>\n    public PackageContainer AddExistingProject(UFile projectPath, ILogger logger, PackageLoadParameters? loadParametersArg = null)\n    {\n        ArgumentNullException.ThrowIfNull(projectPath);\n        ArgumentNullException.ThrowIfNull(logger);\n        if (!projectPath.IsAbsolute) throw new ArgumentException(\"Invalid relative path. Expecting an absolute project path\", nameof(projectPath));\n        if (!File.Exists(projectPath)) throw new FileNotFoundException(\"Unable to find project\", projectPath);\n\n        var loadParameters = loadParametersArg ?? PackageLoadParameters.Default();\n\n        Package package;\n        PackageContainer project;\n        try\n        {\n            // Enable reference analysis caching during loading\n            AssetReferenceAnalysis.EnableCaching = true;\n\n            project = LoadProject(logger, projectPath.ToOSPath(), loadParametersArg);\n            Projects.Add(project);\n\n            package = project.Package;\n\n            // Load all missing references/dependencies\n            LoadMissingDependencies(logger, loadParameters);","sourceCodeStart":683,"sourceCodeEnd":719,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/PackageSession.cs#L683-L719","documentation":"AddExistingProject requires an absolute path to the project file. Passing a relative UFile throws ArgumentException, because subsequent File.Exists and package loading logic depend on a fully qualified location.","triggerScenarios":"Calling session.AddExistingProject(\"MyGame/MyGame.csproj\", logger) with a relative path, or a path built from the current directory implicitly.","commonSituations":"Taking a project path from command-line args or config without resolving it, hard-coded relative paths that worked by accident in another working directory.","solutions":["Resolve to an absolute path with Path.GetFullPath (combined with your base directory) before calling","Check projectPath.IsAbsolute before the call","Build the path from an absolute root directory constant"],"exampleFix":"// before\nsession.AddExistingProject(\"src/MyGame.csproj\", logger);\n// after\nvar abs = new UFile(Path.GetFullPath(\"src/MyGame.csproj\"));\nsession.AddExistingProject(abs, logger);","handlingStrategy":"validation","validationCode":"var abs = new UFile(Path.GetFullPath(projectPath));\nif (!abs.IsAbsolute) throw new ArgumentException(\"Project path must be absolute\", nameof(projectPath));","typeGuard":"bool IsAbsoluteProjectPath(UFile p) => p != null && p.IsAbsolute;","tryCatchPattern":"try { session.AddExistingProject(path, logger); }\ncatch (ArgumentException ex) { logger.Error(ex, \"Project path must be absolute\"); }","preventionTips":["Resolve config/CLI-supplied paths with Path.GetFullPath at the boundary","Check UFile.IsAbsolute before calling path-based APIs","Keep a single rooted base-directory constant for building paths"],"tags":["path","argument","projects"],"backgroundTag":"invalid-argument-value","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"}