Working with Sitecore, Part Seven: Setting Up Your Solution

Monday, March 25, 2013 @ 11:17

By: Josh Jenkins, Lead Consultant

Before I get into it, I wanted to mention that I recorded a video on Setting up a VS Solution for a Sitecore Project that covers everything posted here in this article.

If you can't or don't want to watch this then let's dig in.

Now that we have a clean installation of Sitecore up and running we will be setting up the solution. The first thing we do is create a new repository for the site.

For this example I am going to use BitBucket. You can host your own SCM or use one of the many hosting services out there. In my experience GitHub is great but expensive if you have a lot of private repositories. BitBucket is also great but not as feature-rich as GitHub, but it can handle both Git and Hg repositories and doesn't cost as much. Not a knock on BitBucket, but I have had some issues with the service going down on me in the past. The choice is yours.

The example code for this project can be found at https://bitbucket.org/joshuwaj/scapplication.

The first thing I do for all of my projects is set up a repository. We need to enforce those good habits and make sure we have repository setup from the get go.

From there I will clone the repo locally and build out the file system. Under my main development directory I create the following structure:

\documentation\
\lib\
\lib\Sitecore 6.6.0 rev. 130111
\src\
\src\ui
\src\core
\src\infrastructure
\src\tests
\tools\

Next I copy in a standard .hgignore file I use in most of my projects

That gets me ready to roll and start building things out in Visual Studio. In the video I did all that by hand but I usually run a batch script to do it. I keep a tools directory handy with some common scripts, such as that default .hgignore and this handy batch script:

In Visual Studio you'll create a new Blank Solution by going to File > New Project. Under Installed Templates expand Other Project Types, select Visual Studio Solutions, then select Blank Solution.

Name your project and select your main development directory. A note here, I name the repo the same as the application and follow that through in the file system. This way since you've cloned the repo already and it created your directory if you name the solution the same and select the cloned repo's parent directory (your main development directory) it will just put the .sln files nicely in place.

From there, right click on the Solution in the Solution Explorer and add the following Solution Folder structure:

Core
Infrastructure
Tests
UI
UI\Web

From here you'll add the following projects:

  • Under the UI\Web Solution folder add a new ASP.NET Empty Web Application. Name it following the same convention as your repo and Solution. Use something like Solution1.UI.Web.Website and select the \src\ui folder for the location.
  • Under the Tests Solution folder add a new Class Library. Name it following the same convention as your repo and Solution. Use something like Solution1.Tests and select the \src\tests folder for the location.
  • Under the Infrastructure Solution folder add a new TDS Project. Name it following the same convention as your repo and Solution. Use something like Solution1.Infrastructure.TDS.Master and select the \src\infrastructure folder for the location.
  • Under the Infrastructure Solution folder add a new Empty Project. Name it following the same convention as your repo and Solution. Use something like Solution1.Infrastructure.TDS.Configuration and select the \src\infrastructure folder for the location.
  • Under the Core Solution folder add a new Empty Project. Name it following the same convention as your repo and Solution. Use something like Solution1.Core.Model and select the \src\core folder for the location.
  • Optionally, under the Core Solution folder add a new Empty Project. Name it following the same convention as your repo and Solution. Use something like Solution1.Core.Interfaces and select the \src\core folder for the location.

In the end you'll wind up with something like this:

We'll explore the reason for this structure, what these projects do and how they work together in future posts.