dotnet command line goodness from senor hanselman

I love to keep up with all things Scott Hanselman, he’s really a golden god of the tech. I’ve been learning the new dotnet core stuff lately brushing up on my skills and came across his command line tutorial which is a great into into how you use the dotnet command line.

I’m going to shorten it up for my purposes as I’d like to reference back to it as I keep my studies up. Here’s the list of command and what they mean:

make a directory and move to the new folder

md testexample & cd testexample

create a solution file

dotnet new sln

create a class library, the -n is the name & the -o is the location

dotnet new classlib -n mylibrary -o mylibrary

create a xunit text project

dotnet new xunit -n mytests -o mytests

add the class library to the solution file

dotnet sln add mylibrary\mylibrary.csproj

add the xunit test project to the solution file

dotnet sln add mytests\mytests.csproj

add the xunit test project to the solution file

dotnet sln add mytests\mytests.csproj

move to the mytest project and add reference to class library

cd mytests
dotnet add reference ..\mylibrary\mylibrary.csproj

move up one level and restore the project which pulls down the packages it needs

cd ..
dotnet restore

move to the mytests folder and run the test. –> Scott says, Of course, I’m testing nothing yet but pretend there’s a test in the tests.cs and something it’s testing (that’s why I added a reference) in the library.cs, OK?

cd mytests & dotnet test

add a watcher to your tests so when you save code, your tests will run automagically. open up your /mytests.csproj file and add this xml snippet

 <DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />

go back up and restore again as you want to add the watcher dependencies and now you can test

cd ..
dotnet restore

add this code to your UnitTest1.cs file and hit save, you will see your tests run. one test should pass and one should fail

public void Test1()
	Assert.Equal(4, Add(2,2));

public void Test2()
	Assert.Equal(7, Add(4,2));

int Add(int x, int y) {
	return x + y;

Current blog publishing workflow

I’ve been working on some wordpress blogs lately and have a process that I follow to keep things as automated for “publishing” as possible.

The issue is that we can do things manually and keep it “pure” as they say but there’s a lot of tools that let you connect and push so lets make things better for sharing your thoughts with the world as quickly as possible when you hit the Publish button.

I currently have a blog setup and one way to help automate the “publishing” of your blog post is to use Jetpack. Using Jetpack, you can connect your blog to Facebook, Twitter, Google+ etc. so when a new post is released, it also shares it with those sites.

Another tool for you to us is which allows you to do that same thing as Jetpack but has a couple other social media platforms i.e. Pinterest & Instagram to connect to.

I’m on a schedule of one post a week right now and I use the mobile phone app for wordpress to post things on the fly but I always know that once a week I have something to share.

It’s the slow growth model and based on my reading, it’s going to take about a year of consistent posting before you even sniff a large user base but that shouldn’t really be your goal. Your goal IMHO should be to get the right people reading your blog and speaking to them in a way that you both can learn from a discussion you generated.

MY CURRENT PROCESS: I post using which uses the Jetpack plugin, that covers posting to my accounts on Facebook, Twitter, Google+, LinkedIn, Tumblr, Path & Eventbrite. I then go to and setup a post for Pinterest & Instagram.

featured image by “unsplash” which is the most amazing site for images, please share yours and we all win

SQL Query to create XML Elements

I recently had to create an XML file from a Microsoft SQL Server table. I was starting like normal to get my query results and then had to loop thru them in order to assign the data to the XML elements.

Since this table had 150+ fields, it was going to be quite literally a data entry nightmare I didn’t want to face so I figured that I would write a query to loop thru all of the database columns and then append the data needed to make my XML elements.

This query worked like a charm and took a couple minutes to create.

SELECT 'xWriter.WriteElementString(&quot;' + name + '&quot;, item.' + name + ');'
FROM sys.columns