Powershell to publish Helix base solution with VisualStudio 2019 without GULP

As most of Sitecore developers I quickly fall in love with Helix base solution approach but when it comes to developer experience Gulp was not feeling like the best match for build and deployment neither on my local machine…

As you have probably experienced, getting Gulp up and running is pretty simple, but as you start adding projects and complexity to your solution the build time increase exponentially and I have seen solutions where the Gulp build task taking more than 20 minutes, compared to 1-2 minutes of a standard Visualstudio build & publish command….

Therefore my idea to use Powershell even to deploy on my local machine for a full build and publish of my solution locally…

The idea is to hook in the full build and publish of all the projects on the publish of the main website project…

In reality, the code to achieve it, it is pretty simple and you can get it to work pretty easy since you need to worry only about three areas:

  1. Clean up of configs
  2. Build and publish of all the projects
  3. Copy configs that did not come after the full publish

As additional steps, you may consider including the Unicorn or TDS synchronisation to replicate what you do within Gulp but personally, I like to run manually all the items synchronisation to keep closer control and have quicker build and publish time…

Few things to do to get it running:

1.  Install prerequisites

IIS Management Script and Tools must be enabled from ‘turn windows features on or off’

preReqPS.JPG

2. Copy the powershells script and powershell config in the website – configuration folder

You need these two files from my Gist: https://gist.github.com/steliodibello/4cb47563ce43b922b943a000ec072853

remember to replace XXX with your project name

3. Amend the main webiste project to invoke the powershell on the after build step

<Target Name=”PublishAll” AfterTargets=”CopyAllFilesToSingleFolderForPackage”>
<Exec Command=”powershell.exe -NonInteractive –ExecutionPolicy Unrestricted -command &quot;&amp; { &amp;’$(SolutionDir)Configuration\PostPublish.ps1′ -solutionPath ‘$(SolutionDir)’ } &quot;” />
</Target>

 

For further reference and similar blogs who have inspired mine, have a look at:

https://www.onceinawhitemoon.net/2019/04/automatically-deploy-all-sitecore-helix-projects/

and

https://whipeter.wordpress.com/2018/09/07/sitecore-helix-build-and-deploy-powershell-script/

Tracker is not initialized error

Within Sitecore 8.1 and 8.2 you could get easily this “Tracker is not initialized error” even if you are not planning to use analytics but for laziness you have not disabled analytics and/or you left within your layout the VisitorIdentification tag…

The simpler way to get rid of this issue if you are not using Analytics is to remove  Sitecore.Analytics.Tracking.config from your include folder.

In the case you want to use analytics therefore you should check that in Sitecore.Analytics.Tracking.config your hostname property is set to the DNS name that you are using to access to your website….

Is CommerceServer taking over Sitecore?

In the case you have installed Sitecore 8.1 sc81151003 you may have encountered a silly error within your Sitecore Shell…

sitecorecommerce

but wait a minute, I have not installed Commerce Server, why I am getting this error?

In order to remove this unpleasant error message you have to remove the Sitecore.Commerce.Pipelines.ContentEditorLicenseWarning processcor pipeline.
The following patch file will delete the element.

My reccomendation would be also to place the config in a z folder in App_Config to run as the last config.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<getContentEditorWarnings>
<processor type="Sitecore.Commerce.Pipelines.ContentEditorLicenseWarning, Sitecore.Commerce">
<patch:delete />
</processor>
</getContentEditorWarnings>
</pipelines>
</sitecore>
</configuration>

Sitecore CMS only mode on 8.1

As you probably now, Sitecore 8.1 can run in CMS only mode that means that your Sitecore instance can live also without MONGODB architecture…

CMS only mode, disable all the features that require MONGODB like Analytics, behaviour personalisation, MVT but it still allow you to run inSession personalisation rules or execute personalisation rules that do not require MongoDB (eg. geoLocation personalisation)

In order to run Sitecore in CMS only mode you need to set the following parameters:

  1. Xdb.Enabled
  2. Xdb.Tracking.Enabled
  3. Xdb.Configuration.XdbSettings

Further documentation on CMS only mode can be found here:

https://doc.sitecore.net/sitecore_experience_platform/setting_up__maintaining/experience_management/experience_management_an_overview

Block access to Sitecore folder for Content delivery with RequestFilters

In my opinion Request Filters are the simplest option to block access to the Sitecore folder for your content delivery servers… Sitecore recommend to block anonymous access to the Sitecore folder or restrict the access only to a set of IP addresses, but unfortunately there is not an easy way to implement this change, changing the web config and this solution is not PAAS friendly…

 

To learn more about request filters, I would recommend the following page

Therefore I would recommend using request filters to block the access to the Sitecore folder just changing your web config with the following snippet.

 

<system.webServer>
<security xdt:Transform ="Replace" >
<requestFiltering>
<requestLimits maxAllowedContentLength="524288000" />
<filteringRules>
</filteringRules>
<denyUrlSequences>
<add sequence ="/sitecore/" />
<add sequence ="/_Dev/" />
</denyUrlSequences>
</requestFiltering>
</security>

It is important to remind to everybody to change the Sitecore Sitecore.Tasks.UrlAgent to the web site root for CD  by default the url agent point to /sitecore/service/keepalive.aspx and if you block the access, to the sitecore folder, you won’t be able to keep alive…