I'm trying to make a CD for a library that uses Bond. It compiles perfectly locally but it seems like I can't compile it in a Docker image. I'm getting the error below. It suggests that I need to install Bond tools. I can't find an image that would have them installed and I also can't find the way to install them. (I did try apt-get
and nuget install
.) The Bond GitHub project only shows how to compile them. How can I solve that?
I'm using the image mcr.microsoft.com/dotnet/sdk. It compiles everything that don't contain Bond very well.
MSBuild version 17.5.0-preview-23061-01+040e2a90e for .NET
Determining projects to restore...
Restored /var/workdir/aaa/bbb.csproj (in 11.23 sec).
/bin/sh: 2: /tmp/MSBuildTemproot/tmp07e2245471a6416d99ff3965ff6cc96e.exec.cmd: /app/.nuget/packages/bond.csharp/9.0.5/build/../tools/gbc.exe: Exec format error
/app/.nuget/packages/bond.csharp/9.0.5/build/Common.targets(161,5): error MSB3073: The command ""/app/.nuget/packages/bond.csharp/9.0.5/build/../tools/gbc.exe" c# --import-dir="/app/.nuget/packages/bond.csharp/9.0.5/build/../tools/inc" --jobs=-2 --namespace=bond=Bond --output-dir="obj/Release/netstandard2.1/" --using="DateTime=System.DateTime" @"obj/Release/netstandard2.1/bonddefaultcodegen.in"" exited with code 126. [/var/workdir/aaa/bbb.csproj]
Build FAILED.```
It looks like you are trying to run the Windows version of gbc on Linux. As of March 2023, there is no pre-compiled version of gbc for Linux. The gbc included in the NuGet packages is only for Windows.
You will need to compile gbc yourself targeting Linux following the instructions in Bond's README and set the environment variable (or MSBuild property) BOND_COMPILER_PATH
to the path to the directory that contains the gbc that you have built.
This is a known gap in Bond's tooling. See its GitHub issue #940, gbc for Linux? for more details.