Experience Sitecore ! | January 2018

Experience Sitecore !

More than 200 articles about the best DXP by Martin Miles

Adding Unicorn icon to Sitecore Launchpad

Seriously, I cannot understand why no one hasn't done that earlier before myself!

Recently, yet another time bookmarking a unicorn.aspx for another specific environment, I caught myself on why not to have Unicorn icon as a standard launchpad tile icon. Benefits of having it there against bookmarking:

  • it becomes available not only for myself but for the rest of admin users in particular environment
  • yes, by saying admin, I want to say that you can customize security for that shortcut
  • if serialized, this icon shortcut becomes available on all the environments it is being deploys

So please welcome Unicorn Launchpad icon. You may download the installation package at the bottom of this blog post.


So, as you might know, all the Launchpad icons are taken from core database and you may find them by the following path:/sitecore/client/Applications/Launchpad/PageSettings/Buttons. So you may add a new icon by simply creating an item called Unicorn (of the template /sitecore/client/Applications/Launchpad/PageSettings/Templates/LaunchPad-Button) as a child of any LaunchPad-Group items (for example, Tools, along with Content Editor).


The much better option would be to duplicate already existing item that is available to admins only - in such case you'll also inherit permissions set) - AppCenter for instance. Once done, adjusts all the fields correspondingly. The most important field to set is Link, so make it pointing to /unicorn.aspx (but remember you may also include parameters, such as unicorn.aspx?verb=sync).

The next challenge is to set an icon. Unicorn is not a part of Sitecore, obviously, Sitecore won't have icon packs for it. Let's create our own icon pack for Unicorn.


Each of these drops down values above (Applications, Apps, Business, Controls etc.), in fact, is a zip archive underneath folder<SITE_ROOT>\sitecore\shell\Themes\Standard.


The structure of archive is the following - unicorn.zip\Unicorn\32x32\Unicorn.png - you may have icons for the other resolutions but I am referencing this one:


That's all the job and it took a couple of minutes!

Download ready to use package (19.7kb, keep in mind that Unicorn icon will be shown to admin users only).

Introducing Sitecore Discussion Club


Introduction

Sitecore User Groups have been a commonly used way of offline knowledge sharing and socializing for long years and we all love them. However, there are some drawbacks and things that on my opinion could be improved.

As I know, there are many of participants willing to present, but typically in most cases one presentation is taken by people from sponsor, yet one more - by Sitecore employees and whatever remains - by some MVP, while there are only 3, maximum 4 speeches available. Those lucky who manage to get presented have to artificially adjust to ~40 minutes format extending their speech time frames, while in fact the core sense of most presentations can be fit into 15 minutes. In addition, user groups are the rare event, occurring once per quarter.

Another thing is that attendants are socialising only little time during breaks between the presentations, while I know few people are attending only just because of networking. At the same time some of attendees are "switched off". I suggest making user groups more interactive with participants interacting with each other apart from just socializing. Limiting presentation with shorter time frames will allow speakers to better structure their thoughts and allocate time for a bigger number of people to participate.

To address these calls, I am going to introduce and run events of a new format, called Sitecore Discussion Clubs, starting in London and that will run on monthly basis (ex. first Tuesday of each month) and in parallel to existing Sitecore User Groups, not as a replacement. This document describes what is Discussion Club and some basic rules and thoughts, however it may be subject to changes.


What is Discussion Club

Sitecore Discussion Club will be held on a monthly basis and consists of four blocks

1. Light Talks

Each of participants can present anything of his / her recent experience or some interesting aspects of work with Sitecore, that may be useful and interested to the community. We currently tend to limit these talks with 5 minutes, having up to 10 talks during the event. It serves as sort of warmup before major part - Discussion Club. Speech registration opens 48 hours before the event via Discussion Club website, with 10 slots open (first come - first spoken principle), where new participants have priority as they are obliged to present. Every new member of the club must present on first visit the club, that speech actually "opens" (or initiates) the membership.

2. Discussion Club

This is the most important part of the event. Each of participants may suggest a problem he / she currently has for a collective-mindset to challenge, but it's not limited with day-to-day issues. One would probably like to discuss new Sitecore features or whatsoever, if it is interesting to other members to discuss (ex. "can someone please tell in which cases SXA is perfect for greenfield projects and how do I 'sell' it to my client?" etc.). All suggestions are registered at the website, and upon the beginning when the organizer goes along this list - each one has 30 -60 seconds to briefly explain the problem and what is he looking from the discussion to get solved. once finished, every participant votes for topics that seems to be interested (that is done using mobile phone). Then an actual discussions start, from most to least voted suggestions on from agenda list. Each discussion limits to 10 minutes, there is also a mechanism of 5 minutes extension (if majority insist, 80% or more clicking "extend" button on their mobile phones next to current discussion).

3. What If

Is the funniest part of the event, but brings huge value. It is also a collective-mind discussion of unusual, weird or even craziest ideas we can do with our beloved platform. As a good example, I want to share few ideas that came into my head and the one I was trying to implement. The first, is a LunchPad with the live icons showing a progress or any dynamically changeable information, pulled from a Sitecore instance (or behind it), for example showing a progress of a long-running scheduled task, and clicking this live icon brings you to corresponding SPEAK app. I expect, that should be implemented with SignalR or similar technology, but very willing to discuss it in more details and potential traps. Another example is a module I have implemented in 2017, that changes item ID from a context menu - it is a great area for discussion what needs to be taken into account and things to keep in mind, such as child items, changing references to this items, reindexing, links database, etc.). These ideas unlock attendees' creativity and serve as an important source of inspiration and will be shared with Sitecore for considering and potential implementation. This is similar way how Dynamic Placeholder, Buckets and Language Fallback became part of the platform. Who knows what valuable inspiration our enthusiasts will create? Also, I am be seeking a sponsorship from Sitecore for awarding 3 most valuable of "What If" ideas, where award can be anything like free certification on choice, or free SugCon / Symposium entrance of whatsoever Sitecore decides.

4. Hiring, not Recruiting

Is the final simple block. Each member of the club can briefly say what Sitecore vacancies do they have open at the moment or in if looking for a new opportunity - make a brief self-introduction. 3-5 minutes for everything would be enough, I assume. Quick, direct, and no recruiters.


Entrance and attendance

The very first event welcomes everyone who is willing to attend - they all will be allowed and receive Discussion Club membership (but please see "First Event" section below). Then an event registration will be done via website similar to MeetUp, running with minor overbooking, just in case few people are not coming. When event bуcomes mature - new members can join the club by invites from existing member (and they still must present light talk upon first visit). Existing MVPs can attend without any limitations, cannot be denied or dismissed from the club. They also have priority for Light talks (but after newbies of course). Sponsors have another "priority lane" for Discussion Club, however not more than on 3 consecutive events, than they have "chill out" event. However sponsor can suggest a topiс on common grounds to be evaluated and voted.


Venue and sponsorship

The event will take part at sponsor's venue in central London, in 3-5 minutes of walking distance from Angel station (map: https://goo.gl/5p8v7D). Sponsor is also proving the necessary equipment, food and drinks, as normal. Dare agency is currently sponsoring the event, I am currently contracted with them building an advanced platform with Helix and Sitecore 9, they are highly interested in absorbing any of the latest Sitecore knowledge.


Benefits

Discussion Club unites the most enthusiastic members of the Sitecore scene from London and area, offering them all sharing the experience. Unlike as on the User Groups, we discuss real-life scenarios, and actual day-to-day problems, as we vote for most preferred topic from agenda. We are more engaged, communicate and discuss directly and collectively. All that enables us sharing our experience in interactive, friendly manner at unprecedented level, that becomes sort of Sitecore Community 2.0

Updating Sitecore 9 with Helix to 9.0 update 1 (rev. 171219)

I am currently developing a greenfield Helix-based solution on Sitecore 9. That is a challenging but thrilling path, resulting in nicely setup working platform with "one-click install + one click deploy" process, perfectly suitable for continuous integration. 

However, as soon as 9.0 update 1 has been released, I started anticipating upgrading my solution to that revision, but for a week or so we've been missing NuGet packages for the latest version. Since January 18-th they have been released so finally it became possible to update the solution. Below there are few things I have done to make it work.

Phase 1. Choosing an update approach to take. 

