Problem:
DataFolder.config
file is not reverting back to previous state (the patch
element's value). Also, none of the custom config file transforms are being pushed out to the destination folder.
What's interesting is the ConnectionStrings.config
file is being converted back to the original state after the transformation, but not the DataFolder.config
.
<Target Name="BeforeBuild">
<!-- Web.config, ConnectionStrings.config, DataFolder.config
Duplicates original config files into a temp file -->
<Copy SourceFiles="Web.config" DestinationFiles="Web.temp.config" OverwriteReadOnlyFiles="True" />
<Copy SourceFiles="$(ProjectDir)\App_Config\Include\zzz\DataFolder.config" DestinationFiles="$(ProjectDir)\App_Config\Include\zzz\DataFolder.temp.config" OverwriteReadOnlyFiles="True" />
<Copy SourceFiles="$(ProjectDir)\App_Config\ConnectionStrings.config" DestinationFiles="$(ProjectDir)\App_Config\ConnectionStrings.temp.config" OverwriteReadOnlyFiles="True" />
<!-- Tranforms config files -->
<TransformXml Source="Web.temp.config" Transform="Web.$(Configuration).config" Destination="Web.config" />
<TransformXml Source="$(ProjectDir)\App_Config\Include\zzz\DataFolder.temp.config" Transform="$(ProjectDir)\App_Config\Include\zzz\DataFolder.$(Configuration).config" Destination="$(ProjectDir)\App_Config\Include\zzz\DataFolder.config" />
<TransformXml Source="$(ProjectDir)\App_Config\ConnectionStrings.temp.config" Transform="$(ProjectDir)\App_Config\ConnectionStrings.$(Configuration).config" Destination="$(ProjectDir)\App_Config\ConnectionStrings.config" />
</Target>
<Target Name="AfterPublish123" AfterTargets="MSDeployPublish">
<!-- Overwrite transformed config files with the temps.
Delete temp files for Web.config, ConnectionStrings.config, DataFolder.config -->
<Copy SourceFiles="Web.temp.config" DestinationFiles="Web.config" OverwriteReadOnlyFiles="True" />
<Delete Files="Web.temp.config" />
<Copy SourceFiles="$(ProjectDir)\App_Config\Include\zzz\DataFolder.temp.config" DestinationFiles="$(ProjectDir)\App_Config\Include\zzz\DataFolder.config" OverwriteReadOnlyFiles="True" />
<Delete Files="$(ProjectDir)\App_Config\Include\zzz\DataFolder.temp.config" />
<Copy SourceFiles="$(ProjectDir)\App_Config\ConnectionStrings.temp.config" DestinationFiles="$(ProjectDir)\App_Config\ConnectionStrings.config" OverwriteReadOnlyFiles="True" />
<Delete Files="$(ProjectDir)\App_Config\ConnectionStrings.temp.config" />
</Target>
DataFolder.config
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<sc.variable name="dataFolder">
<patch:attribute name="value">#{sitecore.DataFolder}</patch:attribute>
</sc.variable>
</sitecore>
</configuration>
DataFolder.Release.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<sc.variable name="dataFolder" xdt:Locator="Match(name)" xdt:Transform="Replace">
<patch:attribute name="value">c:\inetpub\wwwroot\fb822\Data</patch:attribute>
</sc.variable>
</sitecore>
</configuration>
After the publish is complete, the DataFolder.config
element for patch
now has the value of the DataFolder.Release.config
element's value, which it shouldn't.
DataFolder.Release.config
is the configuration chosen (ie -$(Configuration)
. TheTransformXml
elements are the ones that "transform" the original file, using the "temp" duplicated files created. – Pendulum