I wanna write <Message Text="Line1\nLine2\nLine3" />
but \n seems not to be working. What should I replace \n with?
(I read in the books they said that to print @ and % we use %40 and %25, so I guess the should be a number for the new-line).
I wanna write <Message Text="Line1\nLine2\nLine3" />
but \n seems not to be working. What should I replace \n with?
(I read in the books they said that to print @ and % we use %40 and %25, so I guess the should be a number for the new-line).
Try this:
<Message Text="Line1%0aLine2%0aLine3%0a" />
CR = 0x0D or 13
LF = 0x0A or 10
Here's a better way. Use the "Escape()" property function [1] in a trivial msbuild file like so:
<Message Text="$([MSBuild]::Escape('A\r\nB\r\nC\r\n'))" />
The 'Escape()' property function should do all the magic in terms of escaping exotic characters.
[1] https://learn.microsoft.com/en-us/visualstudio/msbuild/how-to-escape-special-characters-in-msbuild?view=vs-2017 & https://learn.microsoft.com/en-us/visualstudio/msbuild/property-functions?view=vs-2017
You could put the lines into an item group
<ItemGroup>
<Lines Include="Line 1 " />
<Lines Include="Line 2 " />
<Lines Include="Line 3 " />
</ItemGroup>
<Message Text="%(Lines.Identity)"/>
Put the multiline message in a property (in the example below called MyMultilineMessage
) and then use that property in the message text. (Works at least with MSBuild for VisualStudio 2019)
<PropertyGroup>
<MyMultilineMessage>
Lorum ipsum...
</MyMultilineMessage>
</PropertyGroup>
<Message Importance="High" Text="$(MyMultilineMessage)"/>
This also works for Error
elements as well.
Edit: Modified XML example above after comment about missing PropertyGroup
.