smourier / DirectN

Direct interop Code for .NET Framework, .NET Core and .NET 5+ : DXGI, WIC, DirectX 9 to 12, Direct2D, Direct Write, Direct Composition, Media Foundation, WASAPI, CodecAPI, GDI, Spatial Audio, DVD, Windows Media Player, UWP DXInterop, WinUI3, etc.
MIT License
314 stars 28 forks source link

Compatibility with .Net Core 3.1 and above. #7

Closed jfrancisco-neto closed 4 years ago

jfrancisco-neto commented 4 years ago

In an attempt to use this lib in a .Net Core 3.1 the compiler issues this warning:

warning NU1701: Package 'DirectN 1.9.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'. This package may not be fully compatible with your project.

There are any plans to support .Net Core ?

smourier commented 4 years ago

Hi,

I've added a .NET core version. In fact, the files are all plain C# files so they're supposed to work for most C# compilers even "old" ones (well, of course they require a Windows platform to execute), so you can just take any files an put them as is in any .NET C# project (core, standard, etc.)

The only remark with .NET core is some files report this warning:

warning CS0618: 'ComInterfaceType.InterfaceIsIDispatch' is obsolete: 'Support for IDispatch may be unavailable in future releases.'

There's nothing we can't do for these. If you don't want it you must remove these files and recompile yourself, but right now it still works with .NET Core 3.1.

TGRye commented 3 years ago

This might need looking at again. I created a new .Net 5.0 Class Library and tried to add the DirectNCore nuget package and it complains..

Package restore failed. Rolling back package changes for 'GV3D'.
NU1202 Package DirectNCore 1.9.0.2 is not compatible with net5.0 (.NETCoreApp,Version=v5.0). Package DirectNCore 1.9.0.2 supports: net5.0-windows7.0 (.NETCoreApp,Version=v5.0) GV3D C:\Users\GeoVista\OneDrive\Projects\GeoVista\GV3D\GV3D\GV3D.csproj 1

smourier commented 3 years ago

DirectN.MinimalD3D11 has been upgraded to .NET 5 with .NET Core 5. This error might be due to some project properties subtleties.

Please share your project file.

TGRye commented 3 years ago
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

</Project>

It is a new and empty .Net 5.0 class library.

smourier commented 3 years ago

Check MinimalD3D11: https://github.com/smourier/DirectN/blob/master/DirectN/DirectN.MinimalD3D11/DirectN.MinimalD3D11.csproj

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

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net5.0-windows</TargetFramework>
    <UseWindowsForms>true</UseWindowsForms>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <DisableWinExeOutputInference>true</DisableWinExeOutputInference>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\DirectNCore\DirectNCore.csproj" />
  </ItemGroup>

  <ItemGroup>
    <None Update="shaders.hlsl">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>

</Project>

You must use a Windows target.

TGRye commented 3 years ago

Sigh. Of course. Thanks.