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

  • SEARCH
  • Home
  • 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 5952481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:41:17+00:00 2026-05-22T17:41:17+00:00

We use MSBuild to run a project which, among many other things, reads some

  • 0

We use MSBuild to run a project which, among many other things, reads some values from an XML file by means of the XMLQuery task from the Community Tasks package. It worked fine under MSBuild 3.5 but when run under 4.0 it fails with the following message:

error MSB4018: The “XmlQuery” task failed unexpectedly.
System.Xml.XmlException: Name cannot begin with the ‘%’ character, hexadecimal value 0x25. Line 1, position 2.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
at System.Xml.XmlTextReaderImpl.ParseQName(Boolean isQName, Int32 startOffset, Int32& colonPos)
at System.Xml.XmlTextReaderImpl.ParseElement()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XPath.XPathDocument.LoadFromReader(XmlReader reader, XmlSpace space)
at System.Xml.XPath.XPathDocument..ctor(TextReader textReader)
at MSBuild.Community.Tasks.Xml.XmlQuery.loadXmlContent()
at MSBuild.Community.Tasks.Xml.XmlQuery.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult)

The code used to call XMLQuery from within a build target:

<!-- Read XML report -->
<ReadLinesFromFile File="coverageXML\symbolmodule.xml">
  <Output TaskParameter="Lines" ItemName="XmlReportLines" />
</ReadLinesFromFile>
<!-- Get number of visited sequence points -->
<XmlQuery Lines="@(XmlReportLines)" XPath="/trendcoveragedata/stats/@vsp">
  <Output TaskParameter="Values" PropertyName="VisitedSequencePoints" />
</XmlQuery>

I just can’t understand what’s wrong. The XML file is perfectly valid and the XPath specified in the XMLQuery should return a value (and always has). I can’t find a single % character anywhere.

I’m not sure how and where to start troubleshooting this issue… Any pointers in the right direction are appreciated.

  • 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-05-22T17:41:18+00:00Added an answer on May 22, 2026 at 5:41 pm

    ReadLinesFromFile now (in MSBuild 4.0) returns escaped values.
    You have to unescape them before running XmlQUery.
    Like this:

    <!-- Read XML report -->
    <ReadLinesFromFile File="coverageXML\symbolmodule.xml">
      <Output TaskParameter="Lines" ItemName="XmlReportLinesEscaped" />
    </ReadLinesFromFile>
    <ItemGroup>
    <XmlReportLinesEscaped>
      <Escaped>%(XmlReportLinesEscaped.Identity)</Escaped>
      <Unescaped>$([MSBuild]::Unescape('%(XmlReportLinesEscaped.Identity)'))</Unescaped>
    </XmlReportLinesEscaped>
    </ItemGroup>
    <ItemGroup>
      <XmlReportLines Include="@(XmlReportLinesEscaped->'%(Unescaped)')"></XmlReportLines >
    </ItemGroup>
    <!-- Get number of visited sequence points -->
    <XmlQuery Lines="@(XmlReportLines)" XPath="/trendcoveragedata/stats/@vsp">
      <Output TaskParameter="Values" PropertyName="VisitedSequencePoints" />
    </XmlQuery>
    

    Should work.

    Greg.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WiX (Windows installer XML) v3, project which contains references to other
I have the following MSBuild project file: <?xml version=1.0 encoding=utf-8?> <Project xmlns=http://schemas.microsoft.com/developer/msbuild/2003 DefaultTargets=Deploy ToolsVersion=4.0>
I'm trying to use the MSBuild NUnit community task to force tests to run
I'm trying to use the AspNetCompiler task within a custom msbuild file to precompile
I'm trying out Sandcastle Help File Builder. If I run the build from the
When I use msbuild on a .NET 4.0 project it appears to attempt to
I use TeamCity which in turn invokes msbuild (.NET 4). I have a strange
I have a build project that I run from TeamCity, now it takes the
I've developed a tool which I use to build other solution files, and if
I am trying to learn how to use MSBuild so we can use it

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.