Skip to content
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

How to consume native dependencies via ProjectReference? #10575

Open
huoyaoyuan opened this issue Oct 25, 2019 · 0 comments
Open

How to consume native dependencies via ProjectReference? #10575

huoyaoyuan opened this issue Oct 25, 2019 · 0 comments

Comments

@huoyaoyuan
Copy link
Member

Opening at this repository because requiring something like dotnet/cli#1841.

Steps to reproduce

We are publishing some native dependencies via csproj:

  <ItemGroup>
    <NativeLibs Include="$(MSBuildThisFileDirectory)runtimes\**\*.dll*" />
    <NativeLibs Include="$(MSBuildThisFileDirectory)runtimes\**\*.so" />
    <NativeLibs Include="$(MSBuildThisFileDirectory)runtimes\**\*.a" />
    <NativeLibs Include="$(MSBuildThisFileDirectory)runtimes\**\*.dylib" />
    <None Include="@(NativeLibs)">
      <Pack>true</Pack>
      <PackageCopyToOutput>true</PackageCopyToOutput>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Include="_._">
      <Pack>true</Pack>
      <PackagePath>lib/netstandard2.0</PackagePath>
    </None>
  </ItemGroup>

The native libraries are correctly packaged into runtimes\win-x64\native\*.dll and other rids.
A test application sits in the same repository, using ProjectReference to consume the library.
The test application's .deps.json is missing entry for native dependencies, causing them failed to load at runtime.
However, if I put the nupkg into local source and consume it via PackageReference, it's getting native libraries in .deps.json.

Are we packaging it in the wrong way? What's the standard packaging to consume by source?
I cannot find a popular library consuming native packages via project reference. Looked SQLitePCLRaw.lib.e_sqlite3 and runtime.native.System.Data.SqlClient.sni, their tests are consuming them via PackageReference.

Environment data

dotnet --info output:

.NET Core SDK(反映任何 global.json):                                                                                   Version:   3.0.100
 Commit:    04339c3a26

运行时环境:
 OS Name:     Windows
 OS Version:  10.0.18362
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100\

Host (useful for support):
  Version: 3.0.0
  Commit:  7d57652f33

.NET Core SDKs installed:
  3.0.100 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant