Runtime-specific imported dll in dotnet tool

21 Views Asked by At

I'm trying to publish a dotnet tool that depends on a library that uses a dll import attribute.

When I build the project & run it locally (without packaging it into a nupkg and then installing the tool), it works fine and the dll that's imported by the library appears in the directory MyProject\bin\x64\Release\net6.0\x64 and (presumably a slightly different version) in MyProject\bin\x64\Release\net6.0\x86. Running it works.

When I instead follow the following steps:

  1. dotnet pack MyProject.csproj -c Release -o myOutputDirectory
  2. dotnet tool install MyProject --tool-path myInstallPath (install from the generated nupkg)

When I investigate the location of the mentioned DLLs, it seems to be the same as before. However, now when I invoke the tool (via ./myInstallPath/MyProject.exe) I get:

Unhandled exception. System.DllNotFoundException: Unable to load DLL 'MyImportedDll.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)

Curious if anyone has insights on why there's a difference between how it behaves when run as an installed tool vs. just directly, and how to circumvent this issue?

0

There are 0 best solutions below