There are few options:

  • *.update file with actual version
  • upgrade zip archive with only changes + pdf guidance on how to update
  • SIF archive with CMS, xConnect and corresponding configuration *.json files

For sanity purposes, I prefer to fully uninstall the previous version and reinstall the updated afterwards, rather than overwrite things. Thanks to a flexibility of Helix, now developer should not worry about losing an existing state, as soon as everything is checked into a version control system - gulp script will pick the latest changes and do that job for us. That's why approach number 3 becomes a choice. 

As I am keeping web folder under source control (just clean install of each version in order to easily restore that state) it makes sense to move .git folder outside from web folder before we go with uninstall, as it obviously will remove entire web folder. After as we remove the previous version, and newer version settles there, one can return .git folder back and immediately benefit from seeing the difference between two versions. I will cover that below during stage 2. So, to uninstall, open PowerShell and do:

.\uninstall-xp0.ps1

Once complete, got to the next phase.

Phase 2. Preparing and installing new version

First of all, download Sitecore 9.0 Update 1 XPSingle from SDN download page. Since we're doing that for our development environment, make sure you get OnPrem edition, rather than Cloud.

Obviously, to install newer version one need to update Sitecore Install Framework that supports particular version. Luckily, Sitecore Installer knows everything it should regarding how to install the version. PowerShell (with admin rights):

Update-Module SitecoreInstallFramework

If for some reason it breaks with execution policy exception, modify current user appropriate permissions:

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force

Copy Sitecore packages for both CMS and Xconnet into build/assets folder, along with previous version packages. In my case, these files:

Sitecore 9.0.1 rev. 171219 (OnPrem)_single.scwdp.zip and Sitecore 9.0.1 rev. 171219 (OnPrem)_xp0xconnect.scwdp.zip

and also replace *.json scripts from XP0 Configuration files 9.0.1 rev. 171219.zip

Then, quite important, update version details at settings.ps1 script:

$SitecoreVersion = "9.0.1 rev. 171219"
$InstallerVersion = "1.1.0"
Finally, run the installer:
install-xp0.ps1
and wait till it finishes. Warning: do not open Sitecore after it installs.

Phase 3. Saving clean state of web folder with new version
Previously, I have described an approach of restoring a newly installed and previously never run Sitecore from a dedicated git branch, called SitecoreFiles_CM. During this exercise given approach saved me plenty of efforts, as I had to restore initial state of web folder at least 20 -25 times, if not more. That's why, even before I first run Sitecore and it generates plenty of artefacts (logs, caches, etc.) - I do one another commit with a new version of webs folder on top of existing clean install of 9.0 (initial). As a bonus, I get a wonderful tool for identifying changes between clean install of both versions, including config changes, file structure, built-in apps and similar.

Phase 4. Update the solution
Open Visual Studio, but do not deploy as you need to update your solution with all the latest package version. A goal of that phase its to make sure that any of DLLs being published to webroot by gulp script will match existing version of their counterparty within /bin folder of webroot. Sitecore comes with 337 DLLs from the box, and one would probably need to write a decent automation tool to do matching. Again, thanks to SitecoreFiles_CM approach for simplifying my life, as git commit immediately shows all the DLLs that differ from those checked in as a part of 9.0.1 clean install commit. 
As the first step, I went and changed all Sitecore.*.NoReference libraries for each project so they all correspond to 171219 revision. Keep in mind, that some of Sitecore NuGet libraries are versioned differently and do not have revision number in their name.
Changing references in such a large solution taking much efforts, attention and time. That's why I recommend you to do quite often commits while updating your solution, as you'll likely to restore one or few times during that process. Finishing with Sitecore.* references is a good time to check the code.
Then, I went updating Glass Mapper, Unicorn, Unit tests, code generation libraries and the rest of third-party packages. Below there is a list the version I used that are compatible and function:
Autofixture 3.51.0
BuildWebCompiler 1.11.375
EnterpriseLibrary.* 6.0.1304
FluentAssertions 4.19.4
GlassMapper 4.5.0.4
HtmlAgilityPack 1.4.9.5
Kamsar.WebConsole 2.0.0
Lucene.Net 3.0.3
MicroCHAP 1.2.2.2
Moq 4.8.1
Mvp.Xml 2.3.0
netDumbster 2.0.0.1
Newtonsoft.Json 9.0.1
NSubstitute 3.1.0
Rainbow.* 2.0.0
SharpZipLib 0.86.0
Sitecore.FakeDb.* 1.7.2
Unicorn.* 4.0.3
xunit 2.3.1
Lastly, it is a good time to update System.* and Microsoft.* assemblies. 

One thing to mention is that you still need to keep several assemblies at non-final versions and do not update it to the latest, as they will break dependencies. These are listed below along with correct versions:
Microsoft.Extensions.DependencyInjection 1.0.0 
System.Reflection 4.1.0
Newtonsoft.Json 9.0.1
HtmlAgilityPack 1.4.9.5
System.Net.Http 4.0.0
Castle.Core 3.3.3
It took inadequate time to troubleshoot some of those mentioned above, thanks to git in both solution and web folder it became easier to try-test-restore the state.

Finally, it all looks great. Everything works perfect, including generation works, unit tests, Glass Mapper, Unicorn etc.  And few bonuses, of course.

Bonus 1: as soon as I merge this feature branch with updated solution into develop branch of our GitFlow repository, other developers will get the update semi-automatically - with next re-install after refreshing /build/assets folder.

Bonus 2: just nearly forgot to mention: as the reward for an update efforts, I have got an EXM module as part of the platform, yes - now since 9.0 update 1 it comes out of the box!

Get rid of IIS Express processes when debuggind Helix solutions

Problem: you are running a solution with a large number of projects (as we normally have with Helix) and willing to debug it. You are attaching to IIS process (from Debug menu of Visual Studio, or using magical hotkeys) but that takes way too much time to happen. You CPU usage increases and even likely to boost the cooling fans. Another thing you can evidence - slowly responding icon os IIS Express in the system tray:


What comes to one's mind as the first possible solution? To opt out of using IIS Express in favour of full local IIS, as soon as we are using it anyway to host our Helix-based solution. So you open up Web tab of Project Properties and indeed evidence that IIS Express is configured and has Project Url set to http://localhost with some specific long-digit port number:


Then expectedly you change it to Local IIS with Project Url having something similar to http://platform.dev.localwhere hostname for platform.dev.local already exists in your Windows hosts file as well as in IIS binding for that particular website, so that running this URL in a browser will, in fact, give you that locally running website. But you get a weird error instead:


Things are a bit worse, because if you deny creating a Virtual Directory, you'll get a message box as on the image below, and won't be able to close your project tab as it remains modified and will prompt you the same message again and again until you manually terminate devenv.exe process from Task Manager.



What happens? Something has alternative settings preventing you from changing to Local IIS. So need to find this out. After investigating a while I came across...

The solution contains two steps. Part one occurs because there is already a project extension file (ex. Sitecore.Foundation.Serialization.csproj.user) along with your actual project file, that extends (overrides) project settings. Normally, all *.user files are excluded from a source control so your colleague may not experience that same problem despite running the same code from the same repo branch. What exactly prevents you from saving Local IIS changes is UseIISExpress setting, so change it to false:

<PropertyGroup>
  <UseIISExpress>false</UseIISExpress>
</PropertyGroup>

Or just delete it - then settings from actual *.сsproj file will take effect, but as soon as you somehow customise your project, even as little as just clicking "Show All Files" button in the Solution Explorer - then *.user file will be immediately created. So let's move to the second part of this exercise. Now we need to change actual project to use Local IIS. Make sure you set already familiar UseIISExpress property to false

<PropertyGroup>
  <UseIISExpress>false</UseIISExpress>
</PropertyGroup>
and also specify Local IIS to false, CustomServerURL to true with the correct URL where your site is running:
<UseIIS>False</UseIIS>
<UseCustomServer>True</UseCustomServer>
<CustomServerUrl>http://platform.dev.local</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
So now all works. It loads correctly and you can modify and save Web tab of Project Properties without anу issues:


Also, if you already have virtual folders created under your IIS website, make sure they are removed and the website itself contains the right web folder path:


That's it. Please also pay attention to applicationhost.config file that resides under \.vs\config folder in order to be picked by IIS Express. You may delete it without any potential damage, as we just got rid of IIS Express.

Hope this helps!