OfficeDev / generator-office

Yeoman generator for building Microsoft Office related projects.
https://www.npmjs.com/package/generator-office
MIT License
815 stars 207 forks source link

Generated vscode tasks.json file has invalid scripts that fail #786

Open DavidTheProgrammer opened 11 months ago

DavidTheProgrammer commented 11 months ago

Prerequisites

Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

Expected behavior

The files generated after running yo office should work in VS Code without modification.

Current behavior

The run configurations fail as the "preLaunchTask" references a task with invalid syntax.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Run yo office --projectType taskpane --name "New Word AddIn" --host word --ts true
  2. In VSCode open the run and debug menu, select "Word Desktop (Edge Chromium)" and click run.
  3. Console output shows that the preLaunchTask failed due to a missing script.

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

Failure Logs

Please include any relevant log snippets, screenshots or code samples here.

Executing task: npm run "start:desktop -- --app word" 

npm ERR! Missing script: "start:desktop -- --app word"
npm ERR! 
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

npm ERR! A complete log of this run can be found in:

Suggestions

It seems if you create an npm task, as the plugin does, you cannot directly pass arguments as the piped output to npm will consider the full string as the script name "start:desktop -- --app word" and ofcourse that script doesn't exist. My fix is to rewrite the task to be of type shell instead of npm and pass the full npm command directly, below is the working version:

    {
      "label": "Debug: Word Desktop",
      "type": "shell",
      "command": "npm run start:desktop -- --app word",
      "presentation": {
        "clear": true,
        "panel": "dedicated",
      },
      "problemMatcher": []
    },

I have limited knowledge on how the tool works of course but if it's possible that the generator could instead generate tasks in this format, I believe this would be a non-issue. I also assume this affects all the tasks generated by the tool as they're in the same npm format.

davidchesnut commented 11 months ago

Hi @DavidTheProgrammer, thanks for letting us know about this issue!

@millerds can you please help with this issue? Thanks!