sasik
✅ Creating a cross-platform csproj supporting any .NET and any platform -linux,osx,amd64,arm64
Hello, I have a project that I would like to be able to run on any machine, from linux/amd64 with mono installed to (dated) linux/amd64 with dotnet 5 to osx/amd64 and osx/arm64 with the latest dotnet 7.
To be more specific, what I would like to achieve:
- when I type
dotnet build/test/run
, I would like to run it using the current platform and any available framework (I can safely assume there is just one)
- when I type dotnet publish
it is published as a self-contained application
My current csproj (excerpt)
And if the csproj is publishable, then I add also this:
Issues:
- this lets me only handle .NET 4.6.1 (which I use via mono), .NET 5 and .NET 6. It won't work on .NET 7
strange thing here: <RollForward>
(I've played with Major
, LatestMajor
) works if .NET 6 is installed but it doesn't work when .NET 7 is the only available runtime . Does it mean, that RollForward
is only able to bump the major version by 1?
- it doesn't work on osx. I have to manually change the <RuntimeIdentifier>
- differently for osx/arm64 and for osx/amd64
How to do this well?8 replies