Thursday, January 24, 2013

Extending Sitecore Rocks Installation scripts

A while ago i was asked to setup a new Sitecore development instance for our team. So i went ahead and downloaded the latest Sitecore version and modules needed and installed it on the development environment.  To shorten installation time i decided to use Sitecore Rocks, part of my Visual Studio 2012, as the tool to manage the installation.


After setting the desired folders, licences, credentials and packages to use i hit the execute button. Within minutes my installation was successful and my Sitecore Website was up and running.


When checking my installation I was quite pleased about it, Sitecore Rocks Rocks!

Below i offer the files used as a download and some reference links.


Extending Sitecore Rocks

One issue was noticed anyway: The data folder used in this instance was set via the Web.Config file. This is done in step 6 of the installation script:





Since some time Sitecore ships with a example config file in the App_config/Includes/ folder called Datafolder.include.example. I think it is a good practice to keep the Web.Config file as clean as possible so i set out to see if i could add a new task to the Sitecore Rocks installation list, used to modify the include file instead of the Web.Config.

I managed to make it work, here are the steps to get it to work at your Pc:


Create a task

When you click on one task, the Execute button showsup, click on the arrow and choose to open the task in Windows Explorer. Now you are at: C:\Users\<USERNAME>\AppData\ Local\ Sitecore\ Sitecore.Rocks\ Repositories\ TaskLists \InstallSitecore

Copy the file '1400 - SetDataFolder.task.xml' and rename it to '1410 - SetDataFolderViaIncludeFile.task.xml '. Edit the file content so that it represents the task: modifying the include file.

Create a PowerShell script

While you are in the Windows Explorer, also copy '1400 - SetDataFolder.ps1' and rename it to '1410 - SetDataFolderViaIncludeFile.ps1'.
Notice i have given the tasks a higher number, so it sorts nicely. Change to content of the PowerShell script to:








Reload

Use right-click in the tasklist, and refresh it. Now your new task should be in position seven.

When you navigate to C:\Users\<username>\AppData\ Local\ Sitecore\ Sitecore.Rocks\ Tasks\ Install Sitecore and find the Default.taskproj file. You'll see a reference to the task you created is added.

Re-run the installation

Last step is to execute an new sitecore install and see that the include file is renamed and it's contents is changed.

Happy Rocking!

download the task XML and Powerscript files here

Here are some reference links:
Sitecore Rocks on SDN Forums
Sitecore Rocks in the Visual Studio  Plugin Gallery
Blog by Adam Najmanowicz about Sitecore Powershell
Sitecore page about rocks and Sitecore.powershell



No comments:

Post a Comment

Thank you for responding!