MSBuild - Writing Escape Characters to Files

Posted by Richm7 on Stack Overflow See other posts from Stack Overflow or by Richm7
Published on 2010-01-27T11:31:52Z Indexed on 2010/03/29 13:03 UTC
Read the original article Hit count: 436

Filed under:
|
|
|
|

I've got a very similar scenario to the one described in this post. It describes how to load the contents of a file that contains properties & items, making sure they're resolved as part of the process. I'm doing the same thing except writing the contents away to another text file (generally .ini file).

In short I'd start by importing a project / propertygroup which contains this text:

; -----------

[heading]

setting1=$(FirstValue)

setting2=$(SecondValue)

setting3=list;of;values;delimited;by;semicolons

setting4=bla bla bla

; -----------

& hopefully write it away to a new .ini file containing the following:

; -----------

[heading]

setting1=value resolved by msbuild

setting2=another value resolved by msbuild

setting3=list;of;values;delimited;by;semicolons

setting4=bla bla bla

; -----------

Only problem is that some files will contain semicolons. I can live without comments, but they're also used as part of values e.g. in lists. This is the result of using the WriteLinesToFile task. The semicolons are treated as escape characters & result in new lines, so the value of 'setting3' in the above example would be split over 6 lines.

Is there a way around this without implementing my own task?

Thanks in advance for the help!

© Stack Overflow or respective owner

Related posts about msbuild

Related posts about write