vscode-viva icon indicating copy to clipboard operation
vscode-viva copied to clipboard

🐞 Bug report: Publish solution is not working

Open Jeevajothi-Ganapathi opened this issue 1 month ago β€’ 10 comments

⭐ Priority

(Low)☹️ Something is a little off

πŸ“ Describe the bug

gulp bundle --ship && gulp package-solution --ship At line:1 char:21

  • gulp bundle --ship && gulp package-solution --ship
  •                 ~~
    

The token '&&' is not a valid statement separator in this version. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordE
xception + FullyQualifiedErrorId : InvalidEndOfLine

πŸ‘£ Steps To Reproduce

Publsih task on spfx tool kit

πŸ“œ Expected behavior

should clean, build, bundle, package

πŸ“· Screenshots

No response

❓SharePoint Framework Toolkit version

4.12.0

❓Node.js version

22

πŸ€” Additional context

No response

Jeevajothi-Ganapathi avatar Nov 19 '25 13:11 Jeevajothi-Ganapathi

@Jeevajothi-Ganapathi thanks for reporting the bug. May I kindly ask you what is the default terminal you use in VS Code? Is it CMD or PowerShell or Bash or something else?

Adam-it avatar Nov 19 '25 13:11 Adam-it

@Adam-it, does it not work fine across all command shells?

Saurabh7019 avatar Nov 19 '25 14:11 Saurabh7019

@Adam-it, does it not work fine across all command shells?

No it will not. I think this is something I had to figure out in the last PR in which I added support for multiple SPFx version in validate and install and you were testing and in the end in the terminal execute wrapper I created this helper method that for PowerShell related terminals we used ; and for other we use &&.

  private static getCommandChainOperator(): string {
    const shell = TerminalCommandExecuter.shell || '';

    if (shell.path?.includes('PowerShell') || shell.path?.includes('pwsh') || shell.source?.includes('PowerShell') || shell.source?.includes('pwsh')) {
      return ';';
    }

    return ' &&';
  }

From the error message provided in this bug report I expect this will be the issue

Adam-it avatar Nov 19 '25 15:11 Adam-it

getCommandChainOperator

This one doesn't seem to be related to the Publish action. Also, I am not able to reproduce this issue with any terminal profiles.

Are you?

Saurabh7019 avatar Nov 19 '25 18:11 Saurabh7019

Nope I did not give it a local check yet, as I don't have currently a time slot for that. I should have some OS time on friday so I will give it a check.

the publich command runs 'gulp bundle --ship && gulp package-solution --ship' and I suspect it could be related. As I said this is what I suspect, lucky guess here πŸ™‚ I think that for CMD or bash the gulp bundle --ship && gulp package-solution --ship is fine but for PowerShell it could be gulp bundle --ship ; gulp package-solution --ship ... and maybe the && is giving the error

Adam-it avatar Nov 19 '25 19:11 Adam-it

@Saurabh7019 so I managed to quickly reporduce this totally aside from SPFx Toolkit context. So when I used PowerShell 7 (7+) it works properly, I am not sure but I think the support for && as a operator was added in 'modern' PowerShell

Image

but when I used Windows PowerShell (rember that blue old thing we used to use 😁) I repro the error as mentioned in this bug

Image

That is why I think it is 'safer' to just use ; instead of && for PowerShell related terminals in chain operations. This is exactly why I created this helper method I mentioned above

What do you think? Wanna take it on and open a PR with fix to this issue πŸ˜‰? i may do it over the weekend Oooor we could just write good instructions and delegate it to Copilot to do it for us. Why waste time on simple stuff right πŸ™‚?

Adam-it avatar Nov 19 '25 20:11 Adam-it

That is why I think it is 'safer' to just use ; instead of && for PowerShell related terminals in chain operations. This is exactly why I created this helper method I mentioned above

I will make this change...

Is till can't reproduce though :(

Image

Saurabh7019 avatar Nov 20 '25 10:11 Saurabh7019

@Saurabh7019 gotcha πŸ‘, that is exactly why I asked here https://github.com/pnp/vscode-viva/issues/645#issuecomment-3552816428 what terminal is set as default in VS Code

@Jeevajothi-Ganapathi did you maybe had a chance to have a look on that and when terminal you have set in the terminal.integrated.defaultProfile setting?

@Saurabh7019 also I strongly encourage you to give it a try by assigning GH Copilot to this issue and see how that works to get more confidence in using it in future. Before you do that please be sure to provide more context in the initial bug description like the fix proposal and that it should start from dev branch not main and the opened PR should target dev not main. I think its worth trying/learning especially since this bug is also quite low and may easily solved with a workaround

Adam-it avatar Nov 20 '25 11:11 Adam-it

Please find the attached Image

Jeevajothi-Ganapathi avatar Nov 20 '25 11:11 Jeevajothi-Ganapathi

@Jeevajothi-Ganapathi thanks for the update. Could you confirm that if you temporary update this to PowerShell 7+ or CMD it will work properly?

Adam-it avatar Nov 20 '25 11:11 Adam-it

merged. This will be part of the next pre-release shortly and next minor release in a few weeks

Adam-it avatar Nov 26 '25 16:11 Adam-it

Issue Resolved

Jeevajothi-Ganapathi avatar Dec 08 '25 07:12 Jeevajothi-Ganapathi