About Josh

I signed up for a BASIC class in junior high. That got me hooked and pretty soon I started experimenting with harder languages. My college years are a blur of benders hopped up on Perl and Java and that one semester where I sunk so low that I was mainlining Smalltalk. Now I'm a complete C# junky living it one day at a time. Hello, my name is Josh.

And Now ChocolateyCoolWhip

Following up on CoolWhip, ChocolateyCoolWhip is a nuget package that makes creating, packaging, and deploying your code through Chocolatey.org simple.  Like CoolWhip, all you need to do to publish a new release is create release in GitHub.



In case you aren’t familiar, Chocolatey is a package manager for Windows built on top of NuGet and PowerShell. It allows users to download and install thousands of software programs with a single command.  For example, to install nodejs, all you would need to do is open up a command prompt and enter

> choco install nodejs.install

Getting Started with ChocolateyCoolWhip

To get started, install the nuget package into your project.  The first thing you’ll notice is that it creates nuspec and AppVeyor configuration files.  Chocolatey uses the nuspec as metadata for your package, the same way NuGet does.

Once setup, all you need to do to update your package on Chocolatey.org is create a release in GitHub.  ChocolateyCoolWhip will pull the version information directly from the release name and kick off a build in AppVeryor.  You have complete control over versioning your application

Configuration is simple:

  1. Connect AppVeyor to your GitHub repo
  2. Install the NuGet package >Install-Package ChocolateyCoolWhip
  3. Update the generated nuspec file with your project’s information
  4. Add your authorization tokens to the AppVeyor.yml file
  5. Save/commit your changes

Once this is set up, all you’ll need to do in order to release (or update) your package on NuGet is create a GitHub release with the version number.

There is full step by step documentation in the wiki.

Happy Coding.

Introducing CoolWhip

CoolWhip is a NuGet package aimed at making and deploying other NuGet packages easier. With CoolWhip, creating a Release in GitHub automatically pushes that release to NuGet.


Once you’ve installed CoolWhip into your project it will create a nuspec file and AppVeyor configuration file.  These will work together to package your project and automatically upload it to NuGet.org.

Once setup, all you need to do to update your package on NuGet.org is create a release in GitHub.  CoolWhip will pull the version information directly from the release name and kick off a build in AppVeryor.  You have complete control over versioning your application.

To configure CoolWhip you need to

  1. Connect AppVeyor to your GitHub repo
  2. Install the NuGet package >Install-Package CoolWhip
  3. Update the generated nuspec file with your project’s information
  4. Add your authorization tokens to the AppVeyor.yml file
  5. Save/commit your changes

Once this is set up, all you’ll need to do in order to release (or update) your package on NuGet is create a GitHub release with the version number.

There is full step by step documentation in the wiki.

Happy Coding.


Source on GitHub

Package on NuGet

Treat Warnings as Errors In TeamCity

I’m OCD when it comes to my code.  I don’t like to have any warnings.  I wanted to configure my TeamCity builds to fail if there were any warnings in the projects. My first option is to tick the “Treat warnings as errors” box in the project settings.  This had a few problems

Problem 1.

I’d have to remember to do it for every project in my repo, including all the projects I make in the future.  Even worse, everyone on my team would have to remember to do that too.  That’s not something I could rely on.

Problem 2. 

While warnings are just errors that you’re ignoring, I will admit that it is convenient to be able to ignore some things some times.  I’m fine with debugging and running locally with some errors.  I really only wanted to stop people from committing code back to master with warnings.  I couldn’t care less about bad hygiene the have when working locally.

The Solution

In searching, I found David Gardiner’s blog post in which he creates a power shell script to edit the xml in each csproj file.  It looks simple enough so I removed the TFS bit and added it as a build step in my TeamCity flow. It runs right before compiling my code.


Get-ChildItem -Recurse -Filter "*.*csproj" | % {
    Write-Host $_.Name
    $filename = $_.Fullname
    $proj =
( Get-Content $_.Fullname ) $xmlNameSpace = new-object System.Xml.XmlNamespaceManager($proj.NameTable) $xmlNameSpace.AddNamespace("p", "http://schemas.microsoft.com/developer/msbuild/2003") $nodes = $proj.SelectNodes("/p:Project/p:PropertyGroup[@Condition and not (p:TreatWarningsAsErrors)]", $xmlNameSpace) $touched = $false $nodes | ForEach-Object -Process { $e = $proj.CreateElement("TreatWarningsAsErrors", "http://schemas.microsoft.com/developer/msbuild/2003") $e.set_InnerText("true") $_.AppendChild($e) | Out-Null $touched = $true } if ($touched) { Write-Host "Checkout $filename" $proj.Save("$($filename)") | Out-Null } }

ILRepack – E Pluribus Unum: One assembly from many

