Friday, April 29, 2016

TFS Build vNext - Nunit 3.0 Test Adapter error

When trying to run my NUnit tests on the build server, my build turned red with the following error message inside the Test step:

2016-04-28T08:46:53.3339665Z ##[error]Error: Exception System.ArgumentException, Exception thrown executing tests
2016-04-28T08:46:53.3339665Z ##[error]
2016-04-28T08:46:53.3349431Z ##[error]Error: Illegal characters in path.
2016-04-28T08:46:53.3349431Z ##[error]


This problem is caused by a bug in the NUnit 3.0.8 test adapter when used through the NuGet package(and not through the VSIX extension). Luckily a fix is already available, so upgrade to the latest version of the NUnit test adapter and the problem should disappear.

Thursday, April 28, 2016

C#–Choose the right collection type

.NET offers a lot of way to store a set of values  like lists, queues, stacks, dictionaries, etc… each with their own (dis)advantages and performance characteristics.

Unfortunately I see a lot of developers just use the default List<T> without being conscious about this decision. Arthur Minduca created a simple flowchart to help you choose the correct structure for your specific situation:


Read the full article here:

Wednesday, April 27, 2016

Visual Studio 2015 NuGet error–Exception ‘System.AggregateException’ thrown when trying to add source.

After upgrading to the latest NuGet version inside Visual Studio 2015, I couldn’t install any NuGet package anymore. Instead I got the following error message:

Exception ‘System.AggregateException’ thrown when trying to add source ‘http://development/nuget/Default’. Please verify all your online package sources are available.


The issue is that one of my package sources is a private feed for one of my customers and is not available anywhere else. Before updating to the latest version of NuGet, this didn’t cause any issues. But not so in the latest version Sad smile

I temporarily deleted the private feed, but a real solution would be welcome!

Using the Session object in ASP.NET Web API

By default when you try to use the Session object inside ASP.NET Web API the Session object will be null. This is not a bug but expected behavior as HTTP is stateless – meaning that there shouldn’t be a need for any kind of server state as every HTTP request should contain all the information needed to process the request.

Sorry to all the HTTP and REST purist, but the reality is messy and sometimes using the session state can be the easiest solution. 

To instantiate the session during your Web API request, you can add the following line to your Application_PostAuthorizeRequest method inside the global.asax:


More information about this method here:

Tuesday, April 26, 2016

Bootstrap 4 Cheat Sheet

A handy, interactive cheat sheet for Bootstrap 4: 


For every building block inside Bootstrap, it shows you a small code snippet and a preview of the result. A real time-safer!


Monday, April 25, 2016

Reconfigure Redis cache

It is possible to reconfigure your Redis cache from a Redis client without stopping or restarting the service by executing the CONFIG SET command:

CONFIG SET maxmemory 2mb

However be aware that this will not change the redis.conf file and that your change is gone with the next restart of Redis. To persist your configuration change, you can use the CONFIG REWRITE command:


This will update all fields in your redis.conf file that don’t match the current configuration.

Friday, April 22, 2016

dotnet Conf 2016 is coming

dotnet Conf 2016 is getting closer:

Immerse yourself in the world of .NET and join our live stream for 3 days of free online content June 7 - 9 featuring speakers from the .NET Community and Microsoft product teams. The live stream will be broadcasted on

Learn to develop for web, mobile, desktop, games, services, libraries and more for a variety of platforms and devices all with .NET! There will be presentations on .NET Core and ASP.NET Core, C#, F#, Roslyn, Visual Studio, Xamarin, and much more.


Thursday, April 21, 2016

Free ebook: The Security Development Lifecycle



If you are interested in security(who isn’t?), I have a great tip for you. Microsoft made The Security Development Lifecycle: A Process for Developing Demonstrably More Secure Software (Microsoft Press, 2006) book available free. Although more than 6 years old, most of the content is still relevant today.

Download the ebook here:

Wednesday, April 20, 2016

ASP.NET MVC 5 - X-Frame-Options

By default ASP.NET MVC 5 adds the X-Frame-Options HTTP header to your response.

What does this header do?

From MDN:

The X-Frame-Options HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in a <frame>, <iframe> or <object> . Sites can use this to avoid clickjacking attacks, by ensuring that their content is not embedded into other sites.

What is clickjacking?


Clickjacking, also known as a "UI redress attack", is when an attacker uses multiple transparent or opaque layers to trick a user into clicking on a button or link on another page when they were intending to click on the the top level page. Thus, the attacker is "hijacking" clicks meant for their page and routing them to another page, most likely owned by another application, domain, or both.

