Sitecore VS project configuration for Unicorn serialization

496 Views Asked by At

I have a new Sitecore SXA solution in VS 2017 that follows Helix best practices with Unicorn Serialization. Our Sitecore 9.3 runs in a docker container. I created a first site - EA - in Sitecore CMS under our tenant - Company Inc - and figured I needed to create a corresponding project in VS with Unicorn serialization config file. After creating it I built the solution and did docker-compose up but when modifying items in new site I don't think the .yaml unicorn files are being created. Also, I think in CMS I should see "This item is controlled by Unicorn" for my tracked items. Here is my config for EA project:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <unicorn>
      <configurations>
        <configuration
          name="Project.EA"
          description="EA site folder"
          dependencies="Project.CompanyInc"
          patch:after="configuration[@name='Foundation.Serialization']"
          extends="Helix.Base.Project">
        <predicate>
          <include name="Content" database="master" path="/sitecore/content/Company Inc/$(module)" />
          <include name="Forms" database="master" path="/sitecore/Forms/Company Inc/$(module)" />
          <include name="Media" database="master" path="/sitecore/media library/Project/Company Inc/$(module)" />
          <include name="Theme" database="master" path="/sitecore/media library/Themes/Company Inc/$(module)" />
        </predicate>
        </configuration>
      </configurations>
    </unicorn>
  </sitecore>
</configuration>

What other configuration/settings am I missing before my items are tracked by Unicorn?

1

There are 1 best solutions below

0
Rich Rosiak On

The problem was that in my configuration name:

<configuration
  name="Project.EA"

EA is the $(module) and must correspond to site item name as seen in CMS. So, for example, this line

<include name="Content" database="master" path="/sitecore/content/Company Inc/$(module)" />

Would evaluate to /sitecore/content/Company Inc/EA, which didn't exist. What does exist is: /sitecore/content/Company Inc/Ever After

So, after renaming the config name to this:

<configuration
  name="Project.Ever After"

The CMS started showing "This item is controlled by Unicorn"

Final observation. Unicorn uses these variable in serialization configs

$(layer)
$(module)
$(name)

and in the dot-delimited configuration name, layer is first, followed by module, followed by name. Example:

<configuration
  name="Project.Ever After.Site US"

$(layer) = Project, $(module) = Ever After, $(name) = Site US