Sometimes it is just much easier to deploy a single assembly that includes all dependencies.  ILRepack and ILRepack.MSBuild.Task will do just that for you.  Since I like to have Visual Studio and my build environment do this for me, I went with ILRepack.MSBuild.Task.

The Sample

In order to showcase packing an assembly into my program, first I need a program that has a dependency.  I decided to go with a simple console app that has a dependency on the Humanizer NuGet package to tell you how long you have to wait until your birthday. 

Usage:   repack [date]
  Prints how long it is until your birthday.
  If you don't supply your birthday, it uses mine.

23 weeks until your birthday

I created a new console project in Visual Studio and named it Repack.  I then included the Humanizer DLL using the NuGet package manager. 

You can find the source code on github.

Using ILRepack

All you need to do is add the following snippet at the end of your .csproj file.  To do this, you can open up the .csproj file in notepad or your favorite text editor.

<Target Name="AfterBuild" Condition="'$(Configuration)' == 'Release'">

  <InputAssemblies Include="$(OutputPath)\$(AssemblyName).exe" />
  <InputAssemblies Include="$(OutputPath)\*.dll" />


Because we name the target “AfterBuild”, this code will automatically be run after msbuild or Visual Studio builds our project.  Setting the condition ensures that this will only run when we are in release mode.  You can definitely run this on debug builds, but it’s less likely that you’d want to.

The ItemGroup specifies lets us create a list of assemblies to include in the package.  The first assembly should be your assembly.  In my example it will be my executable file “Repack.exe”.  Next, I include all the DLLs in the output directory.  This way, if I add a new dependency later, it will be included automatically.

Note that the order does matter.  You will want to put the .exe first in this list.

Next all we need to do is call ILRepack.  You can specify the output file to be anywhere you like, but in this example I overwrite the existing Repack.exe with the packed version.

Once you rebuild your project (in release mode), you can copy the EXE anywhere you want and it will run. 


ILRepack.MSBuild.Task let’s you package DLL’s into your EXE file so you can copy just the executable anywhere and not have to worry about deploying the dependencies as well.

Full sample code can be found on github.

Happy coding.

Convert Azure Publish Profiles to FileZilla config files

Occasionally I need to FTP into one of my Azure websites.  Sometimes it’s to look at the logs; other times to upload a few files.  Just about every time I go to do this, I realize that I don’t know the credentials.  So I go and download the publish profile and open it up in my favorite text editor to get the FTP information and manually enter that in FileZilla.

I quickly became tired of doing this, so I wrote a console app that will do it for me.  The source code and executable are available on my GitHub.


  1. Download your publish profile
  2. Run the command line tool
  3. Import the config file to FileZilla

Download your publish profile

Log on to the Azure management portal for the website you want to FTP into.  On the right side of the dashboard page you will see an option to “Download the publish profile.”  Click it and you’re on your way.


When downloaded the file will look something like this:

<?xml version="1.0" encoding="utf-8" ?>
    profileName="TestSite - Web Deploy"
    userPWD="test password"
    profileName="TestSite - FTP"
    userPWD="test password"

Obviously, all the pertinent connection information has been scrubbed clean.  But you get the idea.

Run the command line tool

Next thing you need to do is run pubToFz.exe to convert the publish profile into a format that FileZilla understands.  Assuming the default download location, the command would look like this:

pubToFz %home%\downloads\testSite.publishProfile

By default, the tool creates an file named FileZilla.xml in the current directory.  The file will look something like this.

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
      <Pass encoding="base64">base 64 encoded test password</Pass>
      <Comments />
      <LocalDir />
      <RemoteDir />

Again, this was scrubbed clean.

Import the config file to FileZilla

Now all you have to do is open up FileZilla and import the config file that you just saved.


F8 in CMD: The Greatest Thing Since Sliced Bread

I recently stumbled across DOSKEY while reading StackOverflow.  Reading the documentation I stumbled across something old and something new.


F7    Displays command history
F8    Searches command history

I knew about F7 and use it constantly when I’m on the command line.  It pops up a scrollable list of your recent commands.


F8 lets you cycle through commands in your history with a search term.

Suppose you had previously typed a complex command.  In the example I have below, I used the command “echo Foxtrot Golf”.  To find and execute it again all you need to do is type the beginning of the command and then press the F8 key.  In the example, I type “echo” on the command prompt and cycle through all the commands that start with that by pressing F8.  To narrow it down a bit more, I type in “echo F” and then press F8 to get all the commands that start with that.  Note that it is case sensitive.


Debugging a Visual Studio Crash

After a recent reboot, Visual Studio just stopped working.  Whenever I clicked on the icon on my desktop, I’d see this:


When the obvious solution (restarting my computer) I had to dig a little deeper.

Step 1:  Logs

