MSBuild - Writing Escape Characters to Files
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 &a开发者_StackOverflowmp; 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!
I had a similar situation but just using static text containing semi-colons in the WriteLinesToFile task. I got it to work by using %3B as an escape character for semi-colon.
If you can get the semi-colons to show up properly in the in-memory value (use the Message task to check this) then you may just need to replace them with %3B to write the file out.
精彩评论