-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
plugins fail to load for dotnet 6 single file - self contained app #59961
Comments
Tagging subscribers to this area: @agocke, @vitek-karas, @VSadov Issue DetailsDescriptionRunning plugins with dotnet 6 rc1 for single file, self contained applications broke. The issue was found originally in Linux, but was also reproduced on windows. Specifically the AssemblyDependencyResolver's constructor throws an exception when loading the plugin. To reproduce follow the instructions on the readme in this isolated reproduction of the issue: https://github.com/freddyrios/pluginsloadfailure. Alternatively follow microsoft documentation on creating an application with plugins https://docs.microsoft.com/en-us/dotnet/core/tutorials/creating-app-with-plugin-support and publish it as a single file, self contained app with the runtime identifier that matches your system. Configurationdotnet --version: 6.0.100-rc.1.21463.6 Regression?It is a regression, see the demo which shows doing the same steps with a different target breaks. Other informationThis is the stacktrace:
|
As far as I can tell it's a "regression" in single-file - specifically when hostpolicy is part of the apphost, which is true for any superhost. It works a non-single-file SCD app just fine. |
@vitek-karas yes, it is only a regression when making it a single file + self contained app. Making it non single file or non self contained works. |
@vitek-karas forgot to add, that's what we have been running with .net 5. |
I'm actually surprised that it worked on .net 5 - I would expect this to break even on .net 5 (windows or not) |
It does indeed work on .net 5 - interesting... The theory is that in both cases the This was the case already in .NET 5, but maybe something else changed. This will be much easier to solve for @VSadov because he knows exactly how this works... |
reason: this allows to run without publishing the app as a single file, which at the time of writing allows to workaround dotnet/runtime#59961
* breaking change: plugins run from the "plugins" subfolder reason: this allows to run without publishing the app as a single file, which at the time of writing allows to workaround dotnet/runtime#59961 * Also fixed regression in #127 preventing the full help from showing in the help command.
$ dotnet publish HelloPlugin -c Release -f net6.0 -o test
$ dotnet publish AppWithPlugin -c Release --use-current-runtime --self-contained -p:PublishSingleFile=true -f net6.0 -o test
$ test/AppWithPlugin
Loading commands from: /home/am11/projects/pluginsloadfailure/HelloPlugin.dll
System.InvalidOperationException: Cannot load hostpolicy library. AssemblyDependencyResolver is currently only supported if the runtime is hosted through hostpolicy library.
---> System.EntryPointNotFoundException: Unable to find an entry point named 'corehost_set_error_writer' in shared library 'libhostpolicy'.
at Interop.HostPolicy.corehost_set_error_writer(IntPtr errorWriter)
at System.Runtime.Loader.AssemblyDependencyResolver..ctor(String componentAssemblyPath)
$ strings ~/.dotnet6/packs/Microsoft.NETCore.App.Host.linux-musl-x64/6.0.0-rtm.21504.6/runtimes/linux-musl-x64/native/singlefilehost |\
grep corehost_
corehost_main
corehost_main_with_output_buffer
corehost_initialize
corehost_resolve_component_dependencies
Hostpolicy must be initialized and corehost_main must have been called before calling corehost_resolve_component_dependencies.
corehost_resolve_component_dependencies results: { vs. 5.0 $ strings ~/.dotnet5/packs/Microsoft.NETCore.App.Host.linux-musl-x64/5.0.10/runtimes/linux-musl-x64/native/singlefilehost |\
grep corehost_
corehost_resolve_component_dependencies
corehost_main
corehost_load
corehost_set_error_writer
corehost_main_with_output_buffer
corehost_initialize
corehost_unload
corehost_main
corehost_main_with_output_buffer
corehost_initialize
corehost_resolve_component_dependencies
Hostpolicy must be initialized and corehost_main must have been called before calling corehost_resolve_component_dependencies.
corehost_resolve_component_dependencies results: { |
Most likely reason for the failure is indeed missing PInvoke overrides. I will work on a fix. It should not be too involved. |
I have implemented a fix, and it works on 6.0, but I see 1 failure in It is a framework dependent singlefile configuration targeting 5.0. (so far I only tested on Windows).
@vitek-karas - do we expect this configuration to work? Self-contained 5.0 seems to be fine, BTW, just framework-dependent has issues. |
It should not fail like that. I'll have to look into this. |
That failure is a test-only issue. In the tests we create the apphost (before bundling) and stamp it with a full path to the application dll. So something like When starting the app, because the SDK will never do this because it doesn't write absolute paths to the apphost, it only writes relative paths and so the "app base" will be the location of the "exe". Ideally |
I prepared a fix and sent it to your PR via another PR VSadov#3. |
@VSadov did the fix merged into the dotnet 6 branch made it to the rc2? |
I have tested @freddyrios' application and can confirm that fix is available in 6.0.0-rtm.21511.12 (but not rc2), downloaded from https://github.com/dotnet/installer#installers-and-binaries (second column in the table). The app does not throw missing entrypoint exception for Note that rc2 is not getting the recent runtime changes, use rtm daily snapshots for the latest of net6. |
I can confirm the latest daily for dotnet 6 rtm works for our full app running on linux - raspbian. Are there any additional steps needed to ensure it makes it to the full release, or is the presence in the daily snapshots already confirmation it will make it? ps. I assume daily snapshots are not covered by the golive |
The fix will make it to 6.0 release.
Just clarifying if you used the Release/6.0.1XX daily snapshots, then yes, those are builds which will eventually become the final release. (Not the main/7.0.x).
No, the only golive releases are the RC1 and RC2 official builds (and then the final release). |
thanks all for the quick response |
Description
Running plugins with dotnet 6 rc1 for single file, self contained applications broke. The issue was found originally in Linux, but was also reproduced on windows. Specifically the AssemblyDependencyResolver's constructor throws an exception when loading the plugin.
To reproduce follow the instructions on the readme in this isolated reproduction of the issue: https://github.com/freddyrios/pluginsloadfailure.
Alternatively follow microsoft documentation on creating an application with plugins https://docs.microsoft.com/en-us/dotnet/core/tutorials/creating-app-with-plugin-support and publish it as a single file, self contained app with the runtime identifier that matches your system.
Configuration
dotnet --version: 6.0.100-rc.1.21463.6
reproduced both on windows 10 and raspbian (linux / debian)
windows 10 was x64 and raspbian is arm
doesn't look specific to the OS or architecture
Regression?
It is a regression, see the demo which shows doing the same steps with a different target breaks.
Other information
This is the stacktrace:
The text was updated successfully, but these errors were encountered: