microsoft / microsoft/WinAppVSCE

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

Open
#251 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
13
Forks
3
Avg merge
6d 1h
Merged PRs (30d)
11

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with getWorkspacePath() and resolveProjectDirectory in src/extension.ts, then inspect isContainedInWorkspace in src/project-resolver.ts and the existing multi-root primitives described in the issue. Review winapp.appDirectories in package.json and extend src/test/project-resolver.test.ts. Done means project-context commands consider all roots, per-folder app directories are accepted, and multi-root cases pass without changing single-folder behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience, testing, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.