Using a similar technique, keystrokes can also be hijacked. With a carefully crafted combination of stylesheets, iframes, and text boxes, a user can be led to believe they are typing in the password to their email or bank account, but are instead typing into an invisible frame controlled by the attacker.

How to disable this header?

As mentioned at the beginning of this article ASP.NET MVC 5 adds this header to your response by default and this for a very good reason. Despite this fact I had a situation were I wanted to disable it and remove this header from the response. Easiest way to do this is by adding the following line to the Application_Start() method inside Global.asax:

System.Web.Helpers.AntiForgeryConfig.SuppressXFrameOptionsHeader = true;

Remark: This will make your website more vulnerable, so try to avoid it whenever possible.

Tuesday, April 19, 2016

Release the Kraken - GitKraken

As I’m using Git more and more as my day to day source control system, I’m trying some different tools to see which one best suits my needs.


One of the tools I’m giving a test run is GitKraken, an (at the moment of writing) free tool to manage your Git repo’s.


It offers some nice features like:

  • Build on top of Electron making it a great cross platform experience
  • Brings a lot of the power of Git in an easy visual interface
  • Visual hints to guide you through the Git process
  • Submodules and Gitflow support

What I especially like so far is that it makes Git a lot easier to use without losing its power and flexibility.

Monday, April 18, 2016

TFS 2015 Update 2–Build badge

After upgrading to TFS 2015 Update 2, a build badge appeared on the Code hub:


When you click on it, you can create a new build definition that will be linked to the code and the build badge.


Unfortunately I couldn’t find a way to select an existing build definition instead. For most of my projects, a build definition already exist and I would prefer to use that one instead of creating a new one.

Anyone who knows if this is possible and how this can be done?

Friday, April 15, 2016

TFS Work Item improvements

Work Items are a core concept of Team Foundation Server, representing any kind of  project related work like ‘Bugs, Tasks, Change Requests, …’. Work Items really are the glue between every aspect of TFS bringing a lot of information together.

Unfortunately there were 2 features missing that limited the experience and usefullness of Work Items:

  • You cannot change Work Items from one type to another. E.g. a bug work is created that after investigation turns out to be a change request.
  • You cannot move Work Items from one Team Project to another.

But good news! In the VSTS release notes from April 13, these features were finally added! Smile

Change work item type

You can now easily change the type of a work item, or multiple work items. Simply select your preferred type, add a comment, and hit change. The form will update as a result of the selected type and you will have a chance to review before saving to commit the change.

Change type is also an option during a work item move if the type you are moving does not exist in the destination team project.

Change a work item type

For details see Move, change, and delete work items or Bulk modify work items.

Work Item move (single or bulk)

Users may now move a work item(s) between team projects. The work item ID remains the same and all of the work item's revisions are moved. Users may also change type during a move and add a comment to be included as part of the work item's discussion section.

Thursday, April 14, 2016

Xamarin error - Could not load assembly 'Xamarin.Android.Support.v4'

After upgrading my Visual Studio to the latest version, I couldn’t compile my Xamarin project anymore. Instead I got the following error:

Severity    Code    Description    Project    File    Line    Suppression State
Error        Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Xamarin.Android.Support.v4, Version=, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Xamarin.Android.Support.v4.dll'
   at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
   at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
   at Xamarin.Android.Tasks.ResolveAssemblies.Execute()    App1.Droid    C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets    1316


Luckily it was fixed easily by updating the Xamarin.Android.Support.v4 NuGet package to the latest version.


Tuesday, April 12, 2016

A language for Architecture by JD Meier

Last week I stumbled over the following blog post in my news feed; “A Language for Architecture” by JD Meier. This post is redelivery of an old article that JD Meier wrote for the Architecture Journal. It brought back some old memories…

Anyway, although the categories described are rather outdated, I do still believe that the approach that JD Meier describes is good starting point to help you think about  your architecture.

“Building software applications involves a lot of important decisions. By organizing these decisions as a language and a set of mental models, we can simplify organizing and sharing information. By mapping out the architecture space, we can organize and share knowledge more effectively. By using this map as a backdrop, we can also overlay principles, patterns, technologies, and key solutions assets in meaningful and relevant ways. Rather than a sea of information, we can quickly browse hot spots for relevant solutions.”


Go read it:!

Monday, April 11, 2016

TFS Build 2015–Script to remove build tasks

