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.
-
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
- Right click on shortcut icon -> Run as administrator
- Right click on shortcut icon -> Open File Location -> Right Click on shortcut icon -> Properties -> Shortcut Tab -> Advanced -> Check “Run as administrator” -> Apply
- Create a new project
- Templates -> Visual C# -> Web -> ASP.NET Web Application
- Name
- “SitecoreBootcamp”
- Location
- Point to your projects directory
- Check box to create directory for solution
- Empty Project Template
- Add folders and core references for MVC
- Uncheck host in azure
- Add Sitecore NuGet package source
- Open the Options dialog
- Tools -> NuGet Package Manager -> Package Manager Settings
- Tools -> Options
- Quick Launch -> NuGet -> Package Manager Settings
- Inside the Options Dialog
- NuGet Package Manager -> Package Sources
- Click the plus icon
- Name: Sitecore NuGet
- Source: https://sitecore.myget.org/F/sc-packages/api/v3/index.json
- Click Update
- Open the Options dialog
-
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
- Open the Package manager window
- Project -> Manage NuGet Packages
- Quick Launch -> NuGet => Manage NuGet Packages for Solution
- Select Sitecore NuGet from the package source dropdown
- Install options (for each of the install packages named below)
- Select the version that matches your installed Sitecore version
- Dependency behavior = Ignore Dependencies
- File conflict actions = Prompt
- Install packages
- Sitecore.Client
- Sitecore.ContentSearch
- Sitecore.ContentSearch.Linq
- Sitecore.Kernel
- Sitecore.MVC
- Note
- Installing the Sitecore package takes a long time to collect all of the dependencies and installs many packages not needed to do Sitecore development.
- Open the Package manager window
-
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
- Open the Package manager window
- Project -> Manage NuGet Packages
- Quick Launch -> NuGet => Manage NuGet Packages for Solution
- Select nuget.org from the package source dropdown
- Install “Glass.Mapper.Sc”
- Select the latest stable version
- Older version of Sitecore may not be compatible with the latest version of GlassMapper
- Dependency behavior = Lowest
- File conflict actions = Prompt
- Select the latest stable version
- Allow Glass.Mapper to upgrade Sitecore packages
- Allow dependencies to Install
- Castle.Core
- Glass.Mapper.Sc.Core
- Show all files in solution explorer
- Include GlassMapper files in your solution (if not done automatically)
- App_Config/Include/Glass.Mapper.Sc.*
- App_Config/Include/z.Glass.Mapper.Sc.*
- App_Start/GlassMapperSc*
- Open the Package manager window
- Downgrade Sitecore packages
- 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.
- Edit App_Start/RouteConfig.cs
- Remove the default route “{controller}/{action}/{id}”
- This route is not needed by Sitecore
- Remove the default route “{controller}/{action}/{id}”
- Update Views/web.config
- Add the following lines to system.web.webPages.razor/pages/namespaces at the top of the list.
- <add namespace=”Sitecore.Mvc” />
- <add namespace=”Sitecore.Mvc.Presentation” />
- This allows you to use these namespaces in your views without having to include them in every cshtml file.
- Add the following lines to system.web.webPages.razor/pages/namespaces at the top of the list.
- Copy Sitecore web.config to your project directory
- Copy ~/wwwroot/SitecoreBootcamp/Website/Web.config to ~/SitecoreBootcamp/SitecoreBootcamp
- Overwrite the default web.config in your project directory
- 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.
- Copy ~/wwwroot/SitecoreBootcamp/Website/Web.config to ~/SitecoreBootcamp/SitecoreBootcamp
- Build Solution
- Create Publish Settings
- Build -> Publish
- Profile = Custom
- Profile Name = <firstinitial><lastname> (ie JDoe)
-
If you are not running as admin, you will have to do a file system publish. Connection
- Publish Method = Web Deploy
- Name = Localhost
- Server = localhost
- Site name = SitecoreBootcamp (The site name in IIS. Not necessarily the same as the url used to access the site.)
- Validate Connection -> Green check mark
- Settings
- Configuration = Debug
- You can also create your own configuration if you need to have settings specific to your local machine.
- File publish options
- Uncheck all three 3 boxes
- Configuration = Debug
- Publish
- Validate publish settings
- Check existence of ~/wwwroot/SitecoreBootcamp/Website/bin/SitecoreBootcamp.dll
- Launch Site
- http://sitecorebootcamp.localhost
- The first page load after any publish may take some time as Sitecore rebuilds it caches.
- http://sitecorebootcamp.localhost
- Log into Sitecore
- http://sitecorebootcamp.localhost/sitecore
- Default username:password is admin:b
- http://sitecorebootcamp.localhost/sitecore
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
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.
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.