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.

2 Answers 2


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.


As Martine Said you either need to create Extension for SetXml to support namespaces, or in simple cases like DataFolder you can use some trick like this:

"CopyDataFolderConfig": {
        "Type": "Copy",
        "Params": {
            "Source": "[joinpath(variable('Site.PhysicalPath'), 'App_Config','Include','Examples','DataFolder.config.example')]",
            "Destination": "[joinpath(variable('Site.PhysicalPath'), 'App_Config','Include', 'DataFolder.config')]"
    "PatchDataFolder": {
        "Description": "Changing Data Folder.",
        "Type": "SetXml",
        "Params": {
            "FilePath": "[joinpath(variable('Site.PhysicalPath'), 'App_Config','Include', 'DataFolder.config')]",
            "XPath": "//configuration/sitecore/sc.variable[@name='dataFolder']/*",
            "Value": "[variable('Site.DataFolder')]"

using '*' as a selector in such cases is not generaly a good idea, but in this case it wont cause any problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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