Skip to content

How can we avoid problems with different .NET versions? What's the best way to distribute the compiler? #886

@lock9

Description

@lock9

Hi,

One issue we almost always see when testing C# with new developers is errors related to .NET versions. You may not notice this because you likely have multiple .NET versions installed.

Situation:
During a test, a user had .NET 8 installed and had to install .NET 7 to use the compiler. According to his report, he tried to install the compiler using the dotnet tool. It failed because he didn't have .NET 7.0. He had to install it to use the compiler.

Questions:

  • Shouldn't it be backward compatible?
  • Is this a problem with how we distribute the compiler?
  • If we distribute it as a simple DLL, will a .NET 7 DLL work if invoked using .NET 8?

In order to allow the compiler to be automatically downloaded, we were adding it to the NuGet dependencies and invoking it like this in the post build process:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>net7.0</TargetFramework>
        <NeoCompilerCSharpVersion>3.6.2</NeoCompilerCSharpVersion>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="Neo.SmartContract.Framework" Version="$(NeoCompilerCSharpVersion)" />
        <PackageReference Include="Neo.Compiler.CSharp" Version="$(NeoCompilerCSharpVersion)" />
    </ItemGroup>
    <Target Name="PostBuild" AfterTargets="PostBuildEvent">
        <Exec Command="dotnet $(NuGetPackageRoot)neo.compiler.csharp/$(NeoCompilerCSharpVersion)/tools/$(TargetFramework)/any/nccs.dll $(ProjectDir)" />
    </Target>
</Project>

Note: I have .NET 7.0 installed.
However, this used to work.. I guess? Or we were using some other dll. What I know is that today, it doesn't work:

The error:

Coin.csproj : error NU1202: Package Neo.Compiler.CSharp 3.6.2 is not compatible with net7.0 (.NETCoreApp,Version=v7.0). Package Neo.Compiler.CSharp 3.6.2 supports: net7.0 (.NETCoreApp,Version=v7.0) 

And this error:

error NU1212: Invalid project-package combination for Neo.Compiler.CSharp 3.6.2. DotnetToolReference project style can only contain references of the DotnetTool type

I'm not really sure what the problem is or how to solve it. Even writing this message was hard for me. Can someone enlighten me?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions