dotnet / Silk.NET

The high-speed OpenGL, OpenCL, OpenAL, OpenXR, GLFW, SDL, Vulkan, Assimp, WebGPU, and DirectX bindings library your mother warned you about.
https://dotnet.github.io/Silk.NET
MIT License
3.89k stars 378 forks source link

SDL2 gone on publish #2157

Closed Coloryr closed 2 months ago

Coloryr commented 2 months ago

Summary

SDL2.dll gone on publish

System.IO.FileNotFoundException: Could not load from any of the possible library names! Please make sure that the library is installed and in the right place!
   at Silk.NET.SDL.Sdl.CreateDefaultContext(String[] n)
   at Silk.NET.SDL.Sdl.GetApi()
   at ColorMC.Gui.Utils.InputControl.Init() in E:\code\ColorMC\src\ColorMC.Gui\Utils\InputControl.cs:line 21
   at ColorMC.Gui.UIBinding.BaseBinding.Init() in E:\code\ColorMC\src\ColorMC.Gui\UIBinding\BaseBinding.cs:line 85
<Project>
  <PropertyGroup>
    <Configuration>Release</Configuration>
    <Platform>Any CPU</Platform>
    <PublishDir>..\build_out\win-x64-dotnet\</PublishDir>
    <PublishProtocol>FileSystem</PublishProtocol>
    <_TargetId>Folder</_TargetId>
    <TargetFramework>net8.0</TargetFramework>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <SelfContained>true</SelfContained>
    <PublishSingleFile>true</PublishSingleFile>
    <PublishReadyToRun>false</PublishReadyToRun>
    <PublishTrimmed>false</PublishTrimmed>
  </PropertyGroup>
</Project>

Steps to reproduce

image but in AOT is back. image

Perksey commented 2 months ago

First try removing the Platform property - this is implicit now. If that doesn’t work, try setting IncludeNativeLibrariesForSelfExtract to false. If that doesn’t work, try removing your custom publish directory. If that doesn’t work, I’m out of things to suggest.

Coloryr commented 2 months ago

First try removing the Platform property - this is implicit now. If that doesn’t work, try setting IncludeNativeLibrariesForSelfExtract to false. If that doesn’t work, try removing your custom publish directory. If that doesn’t work, I’m out of things to suggest.

IncludeNativeLibrariesForSelfExtract after set false, the file appears, but there are also many files appearing together. How to run it without errors while keeping it is true.

I have found that things like libSkiaSharp.DLL and libHarfBuzzSharp.DLL, packaged together, can still work properly

Perksey commented 2 months ago

If there are other files appearing, they are likely needed and should not be removed. I’m glad setting it to false fixed the issue.

Coloryr commented 2 months ago

Could considered enabling IncludeNativeLibrariesForSelfExtract to work properly?

Perksey commented 2 months ago

There is no appropriate action for us to take in the project itself at this time.