-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global tools targeting netcoreapp2.0 do not work with preview2 SDK #9286
Comments
@spboyer I am not familiar with this global-tool template. Can you share its contents? Also, in preview2, if you are not using a default location (one set through a native installer), you need to set DOTNET_ROOT, pointing to the root of your dotnet installation. This is so that the tool shim can find a shared framework to run against. |
This is the template from @natemcmaster - I did't purposely set an installation location outside of the default for dotnet (clicked next, next, next :-)) |
@wli3 @peterhuene can you guys check the template above and make sure it is correct for preview2? |
It is not correct for preview 2 anymore. It is targeting netcoreapp2.0 which does not have new AppHost support(able to find runtime on programfiles). |
So, are you saying that global tools don't work for console apps that target netcoreapp2.0? FYI the templates should produce a project that effectively looks like this. <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<PackAsTool>true</PackAsTool>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
</Project> |
I played with netcoreapp2.0, and it seems this is completely busted. I'm re-opening as it seems like either:
Repro:
Error
|
I think an error on Pack when PackAsTool is set and TFM is less than netcoreapp2.1 seems reasonable. Your second option is not really feasible as we depend on the framework exe feature built in the runtime in netcoreapp2.1. |
@wli3 @peterhuene can you take a look? |
I think an error on pack is reasonable as well. |
@livarcocc I can add check on Pack to prevent TFM is less than netcoreapp2.1 . So i will target this work for release 2.1.3xx. @KathleenDollard I think we have a communication issue on the breaking of netcoreapp2.0. |
So the action item is to add warning for PackAsTool |
I agree that we should add this warning on pack |
How come this worked in preview 1? The following package installs and runs fine on preview 1 |
I would like to +1 this - this issue has broken /~https://github.com/filipw/dotnet-script/ as well, which is targeting With preview1, it was generating It seems that the problem is with that
If I copy the generated If possible, it would be great if this could be fixed rather than simply communicated as a breaking change. |
@seesharper , @filipw Also, for security reasons, the location of the executable is hardcoded when the shim is created. If you recompile, publish, and re-install your application, does it work? Also, because of changes between Preview 1 and Preview 2, you must manually uninstall Preview 1 Global Tools by removing the directory and the shim. |
@KathleenDollard if you target netcoreapp2.1 and recompile, it works. |
if you target netcoreapp2.1 and recompile, it works. Not every tool can afford to retarget itself into netcoreapp2.1 straight away, as there could be other considerations and dependencies. |
That's the plan. For global tools, you will need to target netcoreapp2.1. Can you share more details on what are the considerations and dependencies that would block you from moving your global tool (the first version should have been out with preview1 only) to netcoreapp2.1. netcoreapp2.1 should be able to reference anything that netcoreapp2.0 did. So, dependencies should not be a problem. |
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 I am sure I do not see the full picture here, but it sounds like you could have made it work with Is there any workaround for that? Could I for example bring my own shim instead of rely on the generated one? |
It is possible. If you follow the convention tools/TFM/RID/shims/SHIM-RID Your own shim will be used However, you need to cover shims for every different OSs you support(rid and shim name need to be the same as your command name and .exe is needed on Windows. |
thanks a lot, looks promising - we will have to explore this. On a related note - if a Is this intended for the future versions only? i.e. 2.2, 2.3, 3.0 etc? If so, then maybe it would be better to remove the option for now to not cause confusion for now. |
@filipw more importantly it is to fit dotnet core TFM model. And currently it is for future proof, to have an option for multi target 2.1 and next rumtime major bump --a breaking runtime version will cause existing 2.1 build fail to run. But producer can multi target both TFM to meet all audience |
Regarding the decision to have Global Tools support only 2.1 and forward. The previous shim was a hack, particularly on Windows. The new executable approach allows a single process, which means it will show up as the exe name not "dotnet' in your process explorer, be immensely more debuggable, and other benefits. Some amazing work by the runtime team made this possible and we believe it is the right experience for Global Tools. Sadly it did break the netcore20 compatibility. We decided to allow BYOS (bring your own shim) to handle some internal scenarios, and rather late. So, sadly, we have zero support for building packages with custom shims. We think for almost everyone, the new standard shim strategy is a really good one, and more secure as we make it difficult to hijack the DLL call. You're in a special position, and I hope the custom shim works for you. As a side note: why did you call your tool |
@KathleenDollard thanks for the info. We managed to solve it for the time being by using cross compilation. So if you are on 2.1 preview SDK, you'd run as netcoreapp2.1, if you are on earlier version you'd run as netcoreapp2.0. The shim is something we will explore down the road. Regarding your naming comment, it's simple - there has been a vision since the beginning that in the future |
yes, I answered to quickly without realizing this was an existing tool. |
Steps to reproduce
dotnet new global-tool -n my-tool --command-name go
dotnet pack --ouput ./
dotnet tool install -g my-tool --source ./
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:The text was updated successfully, but these errors were encountered: