microsoft / microsoft/WinAppVSCE
Multi-root workspaces: project-context commands only ever see `workspaceFolders[0]`
Nobody has claimed this yet.
- 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:
winapp.appDirectoriescan't route around it.isContainedInWorkspace()insrc/project-resolver.tsrejects absolute paths and..traversal, so the setting cannot point at a second root even when the user knows exactly where their app is.winapp.appDirectorieshas no"scope"declared inpackage.json, so it defaults towindow— a single value for the whole workspace rather than per-folder.vscode/settings.jsonvalues.
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
resolveProjectDirectoryspan all workspace roots, reusing the primitives above. - Replace
getWorkspacePath()'s folder[0] assumption for the remaining commands. - Declare
winapp.appDirectoriesas"scope": "resource"and makeisContainedInWorkspacevalidate per-root, so each folder's.vscode/settings.jsoncan supply its own app directories. - Extend the existing
src/test/project-resolver.test.tscoverage to multi-root cases.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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