How to include native binaries in the build?

SoundFlow library/plugin seems to work well for adding to Flax Engine’s audio modifying/filtering capabilities. However …

Adding SoundFlow.dll to the .Build.cs file options includes it in the build.

options.ScriptingAPI.FileReferences.Add(Path.Combine(FolderPath, “..”, “..”, “Content/SoundFlow.dll”));

However, including the platform specific Miniaudio.dll the same way shows error.

error CS0009: Metadata file ‘C:\Projects\Project_AUDIO\Content\miniaudio.dll’ could not be opened – PE image doesn’t contain managed metadata.

When copying that file manually to the build Content folderworks and audio plays. Likely there is a different way to include it, but how?


Perhaps relevant info:

SoundFlow was installed with Visual Studio / NuGet. There are references to both .dll files. eg in file:

C:\Projects\Project_AUDIO\Cache\Intermediate\GameEditorTarget\Windows\x64\Debug\CSharp\Game.assets.cache

C:\Users\Administrator.nuget\packages\soundflow\1.4.1\runtimes\win-arm64\native\miniaudio.dll

and in:

C:\Projects\Project_AUDIO\Plugins\soundflow.1.4.1\SoundFlow.targets

    <RuntimeTargets Include="$(MSBuildThisFileDirectory)..\runtimes\win-x64\native\libminiaudio.dll" AssetKind="Native">
        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        <RuntimeIdentifier>win-x64</RuntimeIdentifier>
        <OutputPath>miniaudio.dll</OutputPath>

That’s for C# libraries. Native files are included via options.DependencyFiles.Add() or other, depending on usage see docs: Flax.Build | Flax Documentation

Thanks again for your continued help! :+1:

Interestingly, found the page that you linked a few hours before your reply and tried some of the option properties that seeemd related. Some threw errors, others compiled without errors … but miniaudio.dll wasn’t copied.

Stopped right after trying options.DependencyFiles.Add() because it did copy miniaudio.dll successfully to the build folder and audio was playing fine. But wanted to wait for conformation in case it’s one of those situations where the approach “somehow” works … but there could issues later. Or perhaps something else might also need to be set.

For example: How to deal with 32-bit and 64-bit versions. Out of curiosity, added both options.DependencyFiles.Add() … but only one seemed to have been copied to the build folder.
Encountered a few software launchers in the past that seemed to include both 32-bit and 64-bit.
Or perhaps, the simplest answer is to create separate builds? Or perhaps, is it even relevant nowadays to have a 32-bit version for a video game?

Just to confirm, including the proper platform specific miniaudio.dll file can be done by adding Preprocessor Defines to the Game.Build.cs file, right?