Skip to main content

Posts

Showing posts from April, 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.

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: http://www.codeproject.com/Articles/1095822/Choosing-The-Right-Collection

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 … 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: System.Web.HttpContext.Current.SetSessionStateBehavior(SessionStateBehavior.Required); More information about this method here: https://msdn.microsoft.com/en-us/library/system.web.httpcontext.setsessionstatebehavior(v=vs.110).aspx

Bootstrap 4 Cheat Sheet

A handy, interactive cheat sheet for Bootstrap 4: http://hackerthemes.com/bootstrap-cheatsheet   For every building block inside Bootstrap, it shows you a small code snippet and a preview of the result. A real time-safer!

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: CONFIG REWRITE This will update all fields in your redis.conf file that don’t match the current configuration.

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 http://channel9.msdn.com . 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.

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: http://aka.ms/SDL/PDF . 

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? From OWASP : 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 stylesh...

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.

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?

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! 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 ...

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=1.0.0.0, 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.Resolve...

Microsoft Build–Code Labs

In case you weren’t at Build 2016 or had to miss the Code Lab sessions while there, all the content, instructions, setup and source is available now in the Microsoft-Build-2016 repo. CodeLabs-UWP CodeLabs-Data CodeLabs-WebDev CodeLabs-IoTDev CodeLabs-Office CodeLabs-MobileDevOps CodeLabs-GameDev-1-UnityIntro CodeLabs-GameDev-2-UnityWin10 CodeLabs-GameDev-3-ANGLE CodeLabs-GameDev-4-GraphicsDiag CodeLabs-GameDev-5-MonoGameIntro CodeLabs-GameDev-6-Azure

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: https://blogs.m...

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 ), 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     ...

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: https://leanpub.com/whattolookforinacodereview 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: https://leanpub.com/detectingandsolvingmemory...

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

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 https://www.visualstudio.com/en-us/integrate/api/overview . More information: Getting started: https://www.visualstudio.com/integrate/get-started/rest/basics   .NET client libraries: https://www.visualstudio.com/en-us/integrate/get-started/client-libraries/dotnet

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): Go to the TFS Administration site at the top level(so not the team, project or collection level): e.g. https://myvstssite.visualstudio.com/_admin/ Click on Agent Pools 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

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>’ ...