I would like to split a long build command across multiple lines in my appveyor.yml
file, however I cannot get it to unwrap, so the build is failing when the first FOR
command gets cut off and returns an error. I am not sure how to correctly split the lines in the .yml
file so that they are reassembled inside Appveyor. How can this be done?
Here is a simplified version:
build_script:
- cmd: >-
@echo off
FOR %%P IN (x86,x64) DO ( ^
FOR %%C IN (Debug,Release) DO ( ^
msbuild ^
/p:Configuration=%%C ^
/p:Platform=%%P ... ^
|| EXIT 1 ^
) ^
)
I want it to appear in AppVeyor as this:
@echo off
FOR %%P IN (x86,x64) DO ( FOR %%C IN (Debug,Release) DO ( msbuild /p:Configuration=%%C /p:Platform=%%P ... || EXIT 1 ) )
Extra spaces are unimportant, the important bit is that the line beginning with FOR
until the final )
appears on the same line.
Note that in theory it would also be acceptable for Appveyor to see this:
@echo off
FOR %%P IN (x86,x64) DO ( ^
FOR %%C IN (Debug,Release) DO ( ^
msbuild ^
/p:Configuration=%%C ^
/p:Platform=%%P ... ^
|| EXIT 1 ^
) ^
)
As the Windows cmd.exe
interpreter would then see the continuation markers (^
) at the end of each line and treat them as one big long command, except that Appveyor does not appear to recognise the ^
marker so it sends each line to cmd.exe
one at a time, instead of sending the whole multi-line block together.
This means the first option looks like the only viable solution, where the YAML is constructed such that the FOR
line and everything after it is combined into a single line.
I have tried:
- Single spacing with no extra characters at the end of each line. According to this guide, single-spaced YML lines are supposed to be unwrapped into a single line, but this does not happen with Appveyor.
- Double-spaced lines with no extra characters at the end of each line. This is supposed to make each line a separate command, and indeed they are, as the first
FOR
command fails witherror 255
because it is incomplete (only theFOR
line is present and not the rest of the loop.) - Double-spaced lines terminated with
^
. Appveyor only runs each line one at a time, so I get anerror 255
on the first incompleteFOR
command. - Single-spaced lines terminated with
^
as shown above. Same issue as double-spaced lines,error 255
from an incompleteFOR
command. - Ending each line with
&& ^
does actually work when running separate commands (e.g. multiplemsbuild
statements), but this won't work withFOR
loops because you can't have&&
without a command preceding it.
Is there a trick to splitting a single cmd
command over multiple lines in appveyor.yml
?
.yml
lines back into a single-line command inside Appveyor? – Spithead