-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Native assets are not copied to bin on build and application fails to run #316
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
Comments
It looks like the problem may be that EDIT: Nevermind, that was when running on .NET Core. Continuing to investigate... |
In the
Meanwhile, the PackageDependencyResolution targets file is looking for items with the FileGroup metadata set to NativeLibrary, RuntimeAssembly, or ResourceAssembly (which correspond to @rrelyea @yishaigalatzer What does the |
Packages can include rid specific assets (fat package). This is what libuv does. Runtime targets express that intent in the assets file. With portable applications on .NET Core, all of these assets for all rids are copied to the output folder and the runtime understands how to pick the most appropriate ones. In the case of .NET .Framework, the loader only understands the the flat directory layout. To accommodate for that, the runtime targets need to be filtered to the appropriate Rid when using .NET Framework, so the appropriate rid specific assets are copied to the output. I'm not sure why it says win7-arm but I'm guessing that's wrong 😁 |
Currently the targets are set up to copy items from the
|
When we redesigned This allowed us to remove the "runtimes" section from project.json when migrating to .csproj. However, we overlooked desktop projects when coming up with this design. Do desktop apps always need a RID? What happens if I want to build my app for "Any CPU"? Which native assets should get chosen? (I don't think project.json supported desktop "Any CPU" projects - if you didn't have a runtime the CLI would infer one for you: https://github.com/dotnet/cli/blob/1278e9d6bf35500e9672fe3f53125df1d08717d8/src/Microsoft.DotNet.ProjectModel/ProjectContextBuilder.cs#L298-L312). @piotrpMSFT @livarcocc @nguerrera - We will need to rethink how we handle desktop projects w.r.t. Runtime Identifiers. |
In my local web project, if I add the following line to my .csproj:
and then @BillHiebert - can you try that workaround? If it works, maybe there is some defaulting of RIDs we can do for desktop apps. Or maybe desktop apps always need to specify the RID...? |
Adding win7-x64 fixes the libuv failure, but now I see the following - likely related to #315 Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileLoadException: Could not load file or assembly 'Microsoft.AspNetCore.Routing, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) |
@BillHiebert To fix the FileLoadException, can you try adding the following property to the project? <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> |
Fixes the warnings during build, and fixes the assembly load issue, but has a new problem. I verified that I am running the 64bit dotnet.exe and the runtime identifier is win7-x64. I guess the wrong libuv.dll was copied to bin Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) |
Based on the timestamps and filesize it seems to have copied the win7-x64 version of libuv. Could this be related to building AnyCpu? |
The bitness of dotnet.exe doesn't matter. All dotnet.exe does is ensure the project is built and then spawns a new process for your app's .exe. What architecture does your app target? |
Or the other thought is to change x64 to x86 in your .csproj. Does that make it run? |
In the CLI we defaulted the Platform to
See https://github.com/dotnet/cli/issues/2428 for more details. |
This is fixed. We updated the templates to set the RuntimeIdentifier to win7-x86 and updated the targets to infer the PlatformTarget from the RuntimeIdentifier. |
Still happening over here, same problem. |
@jose-cf please open a new issue with your repro steps. I cannot reproduce it with the original repro steps. |
Adding support fo PB_VersionStamp and PB_IsStable
Create an empty ASP.NET Core application targeting DotNet 4.52. Run the application. Project fails to run because of the following. Looking in the output folder I see that libuv.dll was not copied there
nhandled Exception: System.AggregateException: One or more errors occurred. ---> System.DllNotFoundException: Unable to load DLL 'libuv': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.NativeMethods.uv_loop_size()
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.loop_size()
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvLoopHandle.Init(Libuv uv)
at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelThread.ThreadStart(Object parameter)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelEngine.Start(Int32 count)
at Microsoft.AspNetCore.Server.Kestrel.KestrelServer.Start[TContext](IHttpApplication`1 application)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.Start()
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host, CancellationToken token, String shutdownMessage)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
at WebApplication1.Program.Main(String[] args)
The text was updated successfully, but these errors were encountered: