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: