Gurobi’s .sol
file is not the same as IBM’s:
But sure, there are probably solver-specific ways of writing a solution file, but none that are solver-independent.
You’re better off writing something like this:
import JSON
solution = Dict(name(x) => value(x) for x in all_variables(model))
write("solution.json", JSON.json(solution))