The full name of DNX is the. NET execution enviroment (. NET execution Environment), which is an important role for. NET cross-platform. If you're concerned. Net of cross-platform, must pay attention to DNX.
Due to a bug in Mono 4.0 (now fixed), if you want to compile DNX on your Mac, you need to check out Mono's source code to compile it, see Bug 29499-system.io.endofstreamexception when running DNX command.
The method of compiling mono in Mac OS X can refer to compiling mono on Mac OS X. The following commands are used:
Brew Install autoconf automake libtool pkg-configgit clone https://github.com/mono/mono.gitCD mono. /autogen.sh--prefix=/usr/local--disable-nlsmakemake Install
After you compile mono (compilation is a lengthy process), you need to modify the Packages/korebuild/build/_kpm-build.shade file in Dnx (if you do not have this file, you need to run it first./build.sh)
exec program= ' cmd ' commandline= '/C kpm pack${pack_options} ${projectfolder}--configuration ${configuration} ' if= '! Ismono ' exec program= ' kpm ' commandline= ' pack${pack_options} ${projectfolder}--configuration ${configuration} ' if= ' Ismono '
Change one of the KPM to DNU (otherwise the compile will be reported "Can't find KPM" error, is the name of the disaster):
dnu build${build_options} ${projectfolder}--configuration ${configuration} ' if= '! Ismono ' exec program= 'dnu' commandline= ' build${build_options} ${projectfolder}--configuration ${ Configuration} ' if= ' Ismono '
Then run the./build.sh command to compile the DNX successfully.
The compiled stuff is in the Artifacts/build folder. There are 2 important folders: Dnx-mono and Dnx-coreclr-darwin-x64, the former is based on the mono Dnx, the latter is based on the CoreCLR DNX, DNVM installed through DNX is this. They contain the execution of one. NET programs, they are the. NET execution enviroment (. NET execution Environment).
Do not believe that we can use a very simple. NET program test a bit.
This one. NET test program called HELLODNX, only 2 files:
1) Program.cs
using System; Public class program{ publicstaticvoid Main () { Console.WriteLine ( "Hello from dnx! " ); }}
2) Project.json
{ "dependencies": { }, "Frameworks": { "dnx451":{}, " Dnxcore50 ": {} }}
We run this hellodnx with our own compiled dnx to try.
First remove the DNX that you previously installed through DNVM.
CD ~/.DNX/RUNTIMESRM-RF *
Then restore the NuGet package with the DNU command in our own compiled DNX:
/git/dotnet/dnx/artifacts/build/dnx-mono/bin/dnu Restore
Microsoft. NET Development Utility v1.0.0-t150525235008restoring Packages for/git/dotnet/hellodnx/ Project.jsonwriting lock File/git/dotnet/hellodnx/project.lock.jsonrestore Complete, 159ms elapsed
Then run the HELLODNX program with our own compiled DNX.
Use mono-based DNX first:
/git/dotnet/dnx/artifacts/build/dnx-mono/bin/dnx. Run
Operation Result:
Hello from dnx!
Run successfully!
Then use the CoreCLR-based DNX:
/git/dotnet/dnx/artifacts/build/dnx-coreclr-darwin-x64/bin/dnx. Run
Operation Result:
Resource string ID=0X17FC System.DllNotFoundException:Resource string id=0x170b at Interop.mincore.GetStdHandle ( Int32 nstdhandle) at system.console.<>c__displayclass0.<get_error>b__5 () at System.console.ensureinitialized[t] (t& field, Func ' 1 initializer) at Dnx.host.RuntimeBootstrapper.PrintErrors (Exception ex) at Dnx.host.RuntimeBootstrapper.Execute (string[] args) at Domainmanager.execute (Int32 argc, char** argv)
Failed to run. It may be that an assembly is missing or the assembly version is not correct and is not being studied. The CoreCLR-based DNX is still in development, and the problem is normal.
On the Mac so toss a bit, one can actually experience a bit. NET cross-platform progress, the second is can toss dnx at any time, change DNX code, compiled out can use it to run. NET program.
Run a. NET program on your Mac with your own compiled DNX