Configure Unicorn in Sitecore items for synchronization


                                 

Unicorn is a utility for Sitecore that solves the issue of moving templates, renderings, and other database items between Sitecore instances. This becomes problematic when developers have their own local instances - packages are error-prone and tend to be forgotten on the way to production. Unicorn solves this issue by writing serialized copies of Sitecore items to disk along with the code - this way, a copy of the necessary database items for a given codebase accompanies it in source control.
The major benefit of this tool is free compare to TDS.

So Let’s play with Unicron step by step.

1.     How to install unicorn with your Sitecore Instance?

     Here As per your project structure you can create separate module or you can go ahead with existing module.
I always preferred separate module for that so let’s move on the project.

a.     Move in your visual studio project and right click on that and select ‘Manage Nuget Package’.
b.     In window just select browse window and search unicorn.
c.      When you search then it’s come on top and select latest version of unicorn and click on install button.

      


 d.     It will take few seconds to install completely.

    

     it will show you what changes going on just press ok button.

e.     After installation build your project and publish so that unicorn config and dll files move on your root folder.
f.       But before publish make sure your application config file, dlls and global ajax should not be publish either it can create problems.
g.     Make sure your unicorn dlls and file should be publish only.
h.     Need to cross check its working or not just put this one.

      Http://your instance/Unicorn.aspx/


  

if all working fine then move on configuration part!

Configuration:

Now you have configure Sitecore instance so let’s configure the unicorn. let's move on application and extract App_Conifg/Include folder. now you can see here unicorn folder and its have many unicorn config file.




For better part don’t touch unicorn folder just create your separate folder under include folder.
I have created zz.Serialization folder. Under this folder create two patches file.

a.     DataSoure patch file
b.     UnicornSerializae file




You can put file name according to your project.

a.     In UnicornDataSource file you have to define path where you want to serialize items. Just copy this code and put your config file and changesource folder value which is highlighted.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig" xmlns:set="http://www.sitecore.net/xmlconfig/set/">
  <sitecore>
      <sc.variable name="sourceFolder" value="your project path "/>
    </sitecore>
</configuration>


Now moving for second file to serialize items.

b.     In UnicornSerialize file you have to define configuration predicate like what you want to serialize. Just copy this code and put your config fle.
c.      And make sure your putting right path under predicate.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
  <sitecore>
    <unicorn>
      <configurations>

       
        <!--This is Template section-->
       
        <!--here you can define your project name ad put description for unique identification-->
        <configuration name="ExcelPOCTemplate" description="This Template section">
         
          <!--Target data source we have aready defined in another patch file-->
        <targetDataStore physicalRootPath="$(sourceFolder)/Templates" type="Rainbow.Storage.SerializationFileSystemDataStore, Rainbow" useDataCache="false" singleInstance="true" />
           
        <!--we have to define predicate as per our requirement.-->
        <predicate type="Unicorn.Predicates.SerializationPresetPredicate, Unicorn" singleInstance="true">
         <include name="Templates" database="master" path="/sitecore/templates/WffmTemplate"/>
        </predicate>
         
        </configuration>
       
       
        <!--This is Layout section-->
        <!--here you can define your project name ad put description for unique identification-->
        <configuration name="ExcelPOCLayout" description="test">

          <!--Target data source we have aready defined in another patch file-->
          <targetDataStore physicalRootPath="$(sourceFolder)/Layout" type="Rainbow.Storage.SerializationFileSystemDataStore, Rainbow" useDataCache="false" singleInstance="true" />

          <!--we have to define predicate as per our requirement.-->
          <predicate type="Unicorn.Predicates.SerializationPresetPredicate, Unicorn" singleInstance="true">
            <include name="Layout" database="master" path="/sitecore/layout"/>
          </predicate>

        </configuration>
       
       
        <!--This is Content section-->
        <!--here you can define your project name ad put description for unique identification-->
        <configuration name="ExcelPOCContent" description="test">

          <!--Target data source we have aready defined in another patch file-->
          <targetDataStore physicalRootPath="$(sourceFolder)/Content" type="Rainbow.Storage.SerializationFileSystemDataStore, Rainbow" useDataCache="false" singleInstance="true" />

          <!--we have to define predicate as per our requirement.-->
          <predicate type="Unicorn.Predicates.SerializationPresetPredicate, Unicorn" singleInstance="true">
            <include name="Content" database="master" path="/sitecore/content/Home"/>
          </predicate>
        </configuration>
       
       
       
       
       
      </configurations>
    </unicorn>
  </sitecore>
</configuration>


     Once you done all changes save, build and publish your project. go on browser and refresh your unicorn admin panel. now you will see this type of screen first time. just press the perform initial serialization button and it will run the process.






        


      ok, Once its done sync process let's go back on project folder path whatever we mentioned to store sync items and check.
      Hurrah! its done and all template on my disk as a yml file.




     That's the way you can achieve easily.

     For more details please go through below URL.
https://kamsar.net/index.php/category/Unicorn/



Happy Coding!

😇

Comments

  1. The education is necessary because through this you become an expert and get acknowledge about different important aspects. DumpsTool products contain information that has been extracted from authentic and reliable sources. NSE7_SAC-6.2 Practice Exam offer you updated knowledge about all the contents of the syllabus and will enable you to pass it with flying colors. If you need to go through the entire syllabus and learn each and every topic, choose our Study Guides that equip you with the best knowledge.

    ReplyDelete

Post a Comment

Popular posts from this blog

Difference between shared, Versioned and Unversioned fileds in sitecore

How to find broken links in Sitecore.

Setup First Sitecore Helix Example From Scratch (Blank solution)