Visual Studio 2017 – Add, Remove or Update DotNetCLITools references – 7th March 2017

Visual Studio release notes as of 7th March release notes state that the DotNetCLITools packages cannot currently be managed by the Nuget Package Manager and must be edited manually in the csproj.

After migrating my current projects, I finally figured out that it wasn’t just me that was struggling to find the place to manage these packages. There’s no intellisense in this area either. Eventually I replaced my pre-release references with the following:

In your csproj file: 

    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
    <DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0" />
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
    <DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.2.301" />

This allows visual studio to run the dotnet commands for building, database, bundling and publishing!


My Resharper license just expired…renew or not to renew

It’s that time of the year again when the licenses on my third party products start lapsing and I pull out my card to renew for another year. Although having used Resharper for a long time, the line between it and Visual Studio has blurred for me. So instead I’ve decided not to renew and use VS2015 vanilla style.

Off the bat, VS 2015 suddenly became blistering fast. The start up, loading a solution and even the vanilla refactoring tools became almost instant. I don’t seem to remember having this problem when I was using VS 2013 but I have definitely felt it in VS 2015. I am rocking a SSD & i7, I can’t help but feel Resharper was slowing me down which is the opposite reason as to what I bought it for in the first place. Out of the thousands tools it does offer, I felt I was only using maybe 10 of them?

I’ve been off Resharper for a few days and I am actually enjoying the change. Two features I do miss so far is Continuous code analysis using StyleCop and Continuous Testing using dotCover. VS 2017 enterprise edition introduces Live Unit Testing which should hopefully fill this void.

I’m going to give vanilla VS2015 another week or so then I’ll try some of the open source options. I did come across this little gem as a free alternative to the paid providers:

EPiServer 10 – Restrict any Block Types on XHtmlString property using the Validation Attribute

I couldn’t find a similar solution online as I believe there is an emerging pattern where we are now instructing clients to drag EPiServer Blocks into Rich Text editors.


As an Editor I want to limit certain blocks types from being dragged into the rich text editor

Solution #1:

Apply this attribute to any of your xhtml properties to enable to validation functionality

[Display(Name = "Text", GroupName = SystemTabNames.Content)]
[XHtmlStringAllowedBlockTypes(new[] { typeof(TextBlock), typeof(ImageBlock) })]
public virtual XhtmlString RichText { get; set; }


Implement the following attribute where your other validation attributes reside.

 public class XHtmlStringAllowedBlockTypes : ValidationAttribute
private readonly Type[] allowedTypes;
public XHtmlStringAllowedBlockTypes(Type[] allowedTypes)
this.allowedTypes = allowedTypes;

protected override ValidationResult IsValid(object value, ValidationContext context)
var contentData = context.ObjectInstance as IContentData;

if (contentData != null &amp;&amp; contentData.Property[context.MemberName].Value is XhtmlString)
var richTextProperty = (XhtmlString)contentData.Property[context.MemberName].Value;

foreach (ContentFragment fragment in richTextProperty.Fragments.Where(x =&gt; x is ContentFragment))
var content = ServiceLocator.Current.GetInstance&lt;IContentRepository&gt;().Get&lt;IContentData&gt;(fragment.ContentLink);

foreach (var allowedType in allowedTypes)
if (allowedType.IsInstanceOfType(content))
return new ValidationResult(string.Format("You cannot add {0} to {1}", content.GetType(), context.MemberName));

return ValidationResult.Success;



Creating a SQL Alias

To help standardize the connectionstrings across your team’s development machines. You can all use the same sql alias, database name, username and password. The last three are easily configurable however the sql alias isn’t so obvious. Here’s a simple set of instructions to get it working.

My environment at time of this post is Windows 8.1, SQL Server 2014 Express.

  • First you must find the port your server is using through tcp/ip.
  • Open SQL Server Network Configuration
  • Click on the server in question
  • in the right hand pane, right click TCP/IP and select Properties
  • Hit the IP Addresses tab and scroll all the way to the bottom
  • The TCP Dynamic Ports is the port you need to use in the next section.


  • Open up Sql Server Configuration Manager
  • Expand SQL Native Client. Choose 32-bit or 64-bit depending on your setup
  • Expend Aliases and create a new entry
  • The port must match the port you found above



Disabling NuGet Package Restore

You’ve enabled NuGet Package Restore and want to reverse that decision? Follow the steps below for every csproj in your solution:

  • Close down the solution
  • Delete the .nuget folder on the solution level
  • Open up each csproj in a text editor
  • Find the following XML tags and delete them:
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />  
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">  
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see The missing file is {0}.</ErrorText>
    <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />

EPiServer 7.5 – Exception – More than one content model is assigned to the guid

When running an EPiServer site and you get the exception “More than one content model is assigned to the guid”. This is usually because you’ve changed a namespace.

There will be a reference to the old namespace cached somewhere so do the following:

1) Clear your bin folder

2) Clear the ASP.NET Temporary files folder under the framework version your project is using

AngularJS – Why?

Why Angular?

AngularJS is written in Javascript and is a HTML compiler. It was written by developer, Misko Hevery who originally built AngularJS as a solution for building HTML components with functionality. It is now a fully fledged open source framework. It allows you to build complete applications.

It is very easy to learn and you will find a team of developers will quickly get up to speed. It is extremely popular and backed by Google so there are plenty of blogs, solutions and discussions out there.


Angular reduces time building an application compared to other mvc frameworks and thus saves money.

Two way binding is one of the most important features Angular provides. It enables real time updating of a model as soon as the variable binded to the scope is changed.

Similiar to jQuery, Angular allows you to write code on a higher level than as if you were writing raw Javascript.

Accessibility and locality is also supported. The ngAria module automatically makes most of your site accessible.

Currency, Dates and Number data types are localized out of the box. For the String data type, you will have to manage locals yourself. There are several 3rd party libraries out there that can help you with this.

Testing is what angular is all about. There are several frameworks created by the team at Google that allows you cover all aspects of testing. ngMock is used for unit testing, Protractor is used for end to end testing and Karma is an automation test tool.