Skip to main content

Microsoft

Sitecore Bootcamp for Developers: Part 3

Setting Up Your Development Environment

Welcome back to Sitecore Bootcamp for Developers! In this part we’ll setup your local development environment to be ready to develop custom code for Sitecore 8.x.
If you are just joining us, please go back and read the introduction where you’ll also find links to each other part of the bootcamp.

  1. If you prefer not to run as admin, you will need to do file system publish instead of web publish in step 11.

    Open Visual Studio in Admin Mode

    1. Right click on shortcut icon -> Run as administrator
    2. Right click on shortcut icon -> Open File Location -> Right Click on shortcut icon -> Properties -> Shortcut Tab -> Advanced -> Check “Run as administrator” -> Apply
  2. Create a new project
    1. Templates -> Visual C# -> Web -> ASP.NET Web Application
    2. Name
      1. “SitecoreBootcamp”
    3. Location
      1. Point to your projects directory
    4. Check box to create directory for solution
    5. Empty Project Template
    6. Add folders and core references for MVC
    7. Uncheck host in azure
  3. Add Sitecore NuGet package source
    1. Open the Options dialog
      1. Tools -> NuGet Package Manager -> Package Manager Settings
      2. Tools -> Options
      3. Quick Launch -> NuGet -> Package Manager Settings
    2. Inside the Options Dialog
      1. NuGet Package Manager -> Package Sources
    3. Click the plus icon
      1. Name: Sitecore NuGet
      2. Source: https://sitecore.myget.org/F/sc-packages/api/v3/index.json
      3. Click Update
  4. While NuGet is the preferred method, you can manually copy the Sitecore DLLs to a _lib folder and reference in each project that needs to build code against Sitecore.

    Install Sitecore NuGet packages

    1. Open the Package manager window
      1. Project -> Manage NuGet Packages
      2. Quick Launch -> NuGet => Manage NuGet Packages for Solution
    2. Select Sitecore NuGet from the package source dropdown
    3. Install options (for each of the install packages named below)
      1. Select the version that matches your installed Sitecore version
      2. Dependency behavior = Ignore Dependencies
      3. File conflict actions = Prompt
    4. Install packages
      1. Sitecore.Client
      2. Sitecore.ContentSearch
      3. Sitecore.ContentSearch.Linq
      4. Sitecore.Kernel
      5. Sitecore.MVC
    5. Note
      1. Installing the Sitecore package takes a long time to collect all of the dependencies and installs many packages not needed to do Sitecore development.
  5. Glass is the most-recommended ORM (object relational mapper) for Sitecore. There are other ORMs available. Using the regular Sitecore API for data mapping is also perfectly feasible, but a bit cumbersome.

    Install Glass.Mapper NuGet package

    1. Open the Package manager window
      1. Project -> Manage NuGet Packages
      2. Quick Launch -> NuGet => Manage NuGet Packages for Solution
    2. Select nuget.org from the package source dropdown
    3. Install “Glass.Mapper.Sc”
      1. Select the latest stable version
        1. Older version of Sitecore may not be compatible with the latest version of GlassMapper
      2. Dependency behavior = Lowest
      3. File conflict actions = Prompt
    4. Allow Glass.Mapper to upgrade Sitecore packages
    5. Allow dependencies to Install
      1. Castle.Core
      2. Glass.Mapper.Sc.Core
    6. Show all files in solution explorer
    7. Include GlassMapper files in your solution (if not done automatically)
      1. App_Config/Include/Glass.Mapper.Sc.*
      2. App_Config/Include/z.Glass.Mapper.Sc.*
      3. App_Start/GlassMapperSc*
  6. Downgrade Sitecore packages
    1. If Glass.Mapper upgraded sitecore packages, downgrade Sitecore.Kernel back to the version that matches your installed Sitecore version and let it auto downgrade any other packages.
  7. Edit App_Start/RouteConfig.cs
    1. Remove the default route “{controller}/{action}/{id}”
      1. This route is not needed by Sitecore
  8. Update Views/web.config
    1. Add the following lines to system.web.webPages.razor/pages/namespaces at the top of the list.
      1. <add namespace=”Sitecore.Mvc” />
      2. <add namespace=”Sitecore.Mvc.Presentation” />
    2. This allows you to use these namespaces in your views without having to include them in every cshtml file.
  9. Copy Sitecore web.config to your project directory
    1. Copy ~/wwwroot/SitecoreBootcamp/Website/Web.config to ~/SitecoreBootcamp/SitecoreBootcamp
      1. Overwrite the default web.config in your project directory
      2. The default web.config does not have the sitecore specific configurations. When you publish the solution, it will overwrite the web.config in the wwwroot directory.
  10. Build Solution
  11. Create Publish Settings
    1. Build -> Publish
    2. Profile = Custom
      1. Profile Name = <firstinitial><lastname> (ie JDoe)
    3. If you are not running as admin, you will have to do a file system publish.

      Connection

      1. Publish Method = Web Deploy
      2. Name = Localhost
      3. Server = localhost
      4. Site name = SitecoreBootcamp (The site name in IIS. Not necessarily the same as the url used to access the site.)
      5. Validate Connection -> Green check mark
    4. Settings
      1. Configuration = Debug
        1. You can also create your own configuration if you need to have settings specific to your local machine.
      2. File publish options
        1. Uncheck all three 3 boxes
    5. Publish
  12. Validate publish settings
    1. Check existence of ~/wwwroot/SitecoreBootcamp/Website/bin/SitecoreBootcamp.dll
  13. Launch Site
    1. http://sitecorebootcamp.localhost
      1. The first page load after any publish may take some time as Sitecore rebuilds it caches.
  14. Log into Sitecore
    1. http://sitecorebootcamp.localhost/sitecore
      1. Default username:password is admin:b

Be sure to follow me through the entire month of November 2017 and follow along with each part as they become available. Thanks for reading, and be sure to leave me comments or questions, I would love to chat with you about Sitecore.
Created by: Eric Sanner, Brandon Bruno, Alan Tibbs

Thoughts on “Sitecore Bootcamp for Developers: Part 3”

  1. Removing the default route “{controller}/{action}/{id}” is not enough, Global.asax also needs to be inherited from Sitecore.Web.Application as Empty Project with MVC adds Global.asax into the solution and on publish you\’ll face issues accessing Sitecore backend.

  2. Thanks for that insight! I did not run into that problem accessing the Sitcore backend you described when creating this guide. I\’ll definitely look into that and update this post.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Eric Sanner, Solutions Architect

More from this Author

Categories
Follow Us