Jake Ginnivan's blog

Release NuGet SemVer Packages From Teamcity

I have a number of open source projects and I do not really have a good release process. So I spend the arvo trying to figure out a good way to do it.

My goals were

  • Use GitHubs releases feature - https://github.com/blog/1547-release-your-software
  • I want to release from NuGet
  • Preferably write release notes before I click the button in TeamCity, this way i can add them on github to build up a release
  • Support SemVer, including pre-release packages
  • Assembly versions should be stamped with informational version as well as a version
  • Be able to link to the project GitHub releases from the NuSpec

Convention Tests V2 Released

ConventionTests v2 Released

Krzysztof Koźmic first spoke about ConventionTests at NDC 2012. You can find the video of that talk here, slides here and the introductory blog post here.

In v2, we have rewritten convention tests from the ground up to make it easier to get started, bundle some default conventions and also decouple it from a specific unit testing framework.

There is still plenty we can make better, so please raise issues on github with suggestions!

What is ConventionTests?

Convention over Configuration is a great way to cut down repetitive boilerplate code. But how do you validate that your code adheres to your conventions? Convention Tests is a code-only NuGet that provides a simple API to build validation rules for convention validation tests.

Pack URI in Unit Tests

I had a unit tests which constructed a pack uri, and I didn’t want to abstract it (needless abstraction) so here is how I solved a few issues.

Exception 1

System.UriFormatException : Invalid URI: Invalid port specified

This one is pretty easy to fix, you can use the PackUriHelper which registers a few things in it’s static ctor

PackUriHelper.Create(new Uri("reliable://0"))

Exception 2

System.NotSupportedException : The URI prefix is not recognized

This one is fixed by giving WPF the default resource assembly.

System.Windows.Application.ResourceAssembly = typeof(App).Assembly;

Now you should be able to unit tests around pack uri’s

Verifying Logged Messages With Log4Net

I came across a constructor which looked something like this, just to enable a test to inject a mocked ILog and validate the calls.

ClassCtor(...., Func<ILog> logFactory) { .. }

The log factory would grab inject a log for the class, but everywhere else in the app used

ILog log = LogManager.GetLogger(typeof(CLASS));

There must be a better way, something like a scoped appender or something, so I came up with this syntax

ClickOnce Signing Error

On my current project we use ClickOnce, and I am setting up the build server to sign using a proper cert rather than a self generated one.

The command:

mage.exe -New Application -ToFile <path>\App.exe.manifest -name "<Name>" -Version 0.1.1.1 -FromDirectory <path>\0.1.1.1\ -IconFile App.ico -CertHash "‏ca5da5a1f7c57411111111a79cbf50c4432ed949"

And was getting This certificate cannot be used for signing - "ca5da5a1f7c57411111111a79cbf50c4432ed949"

I was searching for what extended attributes are required, checking if I got the right thumbprint and wasted a bunch of time.

The fix was simple, remove the quotes around the thumbprint

ReSharper Xaml Attribute Ordering Plug-in

A while back I got introduced to https://xamlstyler.codeplex.com/ which is a pretty good visual studio plug-in for formatting xaml, but I like ReSharper’s formatting options better :)

So over the weekend I was at JetBrains Day in Malmo, and Matt Ellis did a talk on ReSharper extensions. I figured it would be a good time to try and write a plug-in.

Here are some screenshots

Moar Xaml Code Cleanups

Options

Now, I don’t expect this to be super stable and I know of a few issues (like when you first format the Window tag is not quite formatted right), but I hope to setup a CI build and get some fixes out over the next week or so.

Check out the code, report issues and submit pull requests at https://github.com/JakeGinnivan/XamlAttributeOrderingCodeCleanup and install from ReSharper Extensions Site

ClickOnce From Azure Blob Storage

Even with all it’s problems ClickOnce is actually a decent option if you want a simple installer and an application which Self Updates.

Creating the ClickOnce installer

I don’t like using the publish feature in VS for my ClickOnce installers, it causes more problems than it solves. I tend to use Mage directly, but this is sometimes not that easy to figure out how to do it. Lets start by creating our installer.

I am using MSBuild as my build platform, but these instructions can be adapted to anything really.

Automated Project Environment Setup

Web Project Dev Environment

A common problem projects have is when a new dev joins the team is they hopefully have to follow a bunch of instructions to set everything up. Most of the time, those instructions are out of date so another member of the team ends up setting everything up.

Depending on the complexity of the project, this can be quite time consuming.

The last project I was on was greenfields, so from day 1 we had a Setup Dev Environment.ps1 file in the root of the project. This powershell script did the following:

  • Installed IIS, and all the components we needed (windows auth, .net etc)
  • Registered asp.net with IIS
  • Created Websites with host headers for each of the sites in the project (we ended up having 3 different websites)
  • Opened the HOSTS file in notepad (elevated) and printed out the lines you needed to paste into your HOSTS file

Over time, this script gained more and more features. But when a new team member joined the team, they just ran this script which installed/configured everything.

Why IIS you may ask, instead of say IIS Express. Well this approach means each site had it’s own domain, so fiddler works out of the box. It also means that our UI Test suite doesn’t have to fire up IIS Express to run it’s tests.

VSTO Contrib v0.12 Released

I have just pushed the button on VSTO Contrib v0.12!

This release is aimed at fixing a bunch of bugs, like some callbacks not working, creating a viewmodel instance for when no documents are open and supporting Office 2013! Due to the complexities of supporting multiple versions, I have dropped Office 2007 support. Please let me know if this is a major issue, and I might try to add it back in next release.

I have also released a getting started video. This is one of the first screencasts I have done, so I will likely do it again next release. Also when you install VSTO Contrib, a readme will popup, this will help you get started.

I will try to produce some documentation/blog posts on VSTO Contrib over the next few weeks.

From now, I will be tracking changes/fixes a lot better. Please report any issues at https://github.com/JakeGinnivan/VSTOContrib/issues

TestStack.White v0.11 Released!

I have just pushed the button for TestStack.White v0.11.

The main focus between v0.10 and v0.11 is converting the old test suite into a new test suite which is easier to maintain and can reliably run on the build server.

The previous test suite was often red, which meant that it was hard to know if there were regressions as other issues were fixed.

You can see the CI status at http://teamcity.ginnivan.net/project.html?projectId=TestStack_White