Wednesday, April 15, 2015

Sitecore setting up a visual studio solution

Once you have Sitecore installed you will need a visual studio solution to develop in, this post will cover the steps required to create the solution and deploy to the Sitecore web site. Microsoft Visual Studio is required and in this example I am using 2013 Professional. These instructions will cover a web forms based solution as well.

Setting up the solution

  1. Open up Visual Studio and select File > New > Project
  2. Select ASP.NET Empty Web Application and give the project a name
  3. Under the Web.config item select Web.Debug.config and Web.Release.config and right click then Delete.
  4. Click on the Web.config item and set the Build Action to None. This is done because Sitecore has it's own configuration file and we don't want to overwrite it with this one.
  5. Now the Sitecore DLL needs to be added to the solution and referenced, create a folder in the solution and name it "Sitecore".
  6. Navigate to the root of your Sitecore web site (you can do this by clicking Explore on IIS), then go into the Website/bin folder. Copy "Sitecore.Kernel.dll" and "Sitecore.Kernel.xml" into the folder created in the previous step (ensuring you include them in the project as well).
  7. In the project right click on Reference and then click Add Reference.
  8. Click Browse and then select the Sitecore.Kernel.dll from the Sitecore folder added to the current solution. Click OK.
  9. Select the newly added reference and set the Copy Local property to false. The DLL does not need to be deployed to the web root, as Sitecore already has it setup.
  10. The solution creation is now complete. You can now start adding any resources/layouts as required.

Publishing the solution to the Sitecore web site.

In this example I am developing locally so am able to make use of one click publishing.
  1. Right click the project name (in this case MySitecoreSite) and click Publish.
  2. Select Custom and give the profile a name - such as Local Deploy
  3. Select File System as the deploy option using the ellipsis (...) you can either select the IIS entry for the Sitecore web site or manually choose the file system location
  4. Click Next and set the configuration to Debug (if a development environment).
  5. Click Next again and then Publish. The solution will now publish to the Sitecore web site and any created layouts will be available for use. 
  6. Any time you click Publish on the project name, it will happen instantly as these steps only need to be followed once.

Other notes

  • In the past the solution would actually be created in the root of the Sitecore web site. The downside to that method is that source control is harder to use and it can be more difficult to recreate a new Sitecore instance and deploy the code.
  • TDS (Team Development for Sitecore) project(s) can be added to the same solution.
  • If you ever upgrade Sitecore versions, the Sitecore DLL(s) added to the solution will need to be updated as well.

No comments:

Post a Comment