richardszalay / helix-publishing-pipeline

Unified publishing for Sitecore Helix solutions that extends existing Visual Studio and command line workflows
MIT License
68 stars 18 forks source link

Allow pattern-based module metadata #48

Closed richardszalay closed 5 years ago

richardszalay commented 5 years ago
  1. It's a common convention to publish unicorn files as App_Data\serialization(Layer)(Module)*\.yml
  2. Project names tend to be (Namespace).(Layer).(Module)
  3. Advanced content mapping is limited to item metadata when mapping a target path

The above means that HPP can't actually support mapping of the most common unicorn convention.

This proposal is to allow convention based "splitting" of module names into additional metadata fields using a regular expression with named groups.

Example:

<ItemGroup>
  <HelixModuleMetadataPattern Include="^(?<Namespace>.+)\.(?<Layer>.+)\.(?<Module>.+)$" />
</ItemGroup>

Patterns would be applied to the module Filename (without extension) and, if successful, the named groups would be added as metadata into the item.

Applying the above example to the module "TestProject.Foundation.Serialization", the following content mapping would now be possible:

<AdditionalFilesForPackagingFromHelixModules Include="Serialization">
  <SourcePath>..\serialization\**\*.yml</SourcePath>
  <TargetPath>App_Data\unicorn\^(HelixModule.Namespace)\^(HelixModule.Layer)\^(HelixModule.Module)\^(RecursiveDir)^(Filename)^(Extension)</TargetPath>
</AdditionalFilesForPackagingFromHelixModules>

These variables could be used in conjunction with any metadata defined on the ProjectReference