After sharing a script to be able to upload build tasks to your on premise TFS instance, here is a second script to remove build tasks:

Friday, April 8, 2016

Powershell: Error invoking Invoke-RestMethod cmdlet

Inside a Powershell script I’m using I have the following line:

$headers = @{ "Accept" = "application/json; api-version=2.0-preview"; "X-TFS-FedAuthRedirect" = "Suppress" }

Invoke-RestMethod -Uri $url -Credential $Credential -Headers $headers -ContentType application/octet-stream -Method Put -InFile $taskZipItem

I’m using the Invoke-RestMethod cmdlet to call a REST api with some parameters. Although this worked perfectly on my machine(it always does isn’t it Smile), it failed on a colleagues machine with the following error message:

Invoke-RestMethod : The 'Accept' header must be modified using the appropriate property or method.

Parameter name: name

At C:\uploadtask.ps1:31 char:1

+ Invoke-RestMethod -Uri $url -Credential $Credential -Headers $headers -ContentTy ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Invoke-RestMethod], ArgumentException

    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Some investigation brought us the answer. In Powershell v3 you cannot specify the Accept header when calling the Invoke-RestMethod. To solve this we upgraded to Powershell v4 and the error was gone. (That also explained why I had no issue as I was running Powershell v5).

Thursday, April 7, 2016

Free ebooks by JetBrains

The guys from JetBrains combined a set of blog posts in 2 easy-to-read ebooks:

What to look for in a code review
A series of tips on what to look for when doing code reviews, including aspects of testing, security, performance and more. The book is a compilation of blog posts on the same topic available on the Upsource blog.
Download the book here:

Detecting and solving memory problems in .NET
This book is a collection of tips and trick mostly published previously in the form of blog posts and tutorials, and is centered around working efficiently with memory management in .NET.  The content is based on the experience we've had here at JetBrains when developing such well-known products as ReSharper, dotCover, dotTrace, dotMemory and others. In other words, this book is our vision of best practices in finding and solving memory issues in .NET applications.
Download the book here:

More books are in the works. Thanks guys!

Wednesday, April 6, 2016

Powershell–Import a module from a relative path

While creating some custom Powershell commandlets using C# we were wondering how we could load these using a relative path.

Starting from Powershell 3.0 this became easy thanks to the introduction of the $PSScriptRoot variable. This variable always points to the folder the current script is located in.

An example:

Import-Module $PSScriptRoot\..\BuildScripts\CopyFile.dll

Tuesday, April 5, 2016

TFS 2015–API documentation

TFS 2015 offers a rich (REST) API that can be used to manipulate and automate almost every aspect of Team Foundation Server. If you don’t know where to look for the documentation, here is the link


More information:

Monday, April 4, 2016

TFS 2015 Builds–Required rights to upload tasks

Today I introduced a colleague into the world of the new TFS 2015 task based build system. Unfortunately he didn’t succeed on uploading a task. I couldn’t remember the required rights to upload a task.

Some investigation brought the answer, to upload tasks you should be at least Agent Pool Administrator. This can be configured on the TFS administration page.

Here are the steps involved to configure this on VSTS(the steps for TFS on Premise are similar):


  • Click on All Pools


  • On the right you should see 2 groups: Agent Pool Administrators and Agent Pool Service Accounts


  • Click on the Agent Pool Administrators group and choose Add… to add extra users


Friday, April 1, 2016

TFS 2015 - Error on the ‘Assigned To’ field after upgrading to TFS 2015

After upgrading to TFS 2015 a customer called me as some users were having issues with the ‘Assigned To’ field after the upgrade.

When these users opened a specific PBI/Bug, they saw the following error:


The issue only happened for users that exists multiple time in TFS with the same name but different AD accounts:


The issue is caused by a change in TFS 2015 , with the introduction of the concept of an identity field. This concept is introduced to fix issues that involve duplicate display names. Previously, if two users had the same name, TFS could not differentiate between them. During the upgrade to TFS 2015, all applicable fields are upgraded to identity fields and usernames are replaced with the following structure ‘display name <email or domain\alias>’. . However this is an issue for fields where syncnamechanges=false as the string value itself is returned from the database. This causes the error above because  for example ‘Bart Wullems <domain\bawu>’ is not a valid user.

Two possible workarounds to fix this:

  • Before the upgrade, update any templates that have the syncnamechangesproperty set to false for fields that have identity rules to set the syncnamechanges property to true.
  • Add an <AllowExistingValue /> rule on any identity field that has the syncnamechanges property set to false.

More info: