Vous êtes sur la page 1sur 14

UNICORN SET UP FOR SITECORE

PROJECT
THIS DOCUMENT ADDRESSES ON SETTING UP UNICORN FOR SITECORE
PROJECT ALSO TELLS HOW TO USE T4 TEMPLATE CODE GENERATION

Author:
Vikas Nadvi,
Deloitte Digital,

1|Unicorn

Mailto: vsanjeevarayanako@deloitte.com

2|Unicorn

TABLE OF CONTENTS

1. REVISION HISTORY____________________________________________________3
2. REFERENCES___________________________________________________________4
3. PURPOSE OF THIS DOCUMENT________________________________________5
4. INSTALLATION OF UNICORN.__________________________________________6
4.1

INSTALL UNICORN USING NUGET PACKAGE_______________________________6

4.2

CONFIGURATION CHANGES____________________________________________________7

5. CREATING T4 TEMPLATE AND CODE GENERATION_________________10


5.1

INSTALL RAINBOWCODEGENERATION LIBRARY_______________________________10

3|Unicorn

1. REVISION HISTORY

Docume
nt
Version

1.0

4|Unicorn

Review by

Vikas Nadvi

Review
Date

18/10/2016

Comments

2. REFERENCES

Title

Unicorn code and


documentation.

5|Unicorn

Link/Ref.
https://github.com/kamsar/Unicorn

3. PURPOSE OF THIS DOCUMENT


This document details the steps on setting up unicorn utility tool for Sitecore used in
moving sitecore items between Sitecore instances and getting changes under the
source control.
This document covers only setting up unicorn and generic issues found in set up
and also covers on how to use unicorn to get the T4 template code generation using
RainbowCodeGeneration.

6|Unicorn

4. INSTALLATION OF UNICORN.
In this document we will get to know how to install unicorn on a sitecore project
step by step.
4.1

INSTALL UNICORN USING NUGET PACKAGE

The steps involved in installing in unicorn is mentioned below.


1. Open nuget manager on visual studio under Tools -> Extensions and Updates

2. It will install latest unicorn and Rainbow dlls to the web project

7|Unicorn

4.2 CONFIGURATION CHANGES


1. Create new configuration file for unicorn setting by copying
Unicorn.Configs.Default.example and give name according to the project
namespace.

8|Unicorn

2. Comment out the following node in the unicorn.config:


The below configuration defines where the serialized items of sitecore
reside in physical folder. We will move this configuration to the one added in
the above configuration file.

3. Change the following changes to include the tree items which needs to be
serialized. Also add targetDataStore node which was commented out in
unicorn.config. We can give location based on the source controlled location.
Include your predicates based on your requirements.

4. Access unicorn tool using http://<host-address>/unicorn.aspx

9|Unicorn

5. Click on sign in to Sitecore as an administrator and Login with sitecore admin


credentials.

6. Perform initial serialization

7. Once it runs successfully, you can see the folders created for the mentioned
names in the predicate configuration.

10 | U n i c o r n

5. CREATING T4 TEMPLATE AND CODE GENERATION


We need RainbowCodeGeneration.dll for generating code using T4 template. This will help in
mapping the sitecore fields to the model which also helps in tracking the field changes done
in sitecore.
5.1 INSTALL RAINBOWCODEGENERATION LIBRARY

1. Open nuget manager on visual studio under Tools -> Extensions and Updates
and install RainbowCodeGeneration

2. Once installed, RainbowCodeGeneration will add sample T4 template file. This will
give errors as this is not configured. Error occurs because Sitecore.Kernel.dll and
Sitecore.Logging.dll will not be present

11 | U n i c o r n

3. To eliminate these errors we need to add Sitecore.Kernel.dll and Sitecore.Logging.dll


also change the location of all the dlls to refer to the correct location.

12 | U n i c o r n

4. On the last step change the variable values of T4 template - treename, treepath and
physicalFileStore to the corresponding values

5. If everything mentioned changes are done we will be able to see the


SitecoreTemplates.cs file with the code generation for the templates.

13 | U n i c o r n

14 | U n i c o r n

Vous aimerez peut-être aussi