I have a line in a script that works on my dev environments but not in my Appveyor CI environment.
The script:
$rootpath = Join-Path $PSScriptRoot '..' | Resolve-Path
$specs = Join-Path "$rootpath" spec fix *xml | Resolve-Path
My dev environment does exactly what I expect: $specs
is assigned an an array of paths to xml files in that dir.
However, my CI fails out with this:
Join-Path : A positional parameter cannot be found that accepts argument 'fix'.
At C:\projects\myproj-jib50\scripts\Generate-Message-Sources.ps1:8 char:10
+ $specs = Join-Path $rootpath spec fix *xml | Resolve-Path
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Join-Path], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.JoinPathCommand
No input files.
My dev is powershell 7.3.9, but the CI is 7.3.8. Could that be the difference?
It seems the CI was not using the version of Powershell that I thought it was using.
The CI is Appveyor using a "Visual Studio 2022" image.
The existing config was using a "ps" section (pre-existing before my involvement) to run powershell commands including my script, and when I altered my script to print out the version within it, it kept printing 1.0.0. I tried like 3 different ways, and only 1.0.0 came out. (Could it really be using 1.0.0? That seems insane.)
However, when I ran
pwsh --Version
outside of that section, I got 7.3.8 (as noted in my question). Following that lead, I deleted theps
section entirely and ran my script withpwsh
, and it worked correctly.So it appears @SantiagoSquarzon was correct in his comment-- my CI was not actually using 7.3.8 as I thought.