DNX: 1 Caller, and 1 Callee


What and Why? The DNX examples I’ve done before have been standalone 1-line console apps. This is still a trivial-doesn’t-cover-it app, but it does introduce the hurdle of one class I wrote invoking another class I wrote, as opposed to NuGet-type dependencies. While there is some mention of global.json when googling how to do this principle, I see no need for that here. Indeed I failed to get an implementation working using global.json.

A total of 4 files was needed – two project.json files, each being the equivalent of a (full) Visual Studio project, and a .cs files in each of those projects.

I kept chopping out content from the project.json files, until they were the absolute minimum required.

Note this structure – at this point dnu has not been run, so there is no lock file. This is the Caller:



This is the structure for the Callee:


That is the entire codebase – note that there is no global.json or any other config, metadata file.

The content of the 4 files, viewed from VSCode. See how the code parser is not happy we have not yet run dnu:


We’ll click one Restore:


… and then the other:


, and all the squiggles are gone. Tick.

The code for each of the 4 files we wrote:


Note below that the Caller project.json declares a dependency on Callee. If the content of that yellow box is removed, then the execution breaks, because it can’t find Callee.




(oop – bit of inconsistency in naming…)



Finally the dnu command,


and the dnx command to execute the 2 WriteLines – 1 from the Caller, 1 from the Callee:




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