dotnet host should provide clearer error messages when app content is missing
Steps to reproduce
dotnet new; dotnet build; cp bin/Debug/netcoreapp1.0/hello.dll . dotnet hello.dll
Expected behavior
Error message stating that runtimeconfig.json is missing, or something describing the artifact that is preventing the app from launching.
Actual behavior
library 'libhostpolicy.dylib' required to execute the application was not found
Granted, running an app that wasn't published is not a designed-for scenario. However, since we're printing an error message that points to some symptom, it would be great to specify a more actionable symptom.
This issue is a digest of https://github.com/dotnet/cli/issues/4268 from @kumpera.
@ramarag PTAL.
CC @schellap
If runtimeconfig is missing, we default to running a standalone app with dotnet. The next step is to find hostpolicy.dll which is missing.
We could probably detect that this is a standalone invocation using dotnet.exe and print a slightly different message.
But I don't think we should go through the pains of detecting such an invocation just for flagging. We should just modify the error message to say: "Additionally, check if you are doing bad thing."
Also, the error message is actually accurate, but it can be more helpful. The artifact that is missing is hostpolicy. Missing runtimeconfig is still a valid app and is also an implementation detail that users should not need to know about.
I found this issue today as well, is there any solution? Why do we need the runtime json file?
Runtimeconfig.json is required to when building apps that run against Shared FX (i.e. Microsoft.NETCore.App FX). If it is missing, then we expect the app to be standalone and go down that path for activation and any missing components will be raised (as in the message above).
To attempt to run the app, as in the example above, is a user-error since that is not a supported publish/activation model.
@gkhanna79 what is the error message that we should be giving ?
@ramarag Why don't you suggest an appropriate solution for this :) ?
Can there not be an option in build settings and in back-end to check for it as an embedded resource since it is a required file?
This file is not an embedded resource but a metadata option.
When building either through just a debug build or a published build json file is required for the dll to run, should there not be a way to embed a required file into the app itself? It seems a bit silly to require a json file outside of the app for it to even work.
The metadata will be inserted in
Think you've misunderstood what I've meant i have moved it over to here dotnet/core-setup#1964 since its kind of off topic sorry .
I downloaded an older version of the .NET Core SDK on Mac, because I need to support project.json, but I'm getting this error:
A fatal error was encountered. The library 'libhostpolicy.dylib' required to execute the application was not found in <path>
How can I work around this?
Closing this as dup of https://github.com/dotnet/core-setup/pull/3382
That added the following to the existing error message:
Failed to run as a standalone app because there is no '<dir>\<app>.runtimeconfig.json' file. If this should be a portable app instead, add that file specifying the appropriate framework.