4

I'm writing a library which has support for GPU acceleration through the Alea.Gpu library, and so far my setup is:

  • Base .NET Standard 2.0 binary (CPU)
  • .NET Framework 4.7.1 with Alea.Gpu (GPU)

The idea is that you'd only use the base .NET Standard 2.0 library when on .NET Core/UWP/Whatever, and also include the .NET Framework 4.7.1 library when using a .NET Framework app to leverage the GPU support.

Since Alea.Gpu is cross-platform though (it works with Mono and Xamarin too according to the docs), I thought I'd move all the code in a single .NET Standard 2.0 library, and the user would then be able to check if the GPU features are supported on the current platform before eventually using them.

The problem is that currently the Alea.Gpu NuGet packages doesn't seem to be using the new PackageReference setup, so installing it in the .NET Standard 2.0 library causes the package to be added successfully, but the dependencies being lost in the process. In practice, I have Alea.Gpu installed but I don't have any namespace in the library (the .dll files aren't there either).

See here: https://github.com/dotnet/standard/issues/481

I have found a workaround that seems to work, even if on .NET Framework only, that just consists of adding these lines to the library .csproj file:

<ItemGroup>
    <Reference Include="Alea">
        <HintPath>$(NuGetPackageRoot)\alea\3.0.4\lib\net45\alea.dll</HintPath>
    </Reference>
    <!-- Same for Alea.Parallel -->
</ItemGroup>

My questions are:

  • Even if the .dll files aren't correctly added to the library, would they still be downloaded upon build, so that they'd still end up in that folder as in the .csproj code, on any other PC too?
  • Is it safe to say that upon build VS will restore those .dll files in the same net45 subfolder, regardless of the actual platform? I mean, will it automatically fallback to net45 when restoring the packages for the .NET Standard 2.0 library?
  • Is there any other (better) workaround until Alea.Gpu is updated to use PackageReference so that it will automatically include those .dll files?

Thanks!

Sergio0694
  • 4,447
  • 3
  • 31
  • 58

0 Answers0