How can i get multiline powershell script to work in yml

rafae11's Avatar

rafae11

03 Jun, 2020 07:59 PM

i can't get the command to work when loading from appveyor.yml file.
what am i doing wrong?

```
for:
  -
    matrix:
      only:
        - configuration: Release
          job_name: Tests A
    platform: Any CPU # this setting is ignored
    test_script:
      - ps: >-
          $powershell7 = 'C:\Program Files\PowerShell\7\pwsh.exe'
          $command = 'C:\projects\appveyor_scripts\TestA.ps1'
          & $powershell7 -file $command
  -
    matrix:
      only:
        - configuration: Release
          job_name: Tests B
    platform: Any CPU # this setting is ignored
    test_script:
      - ps: >-
          $powershell7 = 'C:\Program Files\PowerShell\7\pwsh.exe'
          $command = 'C:\projects\appveyor_scripts\TestB.ps1'
          & $powershell7 -file $command

  -
    matrix:
      only:
        - configuration: Release
          job_name: Tests C
    platform: Any CPU # this setting is ignored
    test_script:
      - ps: >-
          $powershell7 = 'C:\Program Files\PowerShell\7\pwsh.exe'
          $command = 'C:\projects\appveyor_scripts\TestC.ps1'
          & $powershell7 -file $command
```

I am getting this error.

```
$powershell7 = 'C:\Program Files\PowerShell\7\pwsh.exe' $command = 'C:\projects\appveyor_scripts\TestA.ps1' & $powershell7 -file $command
At line:1 char:57
+ ... wershell7 = 'C:\Program Files\PowerShell\7\pwsh.exe' $command = 'C:\p ...
+ ~~~~~~~~
Unexpected token '$command' in expression or statement.
At line:1 char:109
+ ... sh.exe' $command = 'C:\projects\appveyor_scripts\TestA.ps1' & $powers ...
+ ~
Unexpected token '&' in expression or statement.
```

  1. rafae11 closed this discussion on 03 Jun, 2020 08:36 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

02 Jul, 2020 03:24 PM
01 Jul, 2020 08:32 PM
01 Jul, 2020 01:12 PM
30 Jun, 2020 04:26 PM
25 Jun, 2020 05:54 PM