SciSharp.Tensorflow.Redist not copying tensorflow.dll to output directory when using net48
The SciSharp.Tensorflow.Redist package does not copy the content of the runtimes folder (containing tensorflow.dll) to the output directory when working on .NET Framework 4.8 (despite being listed as 'compatible' on nuget.org). After switching to .NET 6.0, the folder gets copied correctly. The following are true:
- Installed SciSharp.Tensorflow.Redist 2.7.0 (latest)
- Switched from 'Any CPU' to 'x64' in VS
- Tested on
net48andnet6.0console apps and class libraries (unit test project).
Here is the .csproj of my project:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="SciSharp.Tensorflow.Redist" Version="2.7.0" >
<IncludeAssets>all</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
What could be the problem?
Update: While browsing the Nuget package file, I found this script that supposedly is responsible for the copying of the .dll files:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--
NuGet packages.config doesn't support native assemblies automatically,
so copy the native assemblies to the output directory.
-->
<ItemGroup Condition="Exists('packages.config') OR
Exists('$(MSBuildProjectName).packages.config') OR
Exists('packages.$(MSBuildProjectName).config')">
<Content Include="$(MSBuildThisFileDirectory)\..\..\runtimes\win-x64\native\*.dll"
Condition="'$(PlatformTarget)' == 'x64'">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
<Link>%(Filename)%(Extension)</Link>
</Content>
<Content Include="$(MSBuildThisFileDirectory)\..\..\runtimes\win-x86\native\*.dll"
Condition="'$(PlatformTarget)' == 'x86'">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>false</Visible>
<Link>%(Filename)%(Extension)</Link>
</Content>
</ItemGroup>
</Project>
This is outdated for multiple reasons, one of them being that Tensorflow doesn't even support x32 (x86)-architecture, so the second half is unnecessary. More importantly, the existance of packages.config files that serve as a condition for copying the assemblies is not up to date because they got replaced by .csproject-files in newer .NET Core and Framework versions.
Could that be the source of the problem?
I'm late for this issue. Did you solve the problem later? If you haven't solved it, I'd like to help. If you have had a deal for it, we will appreciate for it if you'd like to submit a PR.😊