tryphotino / photino.NET

https://tryphotino.io
Apache License 2.0
885 stars 73 forks source link

add `net7.0` TFM and allow for .NET 7 AOT #130

Closed brettfo closed 1 year ago

brettfo commented 1 year ago

The method Marshal.GetHINSTANCE() is not supported in AOT scenarios, but the method NativeLibrary.GetMainProgramHandle() was added in .NET 7 and allows for this to work.

Since there's not a corresponding API to make this work in .NET 6, I multi-targeted the project so existing scenarios for .NET 6 users will still work.

Verified that .NET 7 AOT works on win-x64, win-arm64, and linux-x64; I don't have the hardware to check anything else.

philippjbauer commented 1 year ago

Hi @brettfo, thank you for your contribution!

We have just one question about the changes in the pipeline configuration. You added the .NET 7 SDK alongside the .NET 6 SDK to the build machine setup. Would the build machine not always use the newer SDK to build the project and make the lesser version obsolete in this scenario?

brettfo commented 1 year ago

Good catch! I uninstalled my .NET 6 SDK, did a full clean, and was able to build and pack the extension and both the net6.0 and net7.0 libraries were appropriately created. I'll fix the pipeline configurations to only install .NET 7.

brettfo commented 1 year ago

I was also able to test win-arm64. I've modified the original comment to reflect this.