dotnet run for a NETStandard.Library project gives obscure error: Could not load host policy
Steps to reproduce
dotnet new vi project.json { "version": "1.0.0-*", "dependencies": { "NETStandard.Library": "1.5.0-rc2-23931" }, "frameworks": { "netstandard1.5": {} } } dotnet restore dotnet build dotnet run
Expected behavior
An error message pointing the developer to "compilationOptions" with an "emitEntryPoint". Or an error saying that NETStandard.Library are not runable.
Actual behavior
Could not load host policy library from [/Users/xyz/Documents/Projects/matrix/d.lib_f.standard/bin/Debug/netstandard1.5]
Environment data
dotnet --info output:
.NET Command Line Tools (1.0.0-rc2-002349)
Product Information: Version: 1.0.0-rc2-002349 Commit Sha: ed9309b90b
Runtime Environment: OS Name: Mac OS X OS Version: 10.11 OS Platform: Darwin RID: osx.10.11-x64
You need to add:
"runtimes" : { "osx.10.11-x64": { } }
Many runtimes can be added as win7-x64,ubuntu.14.04-x64 etc
I tried that, it made no difference. The issue is that libraries do not have entry points - I would not expect this to work, but having a good error message is important.
take a look at the cli-samples https://github.com/aspnet/cli-samples also I'm using netcoreap1.0 as framework,
That misses the point - I am not looking to make this work rather ensure the experience in this state is good.
I understand, I think "NETStandard.Library": "1.5.0-rc2-23931" is not needed anymore, when I had the same problem as you, I added the runtimes. Maybe there too many flavours right know and no official information on how to build a basic project.
@schellap I think this may have been regressed by https://github.com/dotnet/cli/commit/0fec9842dfd654e31140bd2b4c43044b697d1458. When testing on Debian, I didn't see this issue with version 1.0.0-rc2-002365 of CLI, which was shortly before that commit, but I did see it with version 1.0.0-rc2-002379, which was shortly after it. With version 2365, the error experience is:
Unhandled Exception: System.MissingMethodException: Entry point not found in assembly 'classlib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
which I think makes a lot more sense.
Interestingly, Jeff's repro was on 2349, so perhaps this issue was fixed between 2349 and 2365 and then regressed before 2379, or perhaps the behavior is platform-specific (he used OS X and I used Debian).
@brthor, if emitEntryPoint is false we don't copy host artifacts. See here: https://github.com/dotnet/cli/blob/rel/1.0.0/src/Microsoft.DotNet.Compiler.Common/Executable.cs#L81
We need this for the right experience. @piotrpMSFT. I believe for RTM this would be from the nuget cache?
dotnet/sdk#5631 is tracking bringing those from the nuget cache during build
Are you suggesting we need to copy the host artifacts for a library though?
This has been fixed in the latest stable (Preview 2) release of the tooling.