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.
Issue was
AfterPublish
is not a valid task. The correct task for running "after publishing" is:<Target Name="CustomPostPublishActions" AfterTargets="GatherAllFilesToPublish">
Note that the
Name
attribute doesn't matter, it can be anything. Here's the completed output:EDIT:
Adding onto my issue, when other developers "built" the project, and didn't publish it, the transform files would change the original configs, which is not the desired approach. Therefore, since we're using
File Deploy
as theOne-Click Publish
, there's aTarget
namedCopyAllFilesToSingleFolderForPackage
, which is called right before files are pushed to the directory.