I'm working with GDAL to get the ElevationMap of GeoTIFF files in an .NET6 / Visual Studio 2022 environment.
In the Debug or Release everything works fine (there is a ./gdal subfolder in the bin-folder).
When I publish the application with dotnet publish, the ./gdal subfolder doesn't exist in the publish-folder. So the native gdal DLL's can't be found.
How do I get the gdal-subfolder to be copied to the publish-folder as well?
I use this command:
dotnet publish -c Release -r win-x64 --self-contained true --output C:\publish MySolution.sln
I tried to reference the GDAL.Native package in the startup project too, but it didn't help.
Update: I finally solved the problem by this code in the project file:
<Target Name="PublishGDAL" AfterTargets="Publish">
<Exec Command="move $(OutputPath)\gdal $(PublishDir)" />
</Target>