jamescourtney / FlatSharp

Fast, idiomatic C# implementation of Flatbuffers
Apache License 2.0
497 stars 50 forks source link

flatsharp.compiler 7.x requires net6.0 SDK #408

Closed dorny closed 9 months ago

dorny commented 11 months ago

We have a project using FlatSharp with the build integration:

    <ItemGroup>
        <FlatSharpSchema Include="Internal\Model\model.fbs" />
    </ItemGroup>

After updating our project to net7.0 our CI pipeline failed with the following error:

/root/.nuget/packages/flatsharp.compiler/7.1.0/build/FlatSharp.Compiler.targets(123,9): error : You must install or update .NET to run this application.

Looks like the flatsharp.compiler requires the net6.0 SDK even when the project targets net7.0. It's not a big deal for local development, however for CI builds it's common to use builder images with only a single SDK version available:

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build

For now we used a workaround to install also the previous SDK version:

RUN wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb; \
    dpkg -i packages-microsoft-prod.deb; \
    apt update -y; \
    apt install dotnet-sdk-6.0 -y

How much is compiler package bound to net6.0? Would be possible to upgrade it to use net7.0 or use whichever SDK version is available?

P.S.: Thanks for your work, this package is awesome 👍

dorny commented 11 months ago

The .nuspec references only net6 files:

 <file src="$OutDir$\net6.0\**" target="tools/net6.0" />

Could this be fixed simply by adding the net7 output? https://github.com/jamescourtney/FlatSharp/blob/main/src/FlatSharp.Compiler/FlatSharp.Compiler.nuspec#L20

jamescourtney commented 11 months ago

I actually used to ship the compiler targeting a ton of different frameworks, but this led to issues because I had to have installed-sdk detection in my targets file and it got messy, including breaking when a new .NET version shipped. My solution was to just snap to the LTS version of .NET and just state that up-front as a requirement.

Does your CI environment not easily let you install multiple versions? In Github actions I can easily install multiple SDK versions and at work in Azure DevOps it's also pretty easy to install multiple versions.

wolfman42 commented 9 months ago

As a related question, are the plans to update to / support .NET 8 any time soon?

jamescourtney commented 9 months ago

Yes, there are plans for .NET 8. I'm currently working on it locally. There won't be any profound changes, but there are a few things that .NET 8 complains about in terms of compiler warnings that I'm working around.

The most substantial change will be that FlatSharp will detect installed SDKs and use the correct version of the compiler.

jamescourtney commented 9 months ago

Fixed in 7.4.0