CI with Jenkins, MSBuild, Nuget and Git part 3

In the previous parts (part 1, part 2) of this series I described how to clean, download Nuget packages and build your solution using MSBuild. In this part I will explain you how to create a MSpec MSBuild target and a Code coverage MSBuild target.

MSpec is a testing framework which enables you to write living specifications. Using the MSpec console runner you can easily generate an html report. This report can later on be published using the Jenkins report plugin. By publishing this report we have some documentation on the specifications of the software available and because we did write the specifications using MSpec we also have unit tests in place. So that’s why I call it living documentation. :D

For generating the code coverage report we use the xml output of our MSpec tests. These reports will also be published using the Jenkins report plugin. To do so I use OpenCover and ReportGenerator.

All three packages are installed in my solution using Nuget. So the paths in my build script are based on the paths of my source/packages folders.

Continue reading

CI with Jenkins, MSBuild, Nuget and Git part 2

In part 1 of this blog series we had a look at a very basic MSBuild script which enables us to compile our projects. For doing this I provided you guys with a simple batch file to make it even more simple to execute the build script.

In this episode we will focus on cleaning the folders before building again and getting the Nuget packages using Nuget package restore. The latter I will explain further for you first.

Nuget package restore can be enabled in Visual studio. A best practice is to enable this always, because then we won’t have to put all Nuget packages in source control. By enabling it, every team member will download the missing packages automatically when building his project in Visual Studio. However the build server won’t do this by default so we create a custom target in our build script to make this happen.

Continue reading

CI with Jenkins, MSBuild, Nuget and Git part 1

Very lately I have worked on setting up some continuous integration (CI) using MSbuild for my c# project. In this blog series I will explain to you how to set up continuous integration.

First of all we will start with creating a MSBuild script which will compile our code. We will also create a small batch file for easy executing the MSbuild script.

When that is in place, we will add several targets to the build script to run for example unit tests, integration tests, code coverage, packaging etc.

So we will take the agile approach and improve our build process based on validated learning.

First of all we need some basic knowledge about MSbuild. I think there are enough pages around on the web which will give you a basic introduction. A good starting point would be the MSDN documentation for MSBuild.

Let’s consider we have the following project structure within our Git repository / local file system.

  • src (contains our source code)
  • lib (contains build output, and third party libs not available on nuget)
  • reports (contains code coverage reports, test scenarios and test results)
  • ci.msbuild (your msbuildfile)
  • ci.msbuild.cmd (your batch file to execute the build on your local machine)

Continue reading

Recap my online year 2012

The year 2012 was for me a year that went way to fast. In the year 2012 I learned a lot new stuff, wrote several blog posts and read lots of blog posts and articles. First of all I want you to give a list of all blog posts I wrote this year. You can find the complete list here http://marcofranssen.nl/2012/ and here http://marcofranssen.nl/2012/page/2/.

JavaScript:

Windows 8:
Windows Phone:
Powershell
I even wrote a non-technical article:

Second I want to share my starred articles from my reading archive. I used pocket to bookmark, read and archive my articles, which enables me now to share all starred articles with you. Continue reading

Knockout JS mappings

Knockout JS is a JavaScript library for creating MVVM JavaScript libraries. In a previous post I already showed some of the cool features of Knockout.

http://marcofranssen.nl/2011/09/13/knockout-that-cascading-dropdown/

If you want to spike your knowledge on Knockout a little more first, please visit Knockout’s documentation.

In this article I want to zoom in on the Knockout mapping plugin. The Knockout mapping plugin enables you to easy map your JSON object into an observable JavaScript object. So here is a short example of what you’ll be able to do with it. So when you do an ajax request and receive a JSON result you can for example do the following.

Continue reading

Windows Phone Theme colors

Phone theme colorsWhen developing Windows Phone apps I love to use the theme accent colors in my apps. Since there are some new theme colors in Windows Phone 8 I started searching for their color codes. Lucky me I found them on msdn.

Now you may be thinking how to use the colors in your own Windows Phone apps. The Color object doesn’t contain a color called Emerald. So I created a small class to help me out with this issue. First of all I created a small static helper method to convert the hexa colors to a color object. So we are able to put in the hexa color string and the function returns a color for us.

Then I made some properties that caches the colors for us on their first use. The Color properties looks like this. Continue reading

Unblock downloaded files with PowerShell

Have you ever got in the situation that you downloaded a zip-file and figured out to late the files are blocked? So you extracted the zip file into a folder with existing items. It will be damn hard to figure out which files needs to be unblocked. Besides that it will cost you many work to do so by right-clicking all of the files and clicking the unblock button.

Luckily we have PowerShell and we can easily write a little script to execute the unblock operation on the files in a specific directory. So start by opening PowerShell and key in the following command.

gci  ’c:Somefolder’ | Unblock-File -WhatIf

The above command will unblock all the Child Items in the given directory. The WhatIf parameter will actually not execute it really, but it will show you what the script is going to do. To really execute the action you have to remove the parameter.

gci ‘c:Somefolder’ | Unblock-File

As you may have seen when using the WhatIf parameter, only the files in this folder will be unblocked. What if you want to unblock the files in the sub folders. This can easily be done with the Recurse parameter on your path.

gci ‘c:Somefolder’ -Recurse | Unblock-File -WhatIf

Because I used the WhatIf parameter again I can pre-check what the command actually is going to do. When I’m sure I want to do it I can just remove the WhatIf parameter again and run the script against the files.

gci ‘c:Somefolder’ -Recurse | Unblock-File

So now you wont have to worry about files being blocked just execute the script and you’re ready to go. Bookmark this article to easily access the commands when you need them and share it with your friends to make their lives also a little easier. Oh and don’t forget to have a look at the ‘PowerShell Getting Started Guide‘ for more information on using PowerShell.