I have an ASP.NET Core project that targets net5.0. That project depends on a library that targets netstandard2.1, net5.0 and net8.0. When I build the project on a build machine that only has an SDK for 5.0, I get the following error:
Error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0. Either target .NET 5.0 or lower, or use a version of the .NET SDK that supports .NET 8.0.
I acknowledge that the library targets a framework that is not available on the build machine, but the build revolves around a net5.0 project, and as such it should include the library project and build it targeting net5.0.
I cannot discard the net8.0 target from the library: it is that way to support newer projects, and also as a first step towards migrating away from .NET 5 (which obviously can’t happen today).
I’ve already tried adding the --framework net5.0
flag to the build step, but with no success.
Am I getting something wrong about the target frameworks? How can I fix this?