Friday, October 30, 2015

Combining Kendo UI–Grid with Angular.js–Pass selected item to controller

A colleague couldn’t find a clean solution to pass the selected row in a Kendo Grid to an Angular controller method. So here is a short code snippet that shows how this can be done:

  • Here is the UI(admire my great design skills):

image

  • Here is the corresponding HTML and Angular controller:

Thursday, October 29, 2015

Angular–Strange ng-click issue

A colleague asked me to have a look at the following issue he had:

“I have the following problem inside my Angular application: I’m using the ngclick to capture the click event on a link and call a method on my controller that uses the UI routing to navigate to a different page inside my SPA. However when I click on the link, the navigation occurs as expected but I also see that the URL in my address bar is set to the root domain. To give an example, instead of showing my.spa.com#product/1/edit, the url is reset to my.spa.com.” 

And here is the code he was using:

When I started to debug the problem, I noticed that 2 click events were triggered when you click on the link. The first click event handles the ng-click as you would expect but the second click executes the normal action when clicking on a url(in this case, as the href attribute was empty, it triggers a navigation to the root url, explaining the strange behavior in the address bar).

I was able to fix the issue, by adding a # to the href attribute:

Wednesday, October 28, 2015

What’s a secure password?

As a consultant I visit a lot of companies. At most of these companies I have an account and associated password. Every company has it’s own set of password rules most of the time expecting a combination of letters, numbers, uppercase, lowercase and special characters. But how useful are these password policies and in what ways does it help to make my password hard to crack?

There are a lot of misconceptions regarding passwords and what a lot of people think is a secure password in the end is not. For example, do you think that “P@ssw0rd1!” is a more secure password than “This is my password”? (At least what I know, is that the second one is a lot easier to remember.)

Let’s use Haystack to get the answer:

“Haystack is an interactive brute force search space calculator that allows you to experiment with password length and composition to develop an accurate and quantified sense for the safety of using passwords that can only be found through exhaustive search.”

First check “P@ssw0rd1!” :

image

Let’s now check “This is my password”:

image

Is this what you expected? Glimlach

Tuesday, October 27, 2015

TFS 2015–Visual Studio Test Runner

After upgrading a XAML build template to TFS 2015, some of our unit tests started to fail. I had no idea what was causing the issue, so I tried to enable any kind of logging I could.

I knew that behind the scenes the Build agent was calling the vstest.console.exe, but no matter what I tried I noticed that I couldn’t find the exact parameters that were used to call this test runner Bedroefde emoticon.

I’m not the only one who had this problem, as an issue had already been raised on Uservoice, http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/6073220-diagnostics-logs-should-show-the-vstest-console-co.

Remark: Maybe another good reason to upgrade to the new Build system in TFS 2015, as the Visual Studio Test step nicely logs the exact parameters.

testrunner

Monday, October 26, 2015

F#–Day by Day

In my journey to master the ancient art of functional programming, I found the F# Day by Day repo in Github;

This repository is dedicated to teaching the F# language in tiny increments. The idea is you come back to the repo every day for a small dose of Functional Programming (FP). 

Every day you get some small F# exercises. As each exercise only takes a few minutes, not enough time is not an excuse!

Friday, October 23, 2015

Team Foundation Server 2015–Enable NUnit tests for new Build system

I’m working on replacing the existing build system we use based on XAML Workflow by the new build system introduced in TFS 2015. So far, I really like the experience. Customizing became a lot easier than it was before…

However one of the things I noticed that no Test Results were collected.

 

I opened up the Test Assemblies Step in the build process(click on the step in the Build Results).

image

There I could see that the vstest.console.exe was invoked but that no tests were discovered.image

The reason is that I’m using NUnit and therefore a test adapter should be installed and loaded on the build server.

Enable NUnit Test Adapter for TFS Build

To enable the NUnit Test Adapter, you have multiple options:

Option 1- Use the NUnit Test Adapter DLL’s

  • Log in to your build server
  • Download the NUnit Test Adapter for Visual Studio from the Visual Studio gallery: https://visualstudiogallery.msdn.microsoft.com/6ab922d0-21c0-4f06-ab5f-4ecd1fe7175d
  • Extract the VSIX file(don’t install it!) and copy the DLL’s to the following folder
    • C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Extensions
  • After installation,  go back to the TFS web portal and open the Team Project where you want to configure the build for
  • Go to the Build tab
  • Queue a new build

Option 2 – Use the NUnit Test Adapter Visual Studio Extension

  • Log in to your build server.
    • Remark: When you use this option, it’s important the account you use to log in is the same account that is used to run the tests
  • Download the NUnit Test Adapter for Visual Studio from the Visual Studio gallery: https://visualstudiogallery.msdn.microsoft.com/6ab922d0-21c0-4f06-ab5f-4ecd1fe7175d
  • Install the VSIX file
  • After installation,  go back to the TFS web portal and open the Team Project where you want to configure the build for
  • Go to the Build tab
  • Right-click on the build definition and choose Edit…
  • Select the Visual Studio Test step
  • On the right, expand the Advanced section
  • Add the ‘/UseVsixExtensions:true’ in the Other console options field

