Description
In some recent work I've had need to execute an external program, so the <Exec/>
task comes in handy:
<Exec Command="configure" />
The problem, though, is that the command I really need to execute is long -- resulting in a line which is nearly 596 characters long:
<Exec
Command="configure LD="e;..."e; ... # plus hundreds more characters..."
/>
I want shorter lines, both to make it easier to read, and to simplify version control review and validation (long lines make for terrible diffs).
There are (at least?) two ways to make for shorter lines:
-
Use more variables
<PropertyGroup> <Ld>LD="@(Runtimes->'%(Ld)')"</Ld> <!-- ... --> </PropertyGroup> <Exec Command="configure $(Ld) ..." />
-
Use line continuations:
<Exec Command="configure ^ LD="..." ^ ..." />
Truth be told, I tried (1) first, but that doesn't work with xbuild on OS X (doh!).
So I try the Unix variant on (2):
<Exec
Command="configure \
LD="..." \
..."
/>
...which promptly fails because \
is replaced with /
at all instances in both xbuild and msbuild (which is why I'm bringing it up here... ;-).
What would be useful is some way of using line-continuation characters in a portable fashion. I can think of two ways to support this:
-
On Unix, replace
^<newline>
with\<newline>
. This would allow us to use the Windows line-continuation character of^
in a portable fashion.The problem with this is if there are any shells or commands for which a trailing
^
is appropriate, though I can't think of any programs which use^
in this manner offhand. -
Fix the
s#\#/#g
replacement that MSBuild performs so that\<newline>
can be used within the//Exec/@Command
attribute. Then, we could useConditional
to have one command for Windows and a different command for Unix:<Exec Condition="' $(OS' == 'Windows_NT' " Command="this is a ^ very long command" /> <Exec Condition="' $(OS' != 'Windows_NT' " Command="this is a \ very long command" />