tag:help.appveyor.com,2012-11-13:/discussions/questions/1096-multiple-line-cmd-in-appveyorymlAppVeyor: Discussion 2018-10-19T08:17:05Ztag:help.appveyor.com,2012-11-13:Comment/363268292015-03-19T17:42:29Z2015-03-26T19:31:50ZMultiple line cmd in appveyor.yml<div><p>I get errors using multiple line commands. How do I put
something like the following into appveyor.yml:</p>
<p>install:<br>
- if "%Platform%" == "x86" ( set PCRE_PLATFORM=Win32 set
JAVA_HOME=c:/Program Files (x86)/Java/jdk1.8.0 set
VCVARS_PLATFORM=x86 set LANG_PLATFORM= ) else ( set
PCRE_PLATFORM=x64 set JAVA_HOME=c:/Program Files/Java/jdk1.8.0 set
VCVARS_PLATFORM=amd64 set LANG_PLATFORM=-x64 )</p></div>williamtag:help.appveyor.com,2012-11-13:Comment/363268292015-03-19T20:44:17Z2015-03-19T20:44:17ZMultiple line cmd in appveyor.yml<div><p>Hi William,</p>
<p>Put this script on UI and then use "Export YAML" feature on
project settings to get <code>appveyor.yml</code> equivalent.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/363268292015-03-20T21:30:50Z2015-03-26T19:31:50ZMultiple line cmd in appveyor.yml<div><p>I'm not having much luck. First I corrected the escaping of
(x86) to use ^(x86^), but the UI suggests I use:</p>
<p>if "%Platform%" == "x86" (<br>
' set PCRE_PLATFORM=Win32' ' set JAVA_HOME=c:/Program Files
(x86)/Java/jdk1.8.0' ' set VCVARS_PLATFORM=x86' ' set
LANG_PLATFORM=' ) else ( ' set PCRE_PLATFORM=x64' ' set
JAVA_HOME=c:/Program Files/Java/jdk1.8.0' ' set
VCVARS_PLATFORM=amd64' ' set LANG_PLATFORM=-x64' )</p>
<p>which also gives an error. I converted this to powershell next
and the UI suggested:</p>
<ul>
<li>ps: >- If ($env:Platform -Match "x86") {
$env:PCRE_PLATFORM="Win32" $env:JAVA_HOME="c:/Program Files
(x86)/Java/jdk1.8.0" $env:VCVARS_PLATFORM="x86"
$env:LANG_PLATFORM="" } Else { $env:PCRE_PLATFORM="x64"
$env:JAVA_HOME="c:/Program Files/Java/jdk1.8.0"
$env:VCVARS_PLATFORM="amd64" $env:LANG_PLATFORM="-x64" }</li>
</ul>
<p>This gives an error:</p>
<p>Error parsing appveyor.yml: (Line: 46, Col: 5, Idx: 1195) -
(Line: 46, Col: 5, Idx: 1195): While scanning a simple key, could
not find expected ':'.</p>
<p>Does the : in $env:XXX have to escaped or something? Seems like
there is a bug here somewhere in either parsing appveyor.yml or the
UI's generator/converter of the scripts.</p></div>williamtag:help.appveyor.com,2012-11-13:Comment/363268292015-03-21T05:03:21Z2015-03-21T05:03:21ZMultiple line cmd in appveyor.yml<div><p>"Export YAML" suggested the following:</p>
<pre>
<code>install:
- ps: "If ($env:Platform -Match \"x86\") {\n $env:PCRE_PLATFORM=\"Win32\"\n $env:JAVA_HOME=\"c:/Program Files (x86)/Java/jdk1.8.0\"\n $env:VCVARS_PLATFORM=\"x86\"\n $env:LANG_PLATFORM=\"\" \n} Else {\n $env:PCRE_PLATFORM=\"x64\"\n $env:JAVA_HOME=\"c:/Program Files/Java/jdk1.8.0\"\n $env:VCVARS_PLATFORM=\"amd64\"\n $env:LANG_PLATFORM=\"-x64\" \n}"</code>
</pre>
<p>It's weird indeed. Maybe it's better put that into separate
<code>.ps1</code> file?</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/363268292015-03-21T05:05:37Z2015-03-21T05:05:37ZMultiple line cmd in appveyor.yml<div><p>No, seems like there were some special symbols at line endings.
After cleaning up the script it gives:</p>
<pre>
<code>install:
- ps: >-
If ($env:Platform -Match "x86") {
$env:PCRE_PLATFORM="Win32"
$env:JAVA_HOME="c:/Program Files (x86)/Java/jdk1.8.0"
$env:VCVARS_PLATFORM="x86"
$env:LANG_PLATFORM=""
} Else {
$env:PCRE_PLATFORM="x64"
$env:JAVA_HOME="c:/Program Files/Java/jdk1.8.0"
$env:VCVARS_PLATFORM="amd64"
$env:LANG_PLATFORM="-x64"
}</code>
</pre></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/363268292015-03-21T05:08:24Z2015-03-21T05:08:24ZMultiple line cmd in appveyor.yml<div><p>Oh, found it. Apparently, if there is a <em>space</em> character
at the end of a line it breaks formatting and gives single quoted
line.</p></div>Feodor Fitsnertag:help.appveyor.com,2012-11-13:Comment/363268292015-03-24T08:06:43Z2015-03-26T19:31:50ZMultiple line cmd in appveyor.yml<div><p>The file was in Unix format, so used \n instead of \r\n,
probably the copy/paste used the unix line ending. Perhaps the UI
should be enhanced to deal with this common line ending as well as
trailing spaces? Anyway, the powershell multiline 'if' statement
works now, and I gave up with the cmd multiline 'if' statement.
Thanks for your help.</p></div>william