The first step is to get some more information.  You can tell Visual Studio to log at startup by passing it the /log parameter on the command line.  Now, I’m fairly comfortable with the command line, but I rarely ever use it to start up Visual Studio.

An easier way is to just use the Diagnostic Mode option in the jump list.  Right click on the Visual Studio icon in your taskbar and select Diagnostic Mode.


Now all I had to do was wait for Visual Studio to crash again.  To get to the logs right click on the Visual Studio icon again select Open Activity Log Location.  With my setup, this opened C:\Users\Josh\AppData\Roaming\Microsoft\VisualStudio\12.0.  The log file is ActivityLog.xml.

In the log just search for a line like


Hopefully, there aren’t too many of them.  In my case it pointed to a missing DLL

    <time>2015/01/26 21:26:02.821</time>
    <description>Could not load file or assembly &apos;GettingStartedSetup.dll&apos; or one of its dependencies. The system cannot find the file specified.</description>

I went to the folder specified and verified that the DLL was missing.  Next thing to do is open up the extension.vsixmanifest to determine which extension it was.  Looking at the DisplayName node, it was fairly clear that it was Release Management tools for Visual Studio 2013.

<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011">
    <Identity Id="9b4bef8e-2ac3-4fa8-b8c7-d93d73d3618b" Version="2.2" Language="en-US" Publisher="Microsoft" />
    <DisplayName xml:space="preserve">Release Management tools for Visual Studio 2013</DisplayName>
    <Description xml:space="preserve">Release Management tools for Visual Studio helps to quickly get started with creating a Release Definition to automate the deployment of your application to multiple stages. You start with a working Build definition and then using this tool, set up a release pipeline that enables triggering of a Release for each build that is available for the build definition.</Description>

Step 2:  Safe Mode

Now that I know which extension was misbehaving, all I needed to do was uninstall it.

Open up Visual Studio in safe mode.  This can be done with a command line switch or through the jump menu again.


Visual Studio should open w/out a problem.  From here, it’s easy sailing.  Open up the Extensions and Updates tool, find the problematic extension in the Installed list, and press the uninstall button.


Now I was able to restart Visual Studio and it worked just fine.  I could have re-installed the extension, but I didn’t really need it so I just left it uninstalled.

Genymotion Android Emulator

I like to use an emulator to debug my android apps.  My emulator of choice is the Genymotion emulator.  It’s much easier to install and use than the one in the android-sdk.

One drawback I have seen with it it, is that sometimes it just refuses to start.  Getting it to start back up isn’t hard, but it isn’t all that unintuitive.

Try Try Again

The first thing to try is to just restart the emulator a few more times.  It might just work the third or fourth time.  You don’t have to restart the entire Genymotion console, just hit the start button and wait for the emulator to succeed or fail.  Try this a few times and you might just get lucky.

Delete Network Settings

If you’ve tried a few times and still don’t have any success you can force Genymotion to reconfigure its network settings.


  1. Open up Oracle VM Virtual Box manager
  2. Go to Preferences
  3. Go to the Network tab
  4. Delete the VirtualBox Host-Only Ethernet Adapter
  5. Start up the emulator as normal


Open up the Oracle VM Virtual Box manager.  I do this by typing any part of the name that I happen to remember at the time into my start menu.


VirtualBox is what powers the emulator, so you will see all of your android images listed.  Go to File –> Preferences


Then click on Network on the right.


You should see “VirtualBox Host-Only Ethernet Adapter” in the “Host-only Networks”.  Select it and click the delete button on the right (it’s the button in the middle)


Now, go back to Genymotion and try to start the emulator again. It will notice that the virtual network adapter is missing and recreate it. You may see a UAC prompt asking if VirtualBox should be allowed to make changes to your computer.  Click yes.

Your emulator should now startup.

Creating Drawables for Android

One of the pains for Android development for me is creating drawables in different sizes for various devices. In the past I’d only have a few images at a time to resize so I’d normally just upload them to Android Asset Studio and have the site generate the correct sizes for me.

There are two problems with this approach.  First, I have to upload the files one at a time.  If I have more than 4 files then it becomes a bit of a chore.  Second, I can’t specify what size I want the output.  It always  generates files that are

mdpi 32×32 pixels
hdpi 48×48 pixels
xhdpi 64×64 pixels
xxhdpi 96×96 pixels

Instead of manually editing the images I had (I had a lot) I decided to finally just write an app to handle this for me.  You can find it on GitHub at AndroidIconsResizer.  Right now it is a little barebones but it quickly and easily handles batches of images.

All options are optional so the simples use is to just run it.  If nothing is specified it assumes the current directory for all input or output.  By default the output images are all squares and are 100×100 at the mdpi size.

> AndroidIconResizer

