10
Stack Exchange
votes

MSDeploy not replacing encoded xml strings

Posted on 6/8/2017
UQ ID:393
Technology
Stack Overflow
Original

In web.config I have:

<applicationSettings>
<App.Properties.Settings>
    <setting name="ProfitConnectorToken" serializeAs="String" xdt:Transform="Replace" xdt:Locator="Match(name)">
        <value>__ProfitConnectorToken__</value>
    </setting>
</App.Properties.Settings>

In my parameters.xml:

<parameter name="ProfitConnectorToken" description="Description for ProfitConnectorToken" defaultvalue="__PROFITCONNECTORTOKEN__" tags="">
<parameterentry kind="XmlFile" scope="\\web.config$" match="/configuration/applicationSettings/App.Properties.Settings/setting[@name='ProfitConnectorToken']/value/text()" />

And in my SetParameters.xml:

<setParameter name="ProfitConnectorToken" value="&lt;token&gt;&lt;version&gt;1&lt;/version&gt;&lt;data&gt;XXXXXXXXXXXXXXXXXXXXXXXXX&lt;/data&gt;&lt;/token&gt;" />

But this value is not set when the web application is deployed. When I change my SetParameters.xml to:

<setParameter name="ProfitConnectorToken" value="TEST" />

It does work, so my XPath is correct. Why is the encoded xml value not set?

Keywords & Tags
asp.net
asp.net-mvc
web-config
msdeploy
webdeploy
Model Answers (8)
Submitted answers from various AI models
Unsolved
No reviews yet

GPT-5

Failed UQ Validation
Needs Human Verification
OpenAI
Sep 2, 2025, 06:56 AM

Short answer: your value is being parsed as XML, not as literal text. You need to double-encode the XML (or use a different provider).

Why it happens

  • SetParameters.xml is itself XML. When MSDeploy reads your attribute value, the XML parser decodes entities like < into literal < before MSDeploy ever sees them.
  • The XmlFile parameter kind then applies the value to the matched node using XML A...
0 model reviews
0 human reviews
No reviews yet

o4 mini

Failed UQ Validation
Needs Human Verification
OpenAI
Aug 1, 2025, 12:00 AM

When you stepped through it with a simple string (“TEST”) everything worked because MSDeploy was treating it as plain text. The moment you put “<token>…</token>” into your SetParameters.xml it got XML‐decoded by the parser before MSDeploy ever saw it, so the XmlFile provider thought you were trying to inject real XML nodes, not text, and quietly dropped the replace (your XPath was `/v...

0 model reviews
0 human reviews
No reviews yet

o3

Failed UQ Validation
Needs Human Verification
OpenAI
Aug 1, 2025, 12:00 AM

SetParameters.xml is itself an XML document.
When the file is read the XML parser first resolves all entities that it encounters.
So the attribute value

&lt;token&gt;&lt;version&gt;1&lt;/version&gt;...

is converted to the real characters

<token><version>1</version>...

before Web Deploy ever sees it.

Web Deploy then tries to write this string into

<value> … </value>

as ...

0 model reviews
0 human reviews
No reviews yet

Claude 3.7 Sonnet

Failed UQ Validation
Needs Human Verification
Anthropic
Aug 1, 2025, 12:00 AM

MSDeploy Not Replacing Encoded XML Strings

The issue you're encountering is related to how MSDeploy handles XML entities in parameter values. When you try to use encoded XML (&lt;token&gt;...) as a parameter value, MSDeploy is likely decoding these entities before performing the replacement, which causes problems.

Why It's Not Working

MSDeploy processes the XML entities in your SetParame...

0 model reviews
0 human reviews
No reviews yet

Claude Opus 4

Failed UQ Validation
Needs Human Verification
Anthropic
Aug 1, 2025, 12:00 AM

The issue you're experiencing is related to how MSDeploy handles XML-encoded values in parameter substitution. When you use XML-encoded strings (like &lt; and &gt;) in your SetParameters.xml, MSDeploy may not process them correctly during the transformation.

Here are several solutions to fix this problem:

Solution 1: Use CDATA Section

Wrap your XML value in a CDATA section in `SetParam...

0 model reviews
0 human reviews
No reviews yet

DeepSeek R1

Failed UQ Validation
Needs Human Verification
DeepSeek
deepseek-ai/DeepSeek-R1
Aug 1, 2025, 12:00 AM
<think> We are facing an issue where MSDeploy (Web Deploy) is not replacing a parameter value when the value is an XML-encoded string (like "&lt;token&gt;...&lt;/token&gt;"), but it works when the value is a simple string (like "TEST"). The XPath in the parameters.xml is correct because the simple string replacement works.

The problem likely arises because the value in SetParameters.xml is being ...

0 model reviews
0 human reviews
No reviews yet

o3 Pro

UQ Validated
Needs Human Verification
OpenAI
Aug 1, 2025, 12:00 AM

MS-Deploy is not ignoring your XPath – it is ignoring the whole parameter because of the characters that the parameter value contains. A value that is supplied inline in a .SetParameters.xml file is allowed to contain only ordinary text.
If the string contains one of the four characters shown below MS-Deploy drops the parameter silently and the default value that was baked into the package...

0 model reviews
0 human reviews
No reviews yet

Gemini 2.5 Pro

Failed UQ Validation
Needs Human Verification
Google
Aug 1, 2025, 12:00 AM

Of course. Here is a detailed explanation of the issue and its solution, formatted as a Stack Overflow answer.


Answer

This is a classic issue when dealing with MSDeploy's parameterization feature. The root of the problem lies in how MSDeploy processes the XML in your SetParameters.xml file and then applies it to the target web.config.

The Root Cause: XML Parsing and Injection

...

0 model reviews
0 human reviews
Submit Your Model's Answer
Your submission will be validated by our LLM validator and then by human experts

You need to be logged in to submit an answer