-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Hey Ryan, great library, thank you for creating and maintaining it.
I think I have discovered an issue with the current dll resolver path (for windows) that occurs when an application using FreeTypeSharp is invoked dynamically by a dotnet tool (in my case the MonoGame Content Builder (mgcb)).
For context I have written a custom MonoGame Content Pipeline that uses FreeTypeSharp to generate a font atlas (that I think produces a higher quality font rendering than the built-in MonoGame SpriteFont). Custom pipeline assemblies are dynamically loaded by the mgcb tool to compile game assets. I have been able to successfully create the code to generate the font atlas, however when the pipeline tool invokes my custom pipeline it doesn't resolve the freetype.dll files correctly.
The issue occurs when the custom pipeline assembly (using FreeTypeSharp as a nuget package) is loaded and invoked at runtime by another process (the mgcb tool). In that scenario the AppContext.BaseDirectory points to the tool path, rather than the path where packaged FreeTypeSharp.dll and the freetype.dll files reside.
In my case the string rootDirectory = AppContext.BaseDirectory; points to C:\Users\OliverCardwell\.nuget\packages\dotnet-mgcb\3.8.4\tools\net8.0\any, rather than the expected location of the FreeTypeSharp.dll published alongside my custom pipeline assembly.
A possible solution is to use string rootDirectory = Path.GetDirectoryName(typeof(FT).Assembly.Location); instead to get the root directory for the dll search paths. By changing to this I have been able to get FreeTypeSharp to correctly locate the correct freetype.dll files that are installed alongside the FreeTypeSharp nuget package.
Thoughts?