Skip to content

Multi-root workspaces: project-context commands only ever see workspaceFolders[0] #251

Open

Description

Problem

getWorkspacePath() in src/extension.ts resolves the workspace like this:

function getWorkspacePath(): string | undefined {
	const workspaceFolders = vscode.workspace.workspaceFolders;
	if (!workspaceFolders || workspaceFolders.length === 0) {
		vscode.window.showErrorMessage('No workspace folder open');
		return undefined;
	}
	return workspaceFolders[0].uri.fsPath;
}

Only the first folder of a multi-root workspace is ever considered. In a .code-workspace with several folders, everything outside folder[0] is unreachable by any WinApp command — there is no prompt, no setting, and no error explaining why the app isn't found.

Two things make it worse:

  1. winapp.appDirectories can't route around it. isContainedInWorkspace() in src/project-resolver.ts rejects absolute paths and .. traversal, so the setting cannot point at a second root even when the user knows exactly where their app is.
  2. winapp.appDirectories has no "scope" declared in package.json, so it defaults to window — a single value for the whole workspace rather than per-folder .vscode/settings.json values.

Meanwhile WinAppDebugAdapterFactory uses session.workspaceFolder, which is folder-scoped — so F5 and the command palette can silently operate on different roots.

Affected commands

Every project-context command routed through resolveProjectDirectory:

  • WinApp: Initialize Project
  • WinApp: Restore Packages
  • WinApp: Update Packages
  • WinApp: Generate Manifest
  • WinApp: Update Manifest Assets
  • WinApp: Add Manifest Execution Alias
  • WinApp: Generate Certificate
  • WinApp: Unregister Package
  • WinApp: Get WinApp Path

Relationship to the winapp run project-mode work

The project-mode change makes winapp.run, winapp.runAdvanced, and the debug adapter multi-root aware, and deliberately leaves the general-purpose primitives behind for reuse:

  • getWorkspaceRoots() and per-root scan/aggregate helpers
  • root labelling for QuickPick items (applied only when more than one root exists, so single-folder users see no change)
  • active-editor-root defaulting

So this issue should be a rewiring rather than a rewrite: point resolveProjectDirectory's dependencies at those helpers.

Scope

  • Make resolveProjectDirectory span all workspace roots, reusing the primitives above.
  • Replace getWorkspacePath()'s folder[0] assumption for the remaining commands.
  • Declare winapp.appDirectories as "scope": "resource" and make isContainedInWorkspace validate per-root, so each folder's .vscode/settings.json can supply its own app directories.
  • Extend the existing src/test/project-resolver.test.ts coverage to multi-root cases.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions