Explanation
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.
T4
<#@ 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);
#>
Transform
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<sitecore>
<sc.variable name="solutionFolder" value="<#= solutionDirectory #>"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</sitecore>
</configuration>
And then using it in Unicorn
<targetDataStore
physicalRootPath="$(solutionFolder)\XXX.Unicorn\$(configurationName)"
useDataCache="false"
type="Rainbow.Storage.SerializationFileSystemDataStore, Rainbow"
singleInstance="true"/>