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>

Friday, September 29, 2017

TDS code generation for content items

Code generation of templates works great with glass mapper and TDS in your Sitecore project, however there are times where content items may need to have classes generated. An example would be system pages or settings, which are serialized/deployed and in which item IDs may be required in other areas of code.

Instead of manually declaring these IDs in a static class like the old days, TDS can generate these classes which makes it a bit more dynamic. This makes use of the itempaths.tt transformation file:



And is as simple as editing the properties on the path where you want content serialized - in this case the content item.


Notice that Code Generation Template has been set for this content item. Now when the coder generation is re-run this content item and it's children all have classes available:


Sitecore TDS code generation error Invalid token this

After upgrading my TDS solution to use the new version 3 of the transformation files, on generation an error message would pop up and the following error appeared in the generated file.
An error occured while generating code for item '/sitecore/templates/MyTemplate'.
T4 Template: C:\Projects\MyProject\TDS.Core\Code Generation Templates\glassv3item.tt
Errors:
Compiling transformation: Invalid token 'this' in class, struct, or interface member declaration
Compiling transformation: Method must have a return type
Compiling transformation: Identifier expected
Compiling transformation: 'GeneratedTextTransformation.Write()' must declare a body because it is not marked abstract, extern, or partial
This error is occurring because the glassv3item.tt template as an extra line added at the bottom of the file. Removing this will allow the code to generate without error.

TDS glassv3item new line
Solution via Ryan Tuck.