For Unicorn serialization currently i have given path like

<targetDataStore physicalRootPath="C:\SitecoreProjects\Unicorn1\src\Project\Unicorn_Test\serialization" 

However its absolute source path in my machine and working fine for me. Since we are working in a team, how can i make this to relative path so that all team members can check out this from source control work without any issues while reserialize and sync?

2 Answers 2


You can do this by using a variable that gets set in a developer only config. I would normally setup the targetDataStore like this in my unicorn config:

<targetDataStore physicalRootPath="$(sourceFolder)\$(layer)\$(module)\serialization\Website" />

Then in my website project, I have a z.DevSettings.config file, where I specify the value for the $(sourceFolder) variable:

<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
        <sc.variable name="sourceFolder" value="C:\Projects\MyProject\src" />

That file is not committed to source control, each developer would create a version of that so that the source folder can be set based on your local machine setup. We don't commit it, because then it will not affect anyone else.



Relative - to what? That is the issue here. Your solution files live in your solution folder, likely under GIT control or some other form of source control.

When Unicorn executes, it executes in your Web Context (IIS folder) and knows nothing about the solution that was published to it.

No relative path would work here, ~/ is pointing to the IIS "Website" folder.

Another approach

An interesting - although untested by me - solution to this was also presented on the Unicorn Issues area.

Question: how can I specify a solution relative path for "targetDataStore" configuration property

It basically introduces a $(solutionFolder) variable that can then be used in the configuration of <targetDataStore>.

I've not tried it myself (and a part of me thinks this is maybe overkill), but wanted to offer up an alternative answer to Richards answer above (which is the approach I use as well).

It involves a T4 template and a config transformation.


<#@ template debug="false" hostspecific="true" language="C#" #><# /* hostspecific must be set to "true" in order to access Visual Studio project properties. */ #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Text" #>
<#@ output extension=".config" #>
<#@ assembly name="EnvDTE" #><# /* This assembly provides access to Visual Studio project properties. */ #>
    var serviceProvider = this.Host as IServiceProvider;
    var dte = serviceProvider.GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
    var solutionDirectory = System.IO.Path.GetDirectoryName(dte.Solution.FullName);


<?xml version="1.0" encoding="utf-8"?>

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
      <sc.variable name="solutionFolder" value="<#= solutionDirectory #>" 
        xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>

And then using it in Unicorn

    type="Rainbow.Storage.SerializationFileSystemDataStore, Rainbow"

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.