0

Background

We have a Sitecore 9.1.1 project following Helix principles and wish to create Nuget packages from some of the custom layer projects (e.g. Customer.Foundation.Dictionary, Customer.Foundation.Assets, Customer.Feature.Article, etc).

The idea is that these NuGet packages can be used on new projects, such that we can re-use logic across projects. We also utilize Unicorn for serialization in our project.

I found a lot of information about creating NuGet packages and some documentation on how to create Sitecore NuGet packages if I was using TDS, however, I have not found anything describing my use-case.

My suggested approach

The way I imagine it could work would be something along these lines:

1) NuGet package following convention-based structure (https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package)

2) Content folder contains the serialized items

3) Content/App_Config/.....Serialization.Config contains stand-alone Unicorn configuration (this configuration needs to work as-is and not rely on existing config). Serialization folder points to the same folder as the script in step 4) copies to

4) Tools folder could contain PowerShell script that copies Serialization items to a location that follows Helix principles (i.e. [Layer]/Feature/Serialization

Is there anyone who tried to build NuGet packages of custom Sitecore components (with Unicorn), who can point me in a direction? Any advice regarding how to structure the NuGet package is much appreciated.

2

I would organise the package something like this

- /
  - bin/
    - Customer.Foundation.Dictionary.dll
    - ... etc
  - App_Config/
    - Include/
      - Feature/
        - Customer/
          - Customer.Foundation.Dictionary.Serialisation.config
  - App_Data/
    - Unicorn/
      - Feature/
          - Customer.Foundation.Dictionary/
            - ... your yaml files here

The config would specify a targetDataStore relative to webroot; e.g. ~/App_Data/Unicorn/$(configurationName).

  • Thanks for your feedback - just what I was looking for. I am using Sitecore PaaS (Azure WebApps) and for deployment we use Azure DevOps. Azure DevOps has an option to leave the App_Data folder alone during deployment, hence I'd rather add my unicorn files to another folder (e.g. 'Data') which does not reside under App_Data. That way, if I delete any template, I can be sure, that the deployed files are always reflecting the actual state, but I guess that is personal preference – Hos Jul 30 at 11:16
  • I actually do the same on a project I'm on. Everything gets deployed to my Azure app somewhere else, then I robocopy /mir it into App_Data as a post deployment step. But there are many ways to set this up, this is just one example. – Mark Cassidy Jul 30 at 11:29
  • I was hoping to get your thoughts on that aswell - thanks again! – Hos Jul 30 at 11:52

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.