0

Background

In our Sitecore 9 solution, we follow Helix principles, when structuring our code and we wish to create NuGet packages that can be re-used across multiple projects. The NuGet packages contains our Sitecore components (Foundation.Dictionary, Feature.PageComponentA, etc).

In a different SO post, I got help as to how I should structure my NuGet package: Creating a custom Sitecore NuGet package containing Unicorn files which means that both C# logic and Unicorn items are in the same NuGet package. So far so good.

The problem

However, for NuGet packages that can be used by multiple project (e.g. all NuGet packages made of Foundation.X-projects), we run into some issues. The issues are, that the same Unicorn items + Serialization config will be added to multiple projects in the solution, which quickly clutters up the solution.

Suggested approach

Currently, the best solution I see, is to create one NuGet package containing only the C# logic and one NuGet package contanining only the Unicorn items + configuration, for a given feature. For example:

Foundation.Dictionary = C# logic

Foundation.Dictionary.Serialization = Unicorn files + configuration

Then it is possible to install Foundation.Dictionary into all the projects that requires the Dictionary logic and then only add the Foundation.Dictionary.Serialization package once.

The only major disadvantage I see with this approach is, that the consumers of the NuGet packages needs to know, that they might have to install two packages, if a given feature has both C# logic and Sitecore content (templates, renderings etc).

The question

Does anyone have another approach than creating two packages, where both C# logic and Unicorn are in the same package, that does not result in multiple versions of the Unicorn config + Unicorn files?

  • Why would there be multiple Unicorn configs and files in this approach? – Mark Cassidy Jul 30 at 17:46
  • Say I want to use my Foundation.Dictionary project in multiple projects in the Feature layer. If I understand correctly and assuming I follow the structure from the linked post, that would mean each of those projects would get the Foundation.Dictionary.Serialization.config file, as well as the each their own copy of the Unicorn files? Or am I misunderstanding the solution posted? – Hos Jul 30 at 19:06
  • They would. But once published out, there would still only ever be 1 file of each. – Mark Cassidy Jul 30 at 20:11
  • Alternatively you could consider a common base config, and have all your modules extend it. Sitecore config style. – Mark Cassidy Jul 30 at 20:11
  • Agree, once published there would only exist one of each, however if you do config changes in one project it is difficult to know if they will be overwritten. Can you elaborate more on your suggestion with the common base config? Do you mean that I could try implementing my own config patching system, like Sitecore does? – Hos Jul 31 at 4:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.