image

  • Save the edited build definition
  • Queue a new build

Option 3  - Include the NUnit Test Adapter using NuGet

  • Open the solution you want to build in Visual Studio
  • Add the NUnit Test Adapter NuGet package(https://www.nuget.org/packages/NUnitTestAdapter/) to your solution
  • Browse to the TFS web portal and open the Team Project where you want to configure the build for
  • Go to the Build tab
  • Right-click on the build definition and choose Edit…
  • Select the Visual Studio Test step
  • On the right, expand the Advanced section
  • Add the ‘$(Build.SourcesDirectory)\packages’ in the Path to Custom Test Adapters field

image

  • Save the edited build definition
  • Queue a new build

Thursday, October 22, 2015

TFS 2015–The item may not be cloaked because it does not have a mapped parent.

I’m working on replacing the existing build system we use based on XAML Workflow by the new build system introduced in TFS 2015. So far, I really like the experience. Customizing became a lot easier than it was before…

However not everything is perfect. While building a solution I noticed the following error message:

“The item $/Framework en Tooling/Drops may not be cloaked because it does not have a mapped parent.”

clip_image002

Let’s find out what was going on.

  • Open your favorite browser and navigate to the web access portal for your team project
  • Click on the BUILD tab
  • Expand the Build Definition section, right click on the failing Build definition and choose Edit… from the context menu
  • The build definition is loaded. Now click on the Repository tab.
  • On this tab you see the workspace mapping used for the build definition. In my case it looked like this:

clip_image004

  • Seeing this immediately explained the error message. I was cloaking a folder that was on the same level as the folder I was mapping. With the current mapping configuration the Drops folder would never be downloaded to the local workspace, so it didn’t make any sense to cloak it(and that was exactly what the error message was telling me)
  • To fix it, the only thing I had to do was remove the Mapping line from the list

Wednesday, October 21, 2015

Branching strategies–Blog series

There is a lot of discussion going on about branching strategies and how a good branching strategy looks like.

My preferred branching strategy has only 2 rules:

  • Rule #1 – Don’t branch
  • Rule #2 – Go read Rule #1

Branching should be an exceptional case as every branch introduces a merge cost (and this cost can be high!). Of course in reality, it’s not always that simple.

With the renewed vibe around Continuous Integration and DevOps, a good branching strategy is crucial. One blog series I recommend reading is Version Control Strategies:

This series of articles describes a taxonomy for different types of Feature Branching – developers working on branches in isolation from trunk – and how Continuous Integration is impacted by Feature Branching variants.

  1. Organisation Antipattern: Release Feature Branching – the what, why, and how of long-lived feature branches
  2. Organisation Pattern: Trunk Based Development – the what, why, and how of trunk development
  3. Organisation Antipattern: Integration Feature Branching – the what, why, and how of long-lived integration branches
  4. Organisation Antipattern: Build Feature Branching – the what, why, and how of short-lived feature branches

Tuesday, October 20, 2015

TFS 2015 installation error - TF400069: You must install either SQL Server Analysis Services version 11.0 or the SQL Server Client Tools.

Last year, I had a TF400069 error when installing Team Foundation Server 2013. This year, while installing Team Foundation Server 2015 for a customer, the error reappeared.

Did I learned nothing? Glimlach 

In this case, the situation was a little bit different than before. I no longer installed the Reporting Services component on the TFS application tier. As a consequence, the SQL Client Tools Connectivity libraries were missing on the application tier. These libraries are required to let TFS talk successfully to the data warehouse.

To solve it, load the SQL Server installation media on your application tier(!), start the installation wizard and enable the Client Tools Connectivity.

SQL2014Setup

Monday, October 19, 2015

Team Foundation Server 2015–Office Integration Installer

With the release of Team Foundation Server 2015, we had to say goodbye to Team Explorer. This was kind of annoying as it was the most easy way to get the Office integration installed. But Microsoft promised an alternative and with the announcement of TFS 2015 Update 1 RC, it is finally there. A preview of the new TFS Office Integration Installer was released.

This new installer addresses a couple of scenarios:

  1. People like project managers, BAs, etc that wanted to use our Microsoft Office integration capabilities used to have to install the Team Explorer package.  It was uncomfortably large and included a VS Shell instance that most of them really didn't want.  This new installer just includes the Office integration component (Excel, Project, etc) and is therefore lighter weight.
  2. The PowerPoint storyboarding tool is now available without VS Enterprise/Test Professional. It’s included it in the Office Integration Installer, making it very easy to get with the rest of the Office integration tools.

Great!

Friday, October 16, 2015

The Agile Mind

As a father but also as a manager, I was listening with great aspiration to the Software Engineering radio episode: Linda Rising on the Agile Brain. In this episode Linda explains how our minds can be agile or fixed and how we can evolve to a more Agile mind. This really changed my perspective on how to encourage and stimulate other people.

This one is a life changer!

Some related articles:

Thursday, October 15, 2015

TFS Build: Configure Package source to Enable Package Restore on your Build server

On a project we are working on, we don’t store the NuGet packages in source control, but use NuGet Package Restore instead. This works nicely and even on the build server the NuGet packages are downloaded before the project is compiled.

Problems started to arise when we switched to an internal package repository. When working with Visual Studio, this wasn’t an issue as we just had to add the internal package repository as a new Package Source. However this is not something we could do on the build server.

When building the project on the build server, we got errors like:

“Unable to find version 'xxx' of package 'xxx'”

So how can we fix this?

NuGet configuration is using a hierarchical system similar to how web.config files work. So what we can do is create a nuget.config file at %ProgramData%\NuGet\Config\.

In this nuget.config we add a packageSource reference:

That’s it!

Wednesday, October 14, 2015

NUnit–Method has non-void return value

When running our NUnit tests on the build server, some of them failed with the following error message:

Method has non-void return value

When I looked at the failed tests, they were all using the async/await syntax:

I found the following posts mentioning the error message:

The proposed solution was to updated NUnit to a more recent version, but when I took a look on the build server we were already using NUnit 2.6.

Anyone with an alternative solution?

Tuesday, October 13, 2015

TFS Local Workspaces error -TF400030: The local data store is currently in use by another operation.

On a large Visual Studio project I started getting the following error message:

TF400030: The local data store is currently in use by another operation.

This project is using the local workspace feature of TFS, which has a lot of advantages, but has it own set of problems when your solution gets quite large(think 50.000 items or more).

I tried multiple solutions to solve the issue:

  • One possible solution is to delete the local workspace and recreate it again. This will clear the local version table, and allows you to start over with a clean slate. We noticed a small performance improvement after doing this.
  • An alternative could be to evaluate your current workspace and see if some server side folders should not be mapped. This can help decrease the size of your workspace.
  • Another option you have is to change back from a local workspace to a server workspace. As mentioned before, this option is useful only when your workspace contains a lot of items. In that case switching to a server workspace can help as they are proven to scale to up to 10,000,000 items in a single workspace.

More information: http://blogs.msdn.com/b/phkelley/archive/2013/05/31/tf400030-the-local-data-store-is-currently-in-use-by-another-operation.aspx

Monday, October 12, 2015

WPF/WinForms: Set the Windows Identity as the CurrentPrincipal

In a WPF application we created(yes, WPF is still alive and kicking), security is based on the Windows Identity people used to login on their systems.

However we noticed that when we checked the current Identity through System.Threading.Thread.CurrentPrincipal.Identity, we got the following back: 

{System.Security.Principal.GenericIdentity}
    [System.Security.Principal.GenericIdentity]: {System.Security.Principal.GenericIdentity}
    AuthenticationType: ""
    IsAuthenticated: false
    Name: ""

To change this, we used the following line of code:

AppDomain.CurrentDomain.SetPrincipalPolicy(System.Security.Principal.PrincipalPolicy.WindowsPrincipal);

After doing that, calling System.Threading.Thread.CurrentPrincipal.Identity returned:

{System.Security.Principal.WindowsIdentity}
    [System.Security.Principal.WindowsIdentity]: {System.Security.Principal.WindowsIdentity}
    AuthenticationType: "Kerberos"
    IsAuthenticated: true
    Name: "ORDINA\\BaWu"

Friday, October 9, 2015

NHibernate 4.0 - NHibernate.QueryException : Cannot simultaneously fetch multiple bags

After upgrading to NHibernate 4.0, the following code started to fail:

Before I could easily fetch a collection together with its children and grand-children, but now I got the following error message instead:

NHibernate.QueryException : Cannot simultaneously fetch multiple bags.
StackTrace:   
at NHibernate.Loader.BasicLoader.PostInstantiate() in n:\nhibernate-core\src\NHibernate\Loader\BasicLoader.cs:line 38
at NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList results) in n:\nhibernate-core\src\NHibernate\Impl\SessionImpl.cs:line 1880
at NHibernate.Impl.CriteriaImpl.List(IList results) in n:\nhibernate-core\src\NHibernate\Impl\CriteriaImpl.cs:line 265
at NHibernate.Impl.CriteriaImpl.List[T]() in n:\nhibernate-core\src\NHibernate\Impl\CriteriaImpl.cs:line 277
at Test.Data.Tests.MultipleChildCollectionsTests.Fetch_GrandChildren_Using_QueryOver_And_JoinAlias_Statement() in c:\Projects\Tests\MultipleChildCollectionsTests.cs:line 83

