Monday, April 20, 2015

Visual Studio: Improve your build output with Project Hero

By default the Build output window in Visual Studio is not very user friendly. If you have a large project, you have to scroll a long list of output information to find relevant information.

Project Hero, you have to love the name, a free Visual Studio Extension tries to solve this.

Project Hero is a simple and easy to use plugin that allows you to see the build/clean status of projects in your solution in a clean and visual way. The need for findinga better alternative than the Output Window for large solution build notification drove this effort. I then landed upon Marius Bancila's plugin and that was no longer supported and hadn't been updated in years, and with no source code available I started from the drawing board.

Project Hero

Friday, April 17, 2015

OWIN error: OWIN middleware is not invoked

I’m in the middle of switching between the ASP.NET WIF implementation and the OWIN WIF implementation. I had some unexpected issues, but the positive thing is I learned a lot about WIF and OWIN Glimlach.

I had an existing project where I wanted to start using OWIN. So I included the OWIN NuGet package and added a startup class.

Afterwards I started my application. But no luck, the breakpoint inside the Startup class was never hit?!

What did I do wrong?

OWIN is just a specification and is host independent. If you want to run it on a specific host, you have to add some extra NuGet packages. In my case, I wanted to run OWIN on IIS inside the ASP.NET request pipeline. Therefore I had to add the Microsoft.Owin.Host.SystemWeb NuGet Package.

After doing that, my breakpoint was hit and my OWIN middleware was called…

More information: http://www.asp.net/aspnet/overview/owin-and-katana/getting-started-with-owin-and-katana

Thursday, April 16, 2015

WIF–OWIN error: A default value for SignInAsAuthenticationType was not found in IAppBuilder Properties.

I’m in the middle of switching between the ASP.NET WIF implementation and the OWIN WIF implementation. I had some unexpected issues, but the positive thing is I learned a lot about WIF and OWIN Glimlach.

One of the issues I encountered was the following error message:

“A default value for SignInAsAuthenticationType was not found in IAppBuilder Properties. This can happen if your authentication middleware are added in the wrong order, or if one is missing.”

image

Fixing it is a one-liner:

app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

Wednesday, April 15, 2015

SpecFlow Reusable steps

I’m a big fan of SpecFlow, a BDD style testing framework for .NET. For me it was a life changer, that made testing fun again.
As you start to use SpecFlow more and more, you’ll see the same test steps appear over and over again. The guys from Endjin recognized the same pattern and bundled some of these steps in a re-usable NuGet package(together with some other useful functionality) .
Here is the list of features from the GitHub site:
    • Path & ScenarioContext extensions
    • Shared Steps for dealing with Exceptions:
      [Then(@"an ""(.*)"" should be thrown")]
      [Then(@"a ""(.*)"" should be thrown")]
            
      And Results:
           
        [Then(@"the result count should be (.*)")]
        [Then(@"the result should equal the datetime (.*)")]
        [Then(@"the result should equal the datetimeoffset (.*)")]
        [Then(@"the result should equal the integer (.*)")]
        [Then(@"the result should equal the string ""(.*)""")]
        [Then(@"the result should be false")]
        [Then(@"the result should be greater than the datetime (.*)")]
        [Then(@"the result should be greater than the datetimeoffset (.*)")]
        [Then(@"the result should be greater than the integer (.*)")]
        [Then(@"the result should be greater than or equal to the datetime (.*)")]
        [Then(@"the result should be greater than or equal to the datetimeoffset (.*)")]
        [Then(@"the result should be greater than or equal to the integer (.*)")]
        [Then(@"the result should be less than the datetime (.*)")]
        [Then(@"the result should be less than the datetimeoffset (.*)")]
        [Then(@"the result should be less than the integer (.*)")]
        [Then(@"the result should be less than or equal to the datetime (.*)")]
        [Then(@"the result should be less than or equal to the datetimeoffset (.*)")]
        [Then(@"the result should be less than or equal to the integer (.*)")]
        [Then(@"the result should be null")]
        [Then(@"the result should be of type (.*)")]
        [Then(@"the result should be true")]
        [Then(@"the result should contain")]
        [Then(@"the result should equal the context value (.*)")]
        [Then(@"the result should not be null")]
        [Then(@"the result should not equal the string ""(.*)""")]
          
    • Custom step argument transformations:
      • TimeSpan transformation converts to TimeSpan for the following free-text argument formats:
                 
        1 day, 1 hour, 1 minute, 1 second
        5 days, 4 hours, 3 minutes, 2 seconds
        5 days, 4 hours, 3 minutes
        5 days, 3 minutes, 2 seconds
        5 days, 4 hours, 2 seconds
        4 hours, 3 minutes, 2 seconds
        5 days, 4 hours
        5 days, 3 minutes
        5 days, 2 seconds
        4 hours, 3 minutes
        4 hours, 2 seconds
        3 minutes, 2 seconds
        5 days
        4 hours
        3 minutes
        2 seconds
If you are a SpecFlow user, this is a must have!


Remark: Also check the other SpecFlow extensions they made; Endjin.SpecFlow.Composition and Endjin.SpecFlow.Owin.Hosting

Tuesday, April 14, 2015

Azure IP Ranges

For an integration scenario I’m working on I had to connect Microsoft Azure with my local datacenter. I know there are some solutions available to create a secure connection between your datacenter and Microsoft Azure, but in this case I had to fall back to a direct TCP connection. To minimize the security footprint, I wanted to restrict the range of IP addresses that could access my local server.

But how do I know which IP address range is used by Microsoft Azure? Easy, download the Microsoft Azure IP Ranges document. This file contains the Compute IP address ranges (including SQL ranges) used by the Microsoft Azure Datacenters.

Exactly what I needed…

Monday, April 13, 2015

Aurelia: Live introductory talk

image

Interested in the latest SPA web frameworks? Rob Eisenberg is presenting an introductory talk on building applications with Aurelia tonight at 7pm EDT.  It is streamed on YouTube, so you can watch it live…

Friday, April 3, 2015

Bower–Visual Studio 2013 Integration

I’m currently switching from NuGet to Bower as my client side package manager. The process is not going as smoothly as I hoped. During the process I got a range of problems I blogged about before.

bower

In this final post, I walk through the process of getting Bower up and running inside Visual Studio 2013.

Outside the .NET world(where NuGet is king), NPM and Bower are the 2 mainstream package managers. I don’t like NPM as it creates a deep tree of package dependencies ending up with the NTFS 260 path length issue. Bower uses a flat dependency tree, requiring only one version for each package.

Installation Steps

image

  • Similar to NuGet where we have a package.config file, we need a file (bower.json) to configure the list of packages. The easiest way to create this bower.json file is by opening up a command prompt and running the ‘bower init’ command.
    • This will walk you through a list of questions. You can use the default for everything except the ‘Would you like to mark this package as private which prevents it from being acidentally published to the registry?: (y/N)’. For that question, change the response to yes.

image

  • Include the generated bower.json file inside your project.

image

  • Let’s add some dependencies to the bower.json file. We add a new “dependencies” property and start adding dependencies. The moment you enter a few characters, Visual Studio will offer to search the Bower registry for published packages.

image

  • When I click on the Search Bower… option, a list of matching packages is shown.

image

  • Same thing when I specify a version number.

image

  • Once we are done adding our dependencies, you can right-click on the bower.json file and choose Bower install packages to download and install the configured dependencies.

image

  • Visual Studio will invoke Grunt to get the packages from the registry. By default the packages will be installed in the bower_components folder.

image

  • Now you can include the packages or even better use a Grunt or Gulp task to copy the files over to the correct folder.(but this is for another blog post).

image