Unicorn for Sitecore and Version Control First Time Setup

After I got #Unicorn for #Sitecore setup for the first time I noticed the folders and yml files were created in my sites data folder. I want those files as part of my project and source controlled similar to TDS. So doing some research I found this setting in the Unicorn.config folder.

<targetDataStore
physicalRootPath=$(dataFolder)\Unicorn\$(configurationName)
useDataCache=false
type=Rainbow.Storage.SerializationFileSystemDataStore, Rainbow
singleInstance=true/>

I changed to my local folder in my project. I created two new folders under App_Data (Unicorn\Serialization).

<targetDataStore
physicalRootPath=C:\Projects\SitecoreTestSite\src\WebApplication1\WebApplication1\App_Data\Unicorn\Serilization
useDataCache=false
type=Rainbow.Storage.SerializationFileSystemDataStore, Rainbow
singleInstance=true/>

*Please note there is a Unicorn.CustomSerializationFolder.config.example that you can also change this setting in. Just remove the .example to use it.

When I went to [site]/unicorn.aspx I received the following error. If you receive this error either change the path to a smaller length or in my case I changed the value in App_Config\Include\Rainbow.config.

I changed this line:

<setting name=”Rainbow.SFS.SerializationFolderPathMaxLength” value=”103″ />

To

<setting name=”Rainbow.SFS.SerializationFolderPathMaxLength” value=”105″ />

Now after going back in to the Unicorn Control Panel I was able run an Initial Serialization. I had to do this since the folder path changed.

Then Sync Selected.

SitecoreTestSite sync complete: 1767 items evaluated, 0 items modified (0 added, 0 updated, 0 recycled) in 6331ms (~3.6ms/item).

Now back in my solution I show hidden files and folders and there are my files. I can then include them in my project.


So now you can make the files part of any source control sytem you are using. It is worth mentioning that there are other methods you can use like Sitecore Courier and Sitecore Ship. Also since projects are sometimes setup different locally for developers using something like slowcheetah might be a good idea to have your own development configuration for the Unicorn.config and Rainbow.config.

Update. In your publish settings I recommend checking the box that says Exclude files from the App_Data folder. You probably don’t want to publish those files.

localdeploy

Now I need to figure out how to sync someone else’s changes. I suspect it might be using the Publish Unicorn and Replace Unicorn from Server options.

3 thoughts on “Unicorn for Sitecore and Version Control First Time Setup

  1. Why would you want to include your Unicorn files into the Visual Studio project(s)? I can’t think of an other reason than “I want to be able to access those files from Visual Studio”.

    Like

      • The setup as is used in Habitat actually also doesn’t include the yml files in the VS projects. The main reason that’s done, is because VS just gets slow when adding lots of files. And to think of it: VS doesn’t need to know of the files… just Git needs to find them. 🙂

        Liked by 1 person

Leave a comment