Here was the class I used:

And here is the corresponding mapping file:

Important to notice in the code above is that I’m still using the ICollection interface together with a bag in the XML mapping. The reason I was using a bag is because this is old code and there was no ISet interface built into older versions of .NET. In .NET 4.0 an ISet interface was introduced, so there is no reason to use a bag anymore.

Let’s update the code:

After switching to a set, the error went away. Double win!

Thursday, October 8, 2015

NUnit Test Adapter - BadImageFormatException

Yesterday I mentioned that my NUnit tests were not discovered when I set the Build Target to ‘x64’ and that I had to change it to ‘Any CPU’ to be able to run my tests.

However this only solved part of my problem as my tests started to fail with the following error message:

image

In theses tests I’m using Noesis.Javascript, a .NET wrapper around Google’s V8 Javascript engine, that allow you to execute scripts directly from .NET code. Noesis.Javascript.dll needs the Microsoft Visual C++ Libraries and to use them, you have to set your Compiler target to a specific platform(x86 or x64).

So back to start…

After some research, I found a solution:

  • Inside Visual Studio, click on Test –>Test Settings –>Default Processor Architecture

image

  • This was set to X86. Changing it to X64 solved my problem.

image

Wednesday, October 7, 2015

NUnit Test Adapter–No tests found to run

