Skip to content
SDL Web 8.5 Event-System extension to mirror publishing in a set of source publications to a list of target publications
C# Batchfile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Publish.Mirror
packages
.gitignore
Publish.Mirror.Extension.sln
README.md

README.md

Tridion Publish Mirror - Event System Extension

SDL Web 8.5 Event System extension to mirror publishing and unpublishing jobs sent in a set of source publications to a set of target publications. This is particularly useful in combination with Experience Manager, where publishing initiated in XPM can be mirrored to other language websites for consistent user-experiences - but there are probably a bunch of other use cases.

The extension has been tested in SDL Web 8.5 with both Topology Manager publishing, and legacy publishing using publishing targets.

How it works

The extension is an asynchronous event-system extension which hooks into publishing & unpublishing events (transaction committed event phase).

  • When an item is published or published, the extension checks to see if the publish was initiated in one of the source publications defined in the configuration file.
  • If the transaction should be mirrored in the target publications, the extension initiates a publish or unpublish in each of the target publications defined in the configuration file.
  • The publishing instructions are mirrored exactly, including the publish / unpublish instructions.

Configurations exist to also force setting some of the advanced publishing settings, including publishing the minor and in-workflow versions (-v0). See the configuration section below.

Configurations

The extension is configured with an accompanying DLL file, which is loaded as an EXE configuration - Tridion.Events.config.

  • SourcePublications: comma-separated list of publication titles or TCM Ids for all publications which should initiate publish mirroring.
  • TargetPublications: comma-separated list of publication titles or TCM IDs for publications should publishing should be mirrored to.
  • PublishLoggingEnabled: indicate whether or not all publish & unpublish transactions should be logged.
  • MirrorIfPropogateSelected: indicate whether or not mirroring should only be enabled if the advanced setting "publish / unpublish to child publications" is checked.
  • ForcePublishToChildPublications: indicate whether the advanced setting should be set to force publishing to all child publications.
  • ForcePublishWorkflowVersion: indicate whether the advanced setting should be set to publish in-workflow versions.
  • ForcePublishMinorVersion: indicate whether the advanced setting should be set to publish minor versions.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
  
    <!-- Define publications by title or TCM ID (comma-separated) where publishing mirroring should be triggered -->
    <add key="SourcePublications" value="tcm:0-7-1"/>
    
    <!-- Define the publications by title or TCM ID (comma-separated) which publishing  -->
    <add key="TargetPublications" value="400 Example Site"/>

    <!-- Enable logging of all publish transactions -->
    <add key="PublishLoggingEnabled" value="true" />

    <!-- Enable mirroring only if propogate children is selected -->
    <add key="MirrorIfPropogateSelected" value="true" />

    <!-- Force the advanced publish / unpublish setting to publish to child publications -->
    <add key="ForcePublishToChildPublications" value="true" />

    <!-- Force the advanced publish setting to publish in-workflow versions -->
    <add key="ForcePublishWorkflowVersion" value="false" />

    <!-- Force the advanced publish setting to publish minor versions -->
    <add key="ForcePublishMinorVersion" value="false" />

  </appSettings>
</configuration>

Building & Deploying

The extension uses ILMerge (v3.0.29) to merge together the extension DLL which is built with dependencies. Logging can also be enabled to log all publish / unpublish transactions for debugging, which can prove useful for auditing purposes.

The dependencies utilized include:

  • NLog (v4.6.2)

You can either download the latest release and deploy it directly, or download the source and compile the project for yourself.

In order to build & deploy the extension:

  • Build the project in Visual Studio
  • Copy Tridion.Events.PublishMirror.Merged.dll, Tridion.Events.PublishMirror.Merged.pdb, Tridion.Events.config and NLog.config into %SDL Web Install%/bin
  • Open %SDL Web Install%/config/Tridion.ContentManager.config and add the following entry to the list:
<add assemblyFileName="C:\Program Files (x86)\SDL Web\bin\Tridion.Events.PublishMirror.Merged.dll" />

Logging

The logging library used is NLog (v4.6.2) which is configured in NLog.config.

You can read more about NLog over on their [https://github.com/NLog](GitHub page).

ILMerge

ILMerge is used for merging DLLs so we don't have to copy and paste them as a group. It is configured in the .csproj file:

<Target Name="AfterBuild">
  <ItemGroup>
    <MergeAssemblies Include="$(OutputPath)Tridion.Events.PublishMirror.dll" />
    <MergeAssemblies Include="$(OutputPath)NLog.dll" />
  </ItemGroup>
  <PropertyGroup>
    <OutputAssembly>$(OutputPath)Tridion.Events.PublishMirror.Merged.dll</OutputAssembly>
    <Merger Condition="('$(OS)' == 'Windows_NT')">"$(SolutionDir)packages\ILMerge.3.0.29\tools\net452\ILMerge.exe"</Merger>
  </PropertyGroup>
  <Message Text="MERGING: @(MergeAssemblies->'%(Filename)') into $(OutputAssembly)" Importance="High" />
  <Exec Command="$(Merger) /out:&quot;$(OutputAssembly)&quot; @(MergeAssemblies->'&quot;%(FullPath)&quot;', ' ')" />
</Target>

Please log any defects on the repo issues page.

You can’t perform that action at this time.