Sitecore Local Environment for Development Part 2: Solution configuration in Visual Studio 2015

27 noviembre 2017
Sitecore Local Environment for Development Part 2: Solution configuration in Visual Studio 2015

Greetings Sitecore Players!

On this occasion, we will continue our discussion on how to configure our local Sitecore environment using Visual Studio.

You can review the first part by clicking on the following link: Sitecore Local Environment for Development Part 1: Installing Sitecore Instance.

This time we will see how we can configure our solution in Visual Studio 2015 to start developing.

Requirements

Visual Studio 2015

Configuring the solution

  1. Open Visual Studio 2015 as administrator.

  2. Next we will go to the menu -> File> New> Project.

  3. Once inside the new project window, we will look for the "ASP.NET Web Application" template.

    As an example we will use the name "SitecorePlayground" for our project, then press OK.

  4. Inside the new ASP.NET project dialog, select "Empty" Template and select the option "MVC" to add the necessary references.

  5. Once the solution is created we must copy the Global.asax file from our Sitecore instance to the directory where our solution is located.

    To access the project directory more quickly, we can right-click on the project and click on the option "Open Folder in File Explorer".
  6. Next, we are going to change the properties of our Web.config so that it does not overwrite the one of our local instance.

    To do this we must right click on the Web.config file in the solution explorer, and select the option "Properties".

    Within the properties of the file, we will select:


    • Build Action: None

    • Copy to Output Directory: Do not copy


  7. In the next step, we must add the references to the Sitecore dlls.

    As a good practice, we will create a "Library" folder in the directory of our solution. And we will copy the following dlls from the "bin" folder of our Sitecore instance.

    • Sitecore.Kernel

    • Sitecore.Mvc

    • Sitecore.Mvc.Analytics

  8. Once the dlls are copied, we will proceed to add the references to our web project.

  9. Then, we must modify the properties of the references so that it does not overwrite the dlls of our instance.

    To do this we must right click on each of the references that we previously added, and select the option "Properties".

    Once in the property window of the reference, we will select:

    • Copy Local: False

  10. In the next step, we will add the following references in the Views/web.config file.

    • <add namespace="Sitecore.Mvc" />

    • <add namespace="Sitecore.Mvc.Presentation" />

  11. As a last step, we will create a "Publish Profile" to publish our code.

    1. First, we enable the option View > Toolbars > Web One Click Publish.

      This will allow us to see the following toolbar:

    2. Within it, we select the option to create a new profile:

    3. Then we assign a name to our profile, in this case we will use "Sitecore Playground Local Environment".

    4. We will select the publication method "File System" and as Target Location we will look for the Website folder of our local Sitecore instance.

    5. Finally, we click on "Publish".

Solution created successfully. Congratulations!

Happy Coding!