Today I discovered an annoying bug in the NUnit Test Adapter, a Visual Studio extension that integrates NUnit test execution in the IDE.

I created some new tests for a specific library, however when I tried to load and run my tests, nothing happened. Inside the output window I noticed the following message:

image

What was causing the issue? When I looked at the Build settings for my test project, I saw that the Compiler platform was set to x64.

image

After changing it to AnyCPU, my tests were discovered…

image

Tuesday, October 6, 2015

Test a website performance–webpagetest.org

WebPageTest.org is a great tool to test your website performance.

image

From the website:

Run a free website speed test from multiple locations around the globe using real browsers (IE and Chrome) and at real consumer connection speeds. You can run simple tests or perform advanced testing including multi-step transactions, video capture, content blocking and much more. Your results will provide rich diagnostic information including resource loading waterfall charts, Page Speed optimization checks and suggestions for improvements.

Let’s have a look at some of the rich information it has to offer:

  • A high level overview with a score(between A and F) for important performance characteristics(Remark: I notice that I have some work to do optimizing and caching my images).

image

  • During the test, the page is loaded twice. Once to see how the first view performs and the second time to check for caches. A waterfall diagram is shown with all the loaded resources and a screenshot is taken from the loaded page.

image

  • If you click on a screenshot, you get another view where you see the difference between when the page is fully loaded and when the document complete is triggered. This give you some insight in how the user experiences the site when it’s ready to use.

image

  • The last thing you get to see is a content breakdown.

image

For each of the reports above you can drill down into a lot more details. What’s also nice is that you can choose the datacenter where you want to initiate your test. So if you want to see how an Asian customer experience your site, choose a nearby datacenter from the list:

image

Monday, October 5, 2015

Inspiring blog post–“Let a 1,000 flowers bloom. Then rip 999 of them out by the roots.”

Let’s start the week with an inspiring post by Peter Seibel about the Engineering Effectiveness team at Twitter. There is so much hidden knowledge in this post, that I can keep reading it over and over… Glimlach

Click on the link and learn!

sunflowers

Friday, October 2, 2015

Goodbye ClickOnce! Hello Squirrel!

Over the years I developed a ‘love/hate’ relationship with ClickOnce. Although really great when it works, the moment something goes wrong, you’re in for some pain.

Recently I discovered Squirrel, an open source product, using the following tagline: “Squirrel: It's like ClickOnce but Works™” Glimlach

image

Squirrel is both a set of tools and a library, to completely manage both installation and updating your Desktop Windows application, written in either C# or any other language. It even works on other platforms.

Squirrel uses NuGet packages to create installation and update packages, so creating an installer is easy.

Check out the user documentation and the Getting Started page, which includes a Quick Start guide.

Thursday, October 1, 2015

Visual Studio and Team Foundation Server 2015 ALM Virtual Machines

For years Brian Keller has been delivering a fully functional TFS VM together with a great set of hands-on-labs, everything an ALM expert needs to keep his knowledge up-to-date.

Last year Brian moved away from his role as evangelist for Microsoft ALM, luckily his colleague Sachin Hridayraj continued the story. Yesterday he released a brand new Visual Studio 2015 version, complete with a revised set of hands-on-labs and demo scripts, at http://aka.ms/ALMVMs.

image