Monthly Archives: February 2016

I needed to write a console application a while back and was investigating the best way to do this using the available NuGet packages. I’d seen the DNVM command line tool that Microsoft built for ASP.NET Core and really liked it and wanted something similar.

I really like the old school ASCII art title and the use of colour. The .NET Framework does contain an enum called ConsoleColor which contains a very limited set of hard coded colours you can use but it has some major ommissions like the colour orange for example.

In my hunt for a C# ASCII art generator, I discovered patorjk.com which is great for generating text using various Figlet fonts. Figlet fonts are basically .flf text files which contain instructions on how each letter in the ASCII character table can be printed out. It turns out these font’s are pretty ancient and there are libraries in every language writing out text using Figlet fonts.

Colorful.Console

I was just about to give up and write my own open source library when I discovered Colorful.Console, available on GitHub. Using this library you can very easily write console apps which look like this:

Or this:

The only thing missing was a method to write ASCII text using Figlet fonts, so I contributed some code to the project to get this done. The output, combined with the fade that Colorful.Console is capable of created a pretty cool effect. Unbelievably this is a couple of lines of code to write!

The title image of this post is also generated using Colorful.Console but was a bit more complicated as it transitions through several colours. By default Colorful.Console includes a single Figlet font but there are dozens of others available which you can download and use yourself. They aren’t all included by default because they would bloat the library quite a bit.

Command Line Parsers

Now the only thing missing in my quest was a command line parser which could let me easily create commands, switches and flags so users could use my command line tool. The best tool I found was Command Line Parser available on GitHub. It’s a pretty powerful and fully features library that makes writing a command line interface very easy. Unfortunately, its output is pretty ugly and it does not let you customize the ‘look and feel’ of what is output to the console.

At some point, I’d like to make another contribution to Colorful.Console, so that it offers command line parsing too but take inspiration from several command line parsing libraries to make something thats fully customizable and of course very colorful.

Command line tools have been around for decades, it’s a wonder that a NuGet package that does all of these things does not exist yet.

Making your own certificate files is quite hard work. You have to use makecert.exe and pvk2pfx.exe, passing in some pretty cryptic arguments which you always have to go back and research.

Learning how to make a certificate and the different types of certificate is pretty important. I highly recommend reading this blog post from Jayway.com which has some very detailed instructions and is the basis of MakeCertificate.

To make things easier I made a PowerShell script called MakeCertificate.ps1 which you can get on the MakeCertificate GitHub page. It asks you to pick the type of certificate you want to create, there are a few different types of certificates that MakeCertificate helps to make: Certificate Authority (CA) Certificates, SSL/TLS Server Certificates and Client Certificates. You are then asked a series of questions which when answered outputs three files

.cer – A public key file that can be shared.

.pvk – A private key file that should be kept secret.

.pfx – A combined public and private key file that should be kept secret.

It also outputs the command you need to execute using makecert.exe and pvk2pfx.exe to recreate the certificate.