Global tools targeting netcoreapp2.0 do not work with preview2 SDK
See original GitHub issueSteps to reproduce
- Create dotnet global tool
dotnet new global-tool -n my-tool --command-name go
dotnet pack --ouput ./
- install
dotnet tool install -g my-tool --source ./
- run
go
Error in latest SDK (see --version
below)
A fatal error was encountered. The library ‘hostpolicy.dll’ required to execute the application was not found in ‘C:\Program Files\dotnet’.
same on macOS A fatal error was encountered. The library ‘libhostpolicy.dylib’ required to execute the application was not found in ‘/usr/local/share/dotnet’.
Environment data
dotnet --info
output:
.NET Core SDK (reflecting any global.json):
Version: 2.1.300-preview2-008530
Commit: 822ae6d43a
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17133
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.300-preview2-008530\
Host (useful for support):
Version: 2.1.0-preview2-26406-04
Commit: 6833f3026b
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:25 (10 by maintainers)
Top Results From Across the Web
Global tools targeting netcoreapp2.0 do not work with ...
Steps to reproduce Create dotnet global tool dotnet new global-tool -n my-tool --command-name go dotnet pack --ouput ./ install dotnet tool ...
Read more >NET Core 2.1 Preview 2 Known Issues
NET Core 2.1 Preview 2 which may be encountered during usage. ... issue on GitHub Global tools targeting netcoreapp2.0 do not work with...
Read more >The current .NET SDK does not support targeting . ...
0 , but after trying to build I get this error: The current .NET SDK does not support targeting .NET Standard 2.0. Either...
Read more >NETSDK1045: The current .NET SDK does not support ...
Go to Tools > Options > Environment > Preview Features, and make sure that Use previews of the .NET Core SDK is checked....
Read more >ASP.NET Core 2.1.0-preview2 now available
The Razor SDK adds the necessary build targets and properties so that Razor files can be included in the build. To create your...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would like to +1 this - this issue has broken https://github.com/filipw/dotnet-script/ as well, which is targeting
netcoreapp2.0
as well.With preview1, it was generating
dotnet-script.exe.config
in the.dotnet/tools
folder upon installation. Now with preview2, adotnet-script.startupconfig.json
is being generated.It seems that the problem is with that
appRoot
path found in that startup JSON file, as it is not being respected by the generated shim EXE. Instead of using the path to find dependency DLLs, it searches for them in the current folder, hence the error mentioning a DLL under the current path:If I copy the generated
dotnet-script.exe
into the tool package folder (soC:\Users\xxx\.dotnet\tools\.store\dotnet-script\0.21.0\dotnet-script\0.21.0\tools\netcoreapp2.0\any
, then the shim works.If possible, it would be great if this could be fixed rather than simply communicated as a breaking change.
In the case of dotnet-script project, it is a C# script runner, and it compiles your scripts by combining your own script-level references and some implicit references inherited from the runner itself. Long story short, if the script wants to be executed as
netcoreapp2.0
it cannot be fed the implicit inherited dependencies from the host runner which is built againstnetcoreapp2.1
.I am sure I do not see the full picture here, but it sounds like you could have made it work with
netcoreapp2.0
(after all, it worked already) but it was consciously decided to take advantage of a the runtime feature ofnetcoreapp2.1
? Is this driven by an expectation that people would not usenetcoreapp2.0
oncenetcoreapp2.1
comes out? Also, aren’t the global tools part of SDK, which should be kind of independent of the runtime? 🙂Is there any workaround for that? Could I for example bring my own shim instead of rely on the generated one?