DotNet Core: Libraries, XUnit, VS Code. Part 1

On this page, there is a tutorial, involving full-fat VS, and at the bottom there are a number of comments around difficulties building the solution.

dotnetcorelib11

dotnetcorelib12

I saw a challenge in trying to prove it is actually easier to build using the DotNet CLI and VS Code, rather than FF VS. One reason might be that you are closer to the bare metal of DotNet Core: if you are running in FFVS, it might be hard to deduce if the build error is due to DotNet Core problems, or problems with Visual Studio’s integration with DotNet Core.

My previous articles on DotNet Core have only been around simple command line stuff, namely, using the default [dotnet new] command.

To start off, let’s get our CLI environment right. The next few lines (being PowerShell) set the date time as the prompt, recursively remove any existing files from the current root down, and custom-set colours (but then dotnet CLI comes along and ignores that, as we see in a moment):

function prompt(){"$(Get-Date)> "}
Remove-Item -Recurse *
$color = (Get-Host).PrivateData
$color.ErrorForegroundColor = "White"

Whereas before, I used [dotnet new], this time we’ll use a nonsense line to show some options:

The contrast in the red error message is poor. It says (note the typo):

Unrecognized type: nonsense
Avaiable types for C# :
- Console
- Web
- Lib
- xunittest

That tells us what is available. The msdn tutorial is for a library and a test, so let’s start with the lib option [dotnet new -t Lib], and then see the files that creates:

So nothing built yet. Now we’ll try [dotnet run]:

Perhaps now we can do a run? No, it’s a library, you don’t Run a library:

So we can distribute a library. OK…

At this point, we have a library file that contains and does precisely nothing:

DotNetCoreLib10.PNG

That’s enough for a first post on this, as I have stuff to do. I’ll probably complete it over a number of days. More anon.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s