Beware % in MSBuild

Here is a very basic example:

<Project DefaultTargets=”Full” xmlns=”″>
<Ingredients Include=”0%Good”/>
<Ingredients Include=”100%Bad”/>
<Target Name=”Full”>
<Message Text=”%(Ingredients.Identity)”/>

It’s a simple cycle through a collection and showing a message. If you think the output is


then you would be wrong. It is in fact:


MSBuild uses the % character to show the beginning of an escaped character. You can get more details here. In this example, you would need to use <Ingredients Include=”100%25Bad”/> to display the result you were expecting.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s