question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Copy runtime libraries from references project

See original GitHub issue

I have Library.csproj with following code:

<ItemGroup>
    <Content Include="runtimes\win7-x86\native\**\*">
      <PackagePath>.</PackagePath>
      <Pack>true</Pack>
    </Content>
</ItemGroup>

When I run dotnet pack, I can see native dll-s in the generated package. If I reference this NuGet package (using my own feed) in the another project then all libraries are correctly placed into bin folder. But if I reference this project directly then libraries are not copied.

We need to have one uniform way to add native libraries into project and use them in all scenarios:

  • Directly in this project
  • In other project that references this project
  • In the generated NuGet package

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:12
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
asmichicommented, Jul 3, 2022

I have made an extreme hack to add runtime libraries into deps.json: https://github.com/asmichi/DotNetInjectNativeFileDepsHack WARNING: This will likely break in a future version of the .NET SDK.

The problem is that runtime libraries from reference projects do not appear in deps.json and thus cannot be loaded by DllImport. Only NuGet libraries can have runtimeTargets! Okay, then, trick the build to add runtime libraries into an existing NuGet library.

1reaction
silkfirecommented, Nov 24, 2022

Another thing that doesn’t seem to be possible at the moment is specifying a subdirectory where the native library ends up after publish. Right now they’re all emitted to the root (/publish/) directory, regardless if they reside in a subdirectory inside the NuGet package itself (/runtimes/<arch>/native/sub1/sub2/mylib.dll).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Studio projects copy dependencies from referenced ...
Is it possible to make Visual Studio to copy all dependencies of referenced projects into the output path? Example. In the Solution, Project...
Read more >
Manage references in a project - Visual Studio (Windows)
If you see a References node in Solution Explorer, you can use the right-click context menu to choose Add Reference. Or, right-click the...
Read more >
How to copy dependent assemblies to the bin folder on build?
How to copy referenced assemblies to the bin folder on build? Open your project file. Simple enough, just select “Edit Project File” by...
Read more >
Linked project items do not get copied to the output directory
I just tried this solution with one of my nuget packages. This only copies the dll to the output directory of the project...
Read more >
How to stop references being copied to output directory ...
When using dotnet build on the My.Assembly project, the Private assemblies are always copied to the /external/ folder (resulting in multiple ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found