This repo has runtime packages for various environments etc. This is bit deeper than the public facing download link at dot.net, which includes both SDK and runtimes...
Each runtime package is made up of 3 primary parts:
- host: Which is a generic host for entrypoint .dll as a well as a template for custom hosts (e.g. calcultor.exe)
- shared framework: .net core implementation of .net standard 2.0 - this also includes native bindings (crypto, http etc.) for the respective platform
- hostfxr - this does some magic to inject some fixes in generic host (dotnet.exe) to make it a custom host. More details here
-
Install .NET 2.0 SDK on Ubuntu 16
sudo apt-get install dotnet-sdk-2.0.0
-
Create a console app
dotnet new console -o pr1
-
copy the pr1.dll (containing managed code) to MAC
-
Install the latest .net CORE runtime from the
tar.gzip
file -
running the
./dotnet
executeable against the dll produces:~/t/aaa ❯❯❯ ./dotnet pr1.dll ⏎ A fatal error was encountered. The library 'libhostpolicy.dylib' required to execute the application was not found in '/Users/zamd/tmp2/aaa/'.```
-
Enabling core-clr tracing
export COREHOST_TRACE=1
to enable Core CLR probe tracing
- core tracing revealed that runtimeconfig.json is missing - this file is produced by the
dotnet build
but I didn't copy it over to MAC.
~/t/aaa ❯❯❯ ./dotnet pr1.dll
Tracing enabled
--- Invoked dotnet [version: 2.1.0-preview1-25727-05, commit hash: c57456fb2d0251dbdd1e48140f4258467a4abfd9] main = {
./dotnet
pr1.dll
}
Reading fx resolver directory=[/Users/zamd/tmp2/aaa/host/fxr]
Considering fxr version=[2.1.0-preview1-25727-05]...
Detected latest fxr version=[/Users/zamd/tmp2/aaa/host/fxr/2.1.0-preview1-25727-05]...
Resolved fxr [/Users/zamd/tmp2/aaa/host/fxr/2.1.0-preview1-25727-05/libhostfxr.dylib]...
Tracing enabled
--- Invoked hostfxr [commit hash: c57456fb2d0251dbdd1e48140f4258467a4abfd9] main
Own dll path '/Users/zamd/tmp2/aaa/dotnet.dll'
Checking if CoreCLR path exists=[/Users/zamd/tmp2/aaa/libcoreclr.dylib]
--- Executing in muxer mode...
Detected a non-standalone application, expecting app.dll to execute.
Treating application '/Users/zamd/tmp2/aaa/pr1.dll' as a managed executable.
App runtimeconfig.json from [/Users/zamd/tmp2/aaa/pr1.dll]
Runtime config is cfg=/Users/zamd/tmp2/aaa/pr1.runtimeconfig.json dev=/Users/zamd/tmp2/aaa/pr1.runtimeconfig.dev.json
Attempting to read runtime config: /Users/zamd/tmp2/aaa/pr1.runtimeconfig.json
Attempting to read dev runtime config: /Users/zamd/tmp2/aaa/pr1.runtimeconfig.dev.json
Runtime config [/Users/zamd/tmp2/aaa/pr1.runtimeconfig.json] is valid=[1]
Executing as a standalone app as per config file [/Users/zamd/tmp2/aaa/pr1.runtimeconfig.json]
--- Resolving libhostpolicy.dylib version from deps json [/Users/zamd/tmp2/aaa/pr1.deps.json]
Dependency manifest [/Users/zamd/tmp2/aaa/pr1.deps.json] does not exist
The expected libhostpolicy.dylib directory is [/Users/zamd/tmp2/aaa/]
The libhostpolicy.dylib was not found in [/Users/zamd/tmp2/aaa/]
A fatal error was encountered. The library 'libhostpolicy.dylib' required to execute the application was not found in '/Users/zamd/tmp2/aaa/'.
- mannually created
pr1.runtimeconfig.json
to match Mac version of the runtime
{
"runtimeOptions": {
"tfm": "netcoreapp2.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "2.1.0-preview1-25727-05"
}
}
}
- with runtimeconfig file in place:
~/t/aaa ❯❯❯ unset COREHOST_TRACE
~/t/aaa ❯❯❯ ./dotnet pr1.dll
Hello World!
~/t/aaa ❯❯❯