Saturday, 14 March 2015

Conflicts with Umbraco 7 install and ReSharper.

Im currently working on a project that abstracts Umbraco away from the customer facing UI AKA front end. We are effectively utilising Umbraco as a service rather than as a platform. Because as a CMS, its incredibly powerful and functional but these benefits come at a cost for the customers interacting with the front end. Typically its performance but there are a whole heap of issues that effect large sites that im not going to go into on this particular blog.

This post is about Umbraco 7 installation. Its an obscure one so I thought I would mention it here to aid folk in the future.

Basically when you install Umbraco from NuGet and you come across the following error.


       
Install failed. Rolling back...
install-package : Expected "$(_PublishProfileSet)" to evaluate to a boolean instead of "", in condition "$(_PublishProfileSet) And '$(PublishProfileName)' 
=='' And '$(WebPublishProfileFile)'==''".  C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets
At line:1 char:1
+ install-package umbracocms
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidProjectFileException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
       
 

It's a known conflict error between Resharper and the install. Further details can be found here. But in brief. Disable Resharper and try again.

Worked for me. I believe the issue is resolved in v9 of ReSharper but further comments would be appreciated.

To disable/Suspend ReSharper

Navigate to:  Tools -> Options -> ReSharper -> Suspend Now

Suspend ReSharper


Tuesday, 3 March 2015

Intro into the OWIN specification and a Hello world example of Katana

Getting Started with OWIN and Katana

Firstly, lets start by trying to identify what the OWIN specification is. The following text is taken from owin.org.
OWIN defines a standard interface between .NET web servers and web applications. The goal of the OWIN interface is to decouple server and application, encourage the development of simple modules for .NET web development
Or in other words; Katana, the Microsoft implementation of OWIN, is basically an answer to node.js just like the ASP.NET MVC framework was the answer to Ruby on Rails.

This is evident when we compare the two hello world web server implementations;

1. Node Web server initiation

2. Katana self hosting web server

Now this is evidently a high level comparison between the 2 but it suggests my point.

Katana, is a collection of projects for supporting and implementing the OWIN specification. The value here is that it creates an abstraction between the web server and application. Meaning it completely decouples server dependencies away from our application. This then introduces the concept of, use what we need and nothing more.

Significantly it includes OWIN support for System.Web and System.Net.HttpListener.

This is an obvious benefit when you review a typical .NET application and notice the dependent reference System.Web.dll; which is over 2.5MB and includes over 10 years of retrofitted development.

Where node uses Node Package Manager, Microsoft uses NuGet to manage these modules.

For this blog post, this is where the comparison stops between these two technologies. I dont want to dwel upon it, however for further readings checkout this performance comparison article; NB. At the time of this blog publication the article was over a year old so the result will no doubt vary.

MSFT's decision to open source their forthcoming ONE ASP.NET platform has meant the open source community has supported the Katana implementation well. Significant support that you can pull down today includes;
I've used a couple of these projects on a basic hello world application. Its a self hosted project running from a console app. But a follow up post will include a Linux host. This is available on GitHub for downloading, forking, or contributing.

View on GitHub





Thanks for reading. As always I would really appreciate any comments.

Monday, 29 December 2014

Concatenating multiple rows into one column in T-SQL

This post looks at how to deliminate many rows into one single column.

I come across this issue quite often so I thought I would share my solution. For example it's quite a good solution for quick ad-hoc data extracts.

There are many ways to do this but the most performant way is actually the simplest too.

The most common approach which most people fall back to would be to iterate through the collection using a Cursor and format a string that way. For many reasons this is not a good idea, from memory to potential deadlock issues to name 2.

For this demo im going to comma deliminate all my tables into a single column for me to then copy this value straight into my favorite text editor to then save as a CSV.

My data looks like the following.
ProductReview
StoreEventPage
AuditLog
Author
TimeLine
TimeLineEvent

Now using the gist below. I can combine the result set of these string values and concatinate them to one string variable.

Now again this is commonly done but note the COALESCE expression. This avoids having duplicated commas and removes null values. The COALESCE expression is a syntactic shortcut for the CASE expression, when the first argument is NULL, COALESCE returns NULL.
The end result is the following which we can now save as a csv.
ProductReview,StoreEventPage,AuditLog,Author,TimeLine,TimeLineEvent

Thanks for reading. Always appreciate hearing your thoughts and comments.
Checkout my website for further info and contact details.

Tuesday, 23 December 2014

Setting up precompiled handlerbars.js templates and using grunt to compile them

What is Javascript Templating

Good place to start is to describe what exactly JS Templating is and what a good use-case could be. For me, I have data that I've retrieved client side and I need to transform it into repetitive markup then I use a templating library.

Now sure Angular and Knockout are pretty popular approaches for rich client side data-binding but in alot of cases they are too bloated and overkill for certain scenarios.

Say I have a legacy app that uses a heavy amount of JQuery (pretty common scenario for me!) and im tasked to render data from a REST API endpoint to the UI. I dont want to add a whole new client side dependency just to render the data. JS Templating, in particular Handlebars precompiler, is perfect for this scenario.

For more detailed comparisons between templating libraries and performance reviews, please refer to the links below.

Its not always that straight forward a decision but if you need close control of your markup then its a great approach. There are many alternative approaches, from utilising client side UI controls like Kendo UI or Infragistics Web Controls to previously mentioned Angular JS templates or Knockout data-binding.

The UI controls are an opinionated out-of -the-box solution while Angular and Knockout require their sizable libraries.

Getting Started

The source for this demo can be obtained here. I haven't created any grunt tasks, im just bringing it all together to offer a solution for this demo. 

Using node package manager I install the following packages.
  • grunt
  • grunt-handlebars-compilar
  • grunt-contrib-watch
  • handlebars
Please note im using v1.3.0 of the handlebars package.
If you copy the following Package.json into the root directory, then these packages can be added automatically by running the following command.
npm install 
The benefit of using precompiled handlebar templates is that we only now need to use the runtime library. Once minified this is only a 7kb file.
Copy the file to your solution directory. The file should be located in the following location.
\node_modules\handlebars\dist\handlebars.runtime.min.js
Im then going to create a directory for my templates to live and then create my first handlebar template file.
mkdir templates
echo. 2>templates/demo-list.handlebars
The next step is to configure the grunt file. This link will give you further details as to how and why we do this. Below configures the handlebars task with the compile target. I then associate this task to the watch task.
This will now run the handlebars task when a file defined in the watch file pattern is changed and saved.
To test this, run the following command.
grunt watch
And edit the contents of the template.

This should then create scripts/handlebars-templates.js file.

Putting it all together

All thats left to do now is to fetch our arbitrary data and render the markup. To do this ive used githubs free api as you can see from the gist of my gist below.


Finally we add the JS references to our page and the container we want to render the markup inside and were done.

All the code for this demo has been added to github so please feel free to pull it down here.
Any queries please let me know and vist my website http://www.zirafon.org for more contact details.

Thanks for reading. Always appreciate your thoughts and comments.
Checkout my website for further info and contact details.