I want to leverage SIF with the Set-Xml task to update the value in the datafolder.config patch file. But so far it seems I am not succeeding in finding the correct XPath due to the XML NS in the file.

I am using the following XPath expression:


For your reference, this is the datafolder.config file shipped with Sitecore 8.2 U7:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
    <sc.variable name="dataFolder">
      <patch:attribute name="value">/data</patch:attribute>

Is it possible to set the value using SIF and an XPath expression? And if so, which XPath might do the trick? Any help is appreciated.


Okay, I got it working. The problem was with the inability of the SetXml SIF task to provide an XML NS.

So I created a custom task based on the SetXml task with an extra parameter to provide the namespace, the SIF configuration (in my case) then becomes as follows:

"SetDataFolder": {
      "Type": "SetXml",
      "Params": {
        "FilePath": "[joinpath(variable('Site.WebsiteFolder'), 'App_Config', 'Include', 'DataFolder.config')]",
        "XPath": "//configuration/sitecore/sc.variable[@name='dataFolder']/patch:attribute[@name='value']",
        "Namespace": [
            "patch": "http://www.sitecore.net/xmlconfig/"
        "Value": "[parameter('DataFolder')]"        

To accomplish this, just copy the complete SetXml task from the SIF library, make the necessary modifications to support the namespace in the Select-XML method, and include it in your module loading and be sure to register it using an overwrite of the out-of-the-box module using

Register-SitecoreInstallExtension -Command Invoke-SetXmlTaskEx -As SetXml -Type Task -Force

Hopefully this will help anyone else stumbling into the same problem until it hopefully becomes part of the official SIF version.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.