π Bug report: Publish solution is not working
β 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 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, does it not work fine across all command shells?
@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
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?
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
@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
but when I used Windows PowerShell (rember that blue old thing we used to use π) I repro the error as mentioned in this bug
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 π?
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 :(
@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
Please find the attached
@Jeevajothi-Ganapathi thanks for the update. Could you confirm that if you temporary update this to PowerShell 7+ or CMD it will work properly?
merged. This will be part of the next pre-release shortly and next minor release in a few weeks
Issue Resolved