It looks for all the .png files in current directory, resizes them and copies them to the appropriate output directories.  If you ran the above command in the following directory


then the directory would look like this after

        file.png (100 x 100 pixels)
        anotherFile.png (100 x 100 pixels)
        file.png (150 x 150 pixels)
        anotherFile.png (150 x 150 pixels)
        file.png (200 x 200 pixels)
        anotherFile.png (200 x 200 pixels)
        file.png (300 x 300 pixels)
        anotherFile.png (300 x 300 pixels)

It is possible to specify different sizes (heights and widths) for the output images.  All you need to specify is the size you want the mdpi image.  The other sizes are extrapolated based on Google’s iconography recommendations.

> AndroidIconResizer –w 20 –h 50

You can specify the input and output directories just as easily

> AndroidIconResizer –i inputDir –o outputDir

By default the xxxhdpi image isn’t generated since it’s only needed for launcher icons.  You can choose to include it with an option

> AndroidIconResizer –-include-xxxhdpi

Or you can just ask the tool itself for some help:

> AndroidIconResizer –help

Those were all the features I needed today, but I’ll probably be expanding on this app in the future.  Let me know if you’d want any other features.

Happy Coding.

Xamarin.Droid and MvvmCross: Setting Fonts in XML

In Android, your options are kind of small for setting a font purely in XML.


In this post, I’ll create a converter so we can specify the font in an MvvmCross binding.

Getting a font

Before going any further, you need to actually get and include a font in your android app.  For this example I will be using Fontin.  The main reason I’m using it is because it was easy to find and is free. Download the TTF versions and and include them in your project.  Add a new subdirectory to the Assets folder in your android project named “font”.  Drop the files into that folder and include them in your project.  Make sure that the build action is set to AndroidAsset.

image        image

If you get the following error, make sure that the font names are spelled exactly the same as the folder and file names, including capitalization.

java.lang.RuntimeException: native typeface cannot be made

In the example from my screenshots, my font name should be:  font/Fontin-Italic.ttf 

And again, capitalization matters.

Binding to Typeface

The first step is to use MvvmCross.  Next all you really need to do is bind directly to the Typeface property on the TextView.  They Typeface property is an instance of of Typeface (nothing surprising there) which meanst that you’ll need a converter.

        local:MvxBind="Text Hello; Typeface StringToFont(FontName)" />

The converter is pretty straight forward:

public class StringToFontConverter : MvxValueConverter<string, Typeface>
    private static Dictionary<string, Typeface> _cache = new Dictionary<string, Typeface>();

    protected override Typeface Convert(string fontName, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            if (!fontName.StartsWith(@"font/")) fontName = @"font/" + fontName;
            if (!fontName.EndsWith(".ttf")) fontName += ".ttf";

            if (!_cache.ContainsKey(fontName))
                _cache[fontName] = Typeface.CreateFromAsset(Application.Context.Assets, fontName);

            return _cache[fontName];
        catch (Exception e)
            Android.Util.Log.Error("AndroidFont", e.ToString());

            return Typeface.Default;

First thing the converter does is to clean the input, ensuring that the font name starts with the directory and ends with the ttf extension. This makes the binding a bit easier in that we don’t have to remember to get the full font path correct.

It then check its static cache to see if it already has an instance of the the font, if not it creates one by calling Typeface.CreateFromAsset.  If creation fails it does some logging and return the default typeface.  This is important because in my testing VisualStudio hang pretty hard under some circumstances where errors were ignored.

Fire this up, and you’ll see that the font is in fact set.

One problem with this example is that we are forcing the ViewModel to know the correct name for the font.  In some cases that’s ok, in others, we won’t want to handle font in the VM layer.  Luckily we can use Tibet binding and just bind to a static string in the xml.  Just remember to surround it with single quotes.

    local:MvxBind="Text Hello; 
                   Typeface StringToFont('Fontin-Bold')" />


Here’s a sample layout putting everything together.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        local:MvxBind="Text Hello; Typeface StringToFont('Fontin-Bold')" />

<!-- Binding to the View Model -->
        android:text="Bind to Typeface:  " />
        local:MvxBind="Text Hello; Typeface StringToFont(SelectedFont)" />
        local:MvxBind="SelectedItem SelectedFont; ItemsSource FontNames;" />

<!-- Binding to a constant -->
        android:text="Constant Typeface:  " />
        local:MvxBind="Text Hello; Typeface StringToFont('Fontin-Bold')" />

<!-- Error -->
        android:text="Error Handling:  " />
        local:MvxBind="Text Hello; Typeface StringToFont('Not a font name')" />

The edit box and first text box are bound to the value in the spinner.  The second text box is staticly bound to the bold font.  The last text box is bound to a value that is not a valid font and defaults to the default Android font.


Here’s a link to the working project on git.

Happy Coding