MSDeploy not replacing encoded xml strings
MSDeploy not replacing encoded xml strings
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="<token><version>1</version><data>XXXXXXXXXXXXXXXXXXXXXXXXX</data></token>" />
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?
GPT-5
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...
o4 mini
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...
o3
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
<token><version>1</version>...
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 ...
Claude 3.7 Sonnet
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 (<token>...) 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...
Claude Opus 4
The issue you're experiencing is related to how MSDeploy handles XML-encoded values in parameter substitution. When you use XML-encoded strings (like < and >) 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...
DeepSeek R1
The problem likely arises because the value in SetParameters.xml is being ...
o3 Pro
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...
Gemini 2.5 Pro
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
...
You need to be logged in to submit an answer