Tuesday, October 31, 2017

Sitecore 9 SOLR installation and running as a service

When installing Sitecore 9, having SOLR running as a windows service is a required pre-requisite. For those developers like myself that stuck with Lucene for too long, here is how to get SOLR running locally.

  1. Download and install the Java Runtime Environment (JRE)
  2. Set a JAVA_HOME environment variable which points to the java install location
    1. Open up advanced system settings
    2. Click environment variables
    3. Add new
  3. Download SOLR (in this case 6.6.2)
  4. Place the extracted files in the location C:\SOLR
  5. Export a local certificate (in IIS) to a .PFX file, then place this file at the root of the C drive. In my case the file was called local.pfx
  6. Run the following command: "keytool -importkeystore -srckeystore C:\local.pfx -srcstoretype pkcs12 -destkeystore C:\solr\server\etc\solr-ssl.keystore.jks -deststoretype JKS" - this will prompt for the password entered when exporting the certificate. It needs to be run from the Java bin folder (in my case "C:\Program Files\Java\jre-9.0.1\bin").
  7. Open the solr.in.cmd file (located in C:\solr\bin) and un-comment the SSL settings shown below. Ensure you set the password as entered during the key import.
  8. Download NSSM - which will allow us to start SOLR as a service
    1. Place the extracted folder in your program files folder
  9. In the CMD change directory to the NSSM exe (in my case C:\Program Files\nssm-2.24\win64)
  10. Run the command nssm install solr6.6.2
  11. Enter the following information:
  12. Click install service
  13. Now open up services and start the SOLR service
SOLR will now run automatically as a windows service as required by Sitecore 9.

This post is a slight expansion of Installing Sitecore 9 dev environment by Patrick Stysiak.

Monday, October 9, 2017

Sitecore TDS Error GetProjectContentFiles task required parameter ConfigurationToBuild

When attempting to build/deploy a Sitecore solution that used TDS code generation the following error occurred:
The "GetProjectContentFiles" task was not given a value for the required parameter "ConfigurationToBuild". TDS.Master C:\Projects\MyProject\TDSFiles\HedgehogDevelopment.SitecoreProject.targets
I had recently upgraded and then downgraded back again my version of TDS. It appears that the file at "C:\Projects\MyProject\TDSFiles\HedgehogDevelopment.SitecoreProject.targets" was mismatched with my current version of TDS.

Using source control I reset the project back to the latest version (and discarded my changes), which reset the HedgehogDevelopment.SitecoreProject.targets file. This appeared to resolve the issue and the solution built again.

Monday, October 2, 2017

Sitecore EXM - upgrade Cannot use DataAdapterProvider as xDB is disabled

During the upgrade of Email Experience Manager through the versions, the following error was appearing after installing version 3.5
Cannot use DataAdapterProvider as xDB is disabled.
During the upgrade of the core Sitecore product,  two settings were set to false inside the Sitecore.Xdb.Config file. Setting these back to true and the site will load as expected.

  1. Xdb.Enabled
  2. Xdb.Tracking.Enabled
In my case, email experience manager was the last piece of the upgrade puzzle, so these could be enabled again anyway.

Sitecore custom dependency injection breaks after upgrade to 8.2

During an upgrade from version 8.1 to 8.2 of Sitecore, custom dependency injection (Autofac) stopped working after the updated custom code was deployed. Trying to resolve anything would simply return a null and cause the code to break.

It turns out that application start in Sitecore 8.2 has been made internal, which meant the instantiation of this project's dependency injection was not be called. Best practice for Sitecore is not to use App_Start and instead to use the initialize pipeline, as shown below.

The initialize pipeline code:
 
using Sitecore.Pipelines;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;

namespace MyProject
{
    public class RegisterContainer : Sitecore.Mvc.Pipelines.Loader.InitializeRoutes
    {
        public override void Process(PipelineArgs args)
        {
            // App Start code here
        }
    }
}
The initialize pipeline patch file:
 
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
      <pipelines>
          <initialize>
              <processor type="MyProject.RegisterContainer, MyProject"
                          patch:before="*[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']" />
          </initialize>
      </pipelines>
  </sitecore>
</configuration>