jingwood / d2dlib

A .NET library for hardware-accelerated, high performance, immediate mode rendering via Direct2D.
MIT License
234 stars 40 forks source link

Package doesn't appear to work under .NET Core or .NET 5 #38

Closed drewnoakes closed 3 years ago

drewnoakes commented 3 years ago

I've created a new netcoreapp3.1 WinForms app and added a package reference to the latest version of the package.

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <UseWindowsForms>true</UseWindowsForms>
    <Prefer32Bit>true</Prefer32Bit>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="unvell.D2DLib" Version="1.2.2" />
  </ItemGroup>

</Project>

NuGet restore completes succesfully. It doesn't appear to have added any managed assembly references to the compilation, as I see error:

error CS0246: The type or namespace name 'unvell' could not be found (are you missing a using directive or an assembly reference?)

Looking in the obj/project.assets.json file I see:

      "unvell.D2DLib/1.2.2": {
        "type": "package",
        "build": {
          "build/unvell.D2DLib.targets": {}
        }
      },

The .targets file is picked up. I see the linked d2dlib32.dll in the project tree.

image

If I change <TargetFramework> to net4.8, the compilation error goes away. The assets file now shows:

      "unvell.D2DLib/1.2.2": {
        "type": "package",
        "compile": {
          "lib/net20/d2dlibexport.dll": {},
          "lib/net20/d2dwinform.dll": {}
        },
        "runtime": {
          "lib/net20/d2dlibexport.dll": {},
          "lib/net20/d2dwinform.dll": {}
        },
        "build": {
          "build/unvell.D2DLib.targets": {}
        }
      },

For some reason, NuGet is excluding the compile and runtime items when targeting netcoreapp3.1 and net5.0-windows. My guess is the .nuspec file is at fault.