Wednesday, November 1, 2017

Creating your first Sitecore 9 Visual Studio solution

So you've now got Sitecore 9 up and running, the next step is to create a solution to allow custom code to be deployed. The following steps will show you how to setup a single project solution, but the concepts will work when adding more projects to form a Sitecore Helix solution.
  1. Firstly, create a new a new web project and ensure the target .NET Framework version is 4.6.2 (see here if 4.6.2 is not available).
  2. For a project template select the Empty option and check the MVC checkbox.
  3. Delete the Global.asax file.
  4. Set the Build Action to None for the Web.Config file.
  5. Add the Sitecore Nuget Feed as a source in Visual Studio.
  6. Add the following nuget packages from the Sitecore feed (I like to use the no reference ones, as the dependent references are often not required).
    1. Sitecore.Kernel
    2. Sitecore.Mvc
    3. Sitecore.Mvc.Analytics
  7. In the Views/Web.Config file add the following two lines (in the namespaces section):
<add namespace="Sitecore.Mvc" />
<add namespace="Sitecore.Mvc.Presentation" />

Now your project is ready to build and deploy to your Sitecore instance. Don't forget to follow the Helix principals!

No comments:

Post a Comment