Open kg opened 4 years ago
I should note that on my windows machine if I open cmd
and perform dotnet run
in the project directory, it works despite the bin directory not having the dependency in it.
Did you specify any runtime indentifier for the dotnet publish
? Eg. dotnet publish -r win-x64
; it generates a new subdirectory in the publish output folder.
The Gee.External.Capstone package has a bit unusual structure where the actual implementation is provided only for win-x86
and win-x64
runtimes. If the runtime identifier is not specified it may not copy anything to the output folder:
I tried it locally on your project:
Seems to do the job.
OK, so it sounds like the package is authored to do this. Does it really make sense for dotnet build/dotnet publish to 'succeed' on a platform and generate an executable that cannot ever possibly work? This feels like a dependency resolution failure that just happens to have been intended by the package author, I would have hoped that some part of the tooling would have noticed it was impossible to resolve the dependency and alert me to it.
Thanks for looking into the metadata, I didn't know how to do that.
As always, I really recommend NuGet Package Explorer and MSBuild Log viewer as the go-to tools for digging deep into issues like this.
It is really unusual way to package the NuGet. Normally the managed code is shared across RIDs and the native libraries are packaged under different RIDs. Perhaps there's some good reason for this but it's not a common setup.
I suppose some warning would be nice but not sure how easy is it to do that (wrt. self-contained vs framework-dependent deployments). There are certain scenarios where the assemblies are intentionally omitted from the implementation because they are supplied by the underlying platform. The whole dotnet SDK itself is composed of NuGets and this is probably the common scenario for the platform itself.
I have a simple C# project using two nuget packages that builds and runs fine in VS2017 on Windows set to .NET Core 2.1. If I use
dotnet build
,dotnet publish
ordotnet run
in all 3 cases one of the packages is missing from the output directory so it fails to be loaded.dotnet restore
doesn't fix this, neither does setting<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
in the csproj.In the csproj you can see the two dependencies here: https://github.com/kg/wasmdis/blob/master/WasmDis.csproj#L36
If you look at the result of a publish, you can see that the native dependencies for Capstone were copied into the output directory but the managed assembly was not. The managed assembly is present in the .deps.json so the dependency is being tracked somehow.
It's not clear to me how to debug this and it's kind of disappointing that the error feedback/output doesn't explain that it attempted to load the dependency out of my local package cache (or whatever) and failed.