Skip to content

Fix Debug task to avoid fragile npm argument forwarding#85

Open
ayush-meghwani-28 wants to merge 1 commit into
OfficeDev:mainfrom
ayush-meghwani-28:user/aymeghwa/fix-debug-task-arg-forwarding
Open

Fix Debug task to avoid fragile npm argument forwarding#85
ayush-meghwani-28 wants to merge 1 commit into
OfficeDev:mainfrom
ayush-meghwani-28:user/aymeghwa/fix-debug-task-arg-forwarding

Conversation

@ayush-meghwani-28

Copy link
Copy Markdown
Contributor

Problem

The generated Debug: Excel Desktop VS Code task runs:

npm run start -- desktop --app excel

This relies on npm forwarding the --app option flag across the -- separator. On some npm versions the flag is not forwarded, so the command resolves to:

office-addin-debugging start manifest.xml desktop excel

That passes 3 positional arguments to start (which accepts only <manifest-path> [platform]), producing:

error: too many arguments for 'start'. Expected 2 arguments but got 3.

Because the debug task aborts before the dev server starts, Excel then reports "Add-in ... failed to download a required resource." This was hit by a customer scaffolding an Excel Custom Functions + Shared Runtime project and pressing F5.

Fix

Move the arguments into a dedicated start:desktop npm script so nothing is forwarded through --:

  • package.json: add "start:desktop": "office-addin-debugging start manifest.xml desktop --app excel"
  • .vscode/tasks.json: Debug: Excel Desktop now runs ["run", "start:desktop"]

This keeps the desktop / --app excel intent, is immune to npm's -- handling, and is backward compatible (identical result on old and new npm). The new script is additive — the existing start script and npm start flow are unchanged.

Verified locally: F5 builds, starts the dev server, and sideloads the add-in into Excel; custom functions execute.

Note on scope

The same npm run start -- <platform> --app <host> pattern exists in the sibling template repos (Excel-Custom-Functions, Excel-Custom-Functions-JS, Excel-Custom-Functions-Shared-JS, and the Office-Addin-TaskPane* / React repos). Starting with this repo since it's the one in the reported issue — happy to mirror the same fix across the others once the approach is confirmed. For the multi-host TaskPane manifests, the --app value must be preserved (it selects which host to launch), which this script-based approach supports.

The 'Debug: Excel Desktop' task ran 'npm run start -- desktop --app excel',
which relies on npm forwarding the '--app' option flag across the '--'
separator. On some npm versions the flag is dropped, so the command resolves
to 'office-addin-debugging start manifest.xml desktop excel' (3 positionals)
and fails with 'too many arguments for start. Expected 2 arguments but got 3.'
Because the task aborts, the dev server never starts and Excel then reports
'failed to download a required resource.'

Move the arguments into a dedicated 'start:desktop' npm script so nothing is
forwarded through '--'. This preserves the desktop/--app excel intent and
works reliably across npm versions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ayush-meghwani-28
ayush-meghwani-28 requested a review from a team as a code owner July 24, 2026 11:53
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@millerds millerds left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't scale. In general, the templates support multiple host and it's not practical to have a script command for each host and then have to adjust that when the projects are generated. This is why we use the extended arguments '--' flag. While this repo doesn't have multiple hosts . . . we like to keep the templates in sync for common thing (it's easier to maintain).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants