confluent-kafka-dotnet icon indicating copy to clipboard operation
confluent-kafka-dotnet copied to clipboard

librdkafka.redist runtime files aren't copied to OutputPath in .NET Core.

Open inikulshin opened this issue 10 months ago • 0 comments

Description

librdkafka.redist runtime files aren't copied to OutputPath in .NET Core target frameworks.

How to reproduce

I have an SDK project with

  <PropertyGroup>
    <TargetFrameworks>net472;net6.0</TargetFrameworks>
    ...

    <PackageReference Include="Confluent.Kafka" Version="2.2.0" />
    ...

After I build this project with VS2022, librdkafka/* files are copied to OutputPath only for net472.

But the issue is actually originates in restore. MyProj\obj\MyProj.csproj.nuget.g.props contains Import of librdkafka.redist.props only for net472:

  <ImportGroup Condition=" '$(TargetFramework)' == 'net472' AND '$(ExcludeRestorePackageImports)' != 'true' ">
    <Import Project="$(NuGetPackageRoot)\librdkafka.redist\2.2.0\build\librdkafka.redist.props" Condition="Exists('$(NuGetPackageRoot)\librdkafka.redist\2.2.0\build\librdkafka.redist.props')" />
    ...
  </ImportGroup>
  <ImportGroup Condition=" '$(TargetFramework)' == 'net6.0' AND '$(ExcludeRestorePackageImports)' != 'true' ">
    ...
  </ImportGroup>

Workround

Explicitly reference librdkafka.redist in project file:

    <PackageReference Include="librdkafka.redist" Version="2.2.0" />

However, I'll appreciate an explanation of this behavior. Probably, it's not related to Kafka, but to .NET Core.

inikulshin avatar Apr 25 '24 20:04 inikulshin