Problem
I have code like this in my msbuild files, all over the place:
<Message
Text="$(NewLine)==============================================$(NewLine)"
Importance="High" />
<Message
Text=" CLEAN UP "
Importance="High" />
<Message
Text="$(NewLine)==============================================$(NewLine)"
Importance="High" />
Goal
now i would like to harmonize output and do reduce code redundancy and extract the message formatting logic to some kind of task or whatnot.
This is how i'm imagine the usage:
<Message Text="$(PrintInBox(CLEAN UP))" Importance="High"/>
so that i could also reuse it in
<Error Text="$(PrintInBox(CLEAN UP))"/>
If that is absolutely not possible, something like
<PrintInBox Text="CLEAN UP"/>
would be the next best thing.
What i found so far
The "best" thing i found so far is "inline tasks". but do i really need to write c# code to get the job done? It's just some simple string concatenation,...
Also using the custom task would be almost as cumbersome as duplicating the code all over, i guess it would look something like this:
<FormatInBox Text="CLEAN UP">
<Output TaskParameter="Result" ItemName="FormattedText"/>
</FormatInBox>
<Message Text="@(FormattedText)" Importance="High"/>
or if i create more specific tasks:
<MessageInBox Text="CLEAN UP" Importance="High" />
and
<WarnInBox Text="CLEAN UP" Condition="..." />
and
<ErrorInBox Text="CLEAN UP" Condition = "..." />
but this will make it necessary to duplicate some of the parameters and pass them along. Also there's still code duplication across the MessageInBox, WarnInBox and ErrorInBox tasks.
Question
How can i achieve the simplest interface for the consumer? How can i reduce code-redundancy best? Is there really no better way then the one i found before? Can i create an msbuild task which consist of msbuild xml, not C# or VB.net or Javascript or whatnot?