Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8542529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:05:32+00:00 2026-06-11T12:05:32+00:00

I have an msbuild script which uses the Exec tag to kick off another

  • 0

I have an msbuild script which uses the Exec tag to kick off another MSBuild command including a DefineConstants property with multiple values. Since I have multiple values for that property, I’m using the technique described in this question to call MSBuild.exe directly (not use the MSBuild tag) and enclose the values in quotes.

However, I now need to embed a special symbol into one of those values, which I’m attempting to do using the code ¯ (registered trademark ®)

The problem is that the special character code must end in a semicolon, but when I embedded the semicolon, msbuild reads that as a value seperator. I can seem to find a valid way to escape the semicolon and have it still show up in the end parameter value.

My question is this:
How can I embed the special char into my build parameter?

To improve readability, I’ve moved the value to a variable in my example, but that’s not a requirement.

File: TopLevelBuildScript.proj

  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="BuildWithSpecialChar">
    <ItemGroup>
      <!-- Note: %3B is the escape code for semicolon -->
      <MyProductName Include="Trademarked&amp;#174%3B Product" />
      <OtherProperty Include="foo" />
    </ItemGroup>

   <Exec Command="msbuild.exe subBuildScript.proj /p:DefineConstants=&quot;MyProductName=@(MyProductName);OtherVar=@(foo);AnotherVar=asdf;&quot; " />
    </Target>
  </Project>

When executed, the above produces the command line:

msbuild.exe subBuildScript.proj /p:DefineConstants="MyProductName=Trademarked&#174; Product;OtherVar=foo;AnotherVar=asdf;"

Which ends up defining the constants with the product name split at the semicolon:

MyProductName=Trademarked&#174
Product
OtherVar=foo
AnotherVar=asdf

Note: I’ve also tried using %25 for the percent sign:

<MyProductName Include="Trademarked&amp;#174%253B Product" />

But that gives me:

MyProductName=Trademarked&#174B Product
OtherVar=foo  
AnotherVar=asdf

Update

It turns out the issue wasn’t with MSBuild, rather with the way WiX parses parameters (my subBuildScript utilizes WiX). I didn’t consider that, so didn’t mention it in my original posting.

Ultimately, I went with a solution based on this answer to another question:

<PropertyGroup>   
  <WixValues>
    <MyProductName>Trademarked® Product<MyProductName>
    <OtherProperty>foo"</OtherProperty>
  </WixValues>
</PropertyGroup>
<MSBuild
    Projects="subProjectScript.proj"
    Properties="Configuration=Release;WixValues=$([MSBuild]::Escape($(WixValues)))"
    Targets="Clean;Rebuild"
    ContinueOnError="false"
    StopOnFirstFailure="true">
</MSBuild>

and unescaping the values in subProjectScript.proj as described in the other answer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:05:33+00:00Added an answer on June 11, 2026 at 12:05 pm

    First, MSBuild files are XML, which you can encode as UTF-8, so you should be able to copy/paste the trademark character directly in the MSBuild script, without escaping.

    If you can’t take that approach, don’t escape the ampersand. There are two levels of escaping things in an MSBuild script. The first is XML-encoding, so that XML-sensitive characters (< and &) can be used and you’ll still have safe XML. When MSBuild reads in the file, XML-escape sequences get unescaped. After that process, MSBuild then does its own un-escaping (i.e. %3B for semi-colons).

    Because you’re using &amp; at the beginning of your XMl escape sequence, the XML processor is interpreting that as a literal ampersand, not the special XML ampersand, which denotes an escape sequence. Change your MyProductName item group’s value to be:

    <MyProductName Include="Trademarked&#174; Product" />
    

    Since MyProductName appears to be a scalar value, and not a list, I would use a property instead:

    <PropertyGroup>
      <MyProductName>Trademarked® Product</MyProductName>
    </PropertyGroup>
    

    In your Exec task you can then use it like this:

    <Exec Command="msbuild.exe subBuildScript.proj /p:DefineConstants=&quot;MyProductName=$(MyProductName);OtherVar=@(foo);AnotherVar=asdf;&quot; " />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an MSBuild script that uses NUnit to run tests in two assemblies.
In my msbuild script I have to clean a directory, which has some hidden
I have a csproj file which references a shared MSBuild script with an <Import>
I need to construct an MSBUILD script executes .SQL Scripts which have changed since
I have the following build script, which I run with MSBuild: <?xml version=1.0 encoding=utf-8?>
I have an MSBuild script which compiles my existing solution but I'd like to
I have the following task in my MSBuild script: <Target Name=ZipStates> <Message Text=CREATING ZIP
I'm trying to create a MSBuild script for running in TeamCity. I have a
I have a custom MSBuild task, which processes a set of files and returns
I have a MSBuild script that I am executing through TeamCity. One of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.