DNX: working Console Application

Summary: I have at least proven that I can run a Console App from the command line, using dnu, dnx, dnvm, yada.This is the output from an hour’s effort, that it is, a console app called using dnx.exe:

VSDNX17

The snippets below record my steps a) to see if by building a console app in VS2015 using a template I could infer exactly how it is done manually, b) failing to understand why it could not resolve the System.* dependencies, c) ignoring guidance in MSDN blogs about Nuget package manager in VS sorting it out, and instead letting dnvm restore do its job, d) F5 and ctrl-F5 to get a clue about how it is executed (i.e. the path to the required dnx.exe), e) executing dnx.exe from the command line, passing in the location of the project.json file, which holds all the necessary info about how and what to execute, f) an implicit confirmation that console applications are no longer about building and running an .exe. (And I get that aspVNext/Roslyn etc is not per se about console apps – I was just looking for a way to do the simplest thing, with the smallest number of dependencies. This at least does now open up the door to knowing (I think!) how I can execute this on a low power Windows machine (or Linux – I have no access to OSX) without Visual Studio present. I could of course just have grabbed an old style csc.exe… but this is about doing Roslyn and related, not revisiting old ground. So the noisy snippets:

VSDNX01

VSDNX02

VSDNX03

VSDNX04

VSDNX05

VSDNX07

VSDNX08

VSDNX09

VSDNX10

VSDNX11 VSDNX12

VSDNX13

VSDNX14

VSDNX15

VSDNX16

VSDNX17

Snippets: C# console app

If I want to play with some ideas in C# that don’t involve a GUI but where you want some console output, then that’s obviously a use-case for the Console Application template in Visual Studio… but it’s not quite as I like. THIS is as I like:

ConsoleApp01

Pastebin

That then gives me a clear place in the RunTheTest method to new up stuff, and a ready-made prompt so the console doesn’t just run away after execution.

While I’m on it, this will save me a few keystrokes * 1000, as it’s easier to remove stuff doing this crude form of debugging than it is to add it. I always like to surround arguments in those square brackets for easy visual delimitation, better too many than too few:

ConsoleSnip01

Of course I should anyway go back to my Resharper Template notes here, and the related YouTube video here.