language-ext icon indicating copy to clipboard operation
language-ext copied to clipboard

Issue: Upgrade to language-ext 4.2.8 (codegen) ended in error while build

Open LaszloLueck opened this issue 2 years ago • 14 comments

After updating to laguage-ext 4.2.8 i cannot build any project anymore. Error is CGR1001 CodeGeneration.Roslyn.BuildTime.targets(73, 5): [CGR1001] CodeGeneration.Roslyn.Tool (dotnet-codegen) is not available, code generation won't run. Please check https://github.com/AArnott/CodeGeneration.Roslyn for usage instructions.

I will figure out if it is a specific (sub) library of language-ext

LaszloLueck avatar Jun 27 '22 13:06 LaszloLueck

Here it is a more specific information: Currently the build fails after updating LangguageExt.CodeGen to version 4.2.8 After downgrade to 4.2.7 all works fine

LaszloLueck avatar Jun 27 '22 13:06 LaszloLueck

I’ll check (I have to run a manual step to the codegen package, which I’m sure I ran, but it must have broken somehow).

louthy avatar Jun 27 '22 13:06 louthy

I've checked the package, and it all looks good. Have you done anything differently with this upgrade? Also, make sure these dependencies are on the correct version:

louthy avatar Jun 27 '22 14:06 louthy

Hi, thats crazy. Before, CodeGeneration.Roslyn was implicitly installed as version 0.7.63 CodeGeneration.Roslyn.BuildTime was implicitly installed as version 0.6.1

I´ve downgraded CodeGeneration.Roslyn as you suggested to version 0.6.1 but without luck. Any version combination fails with LanguageExt.CodeGen version 4.2.8

I´ve tested that issue with an new, empty dotnet (6) core console app. Insert the following imports: image

And the build failed. If i downgrade LanguageExt.CodeGen to version 4.2.7 --> the build failed. If i remove the explicit added CodeGeneration.Roslyn CodeGeneration.Roslyn.BuiltTime than the build succeeded. If i changed the implicit imports to the following versions, the build would also be succeeded: image

But, as i update LanguageExt.CodeGen to >4.2.7 the build would failed!

Regards, Laszlo

LaszloLueck avatar Jun 27 '22 19:06 LaszloLueck

Have you recently moved to a new machine? The code-gen library needs the .NET 2.1 SDK to run.

louthy avatar Jun 27 '22 22:06 louthy

No, i´ve not moved or removed to or from a machine. You wrote:

The code-gen library [needs the .NET 2.1 SDK] https://github.com/AArnott/CodeGeneration.Roslyn#prerequisites) to run.

That´s confusing, because the version 4.2.7 does not need the .NET 2.1 SDK (because it is working on my machine)?

Here are some informations about my setup. Ah, and yes, it is on aarm

dotnet --info
.NET SDK (gemäß "global.json"):
 Version:   6.0.301
 Commit:    43f9b18481

Laufzeitumgebung:
 OS Name:     Mac OS X
 OS Version:  12.4
 OS Platform: Darwin
 RID:         osx.12-arm64
 Base Path:   /usr/local/share/dotnet/sdk/6.0.301/

Host (useful for support):
  Version: 6.0.6
  Commit:  7cca709db2

.NET SDKs installed:
  6.0.201 [/usr/local/share/dotnet/sdk]
  6.0.202 [/usr/local/share/dotnet/sdk]
  6.0.203 [/usr/local/share/dotnet/sdk]
  6.0.300 [/usr/local/share/dotnet/sdk]
  6.0.301 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

LaszloLueck avatar Jun 28 '22 06:06 LaszloLueck

No matter what environment (linux, windows, macos, x64, aarm, arm64) I use, the problem is always the same. I´ve created a completely new dotnet core 6 project, use languageext.codegen (4.2.8 or 4.2.9) from nuget and the build fails. If i use languageext.codegen <4.2.8 the build works fine.

LaszloLueck avatar Jun 28 '22 11:06 LaszloLueck

Hmm, does seem odd. Nothing has changed in the CodeGen project. If using an old version works, it'd be best to stick with that for now.

I've frozen development on the CodeGen project, the new Source-Generators based project will eventually take it over and I'll maintain CodeGen in a frozen state for those that can't move over. The only reason the version number keeps going up is because it's part of my standard deployment tooling - it has no dependencies on the other libs, so staying on an old working version won't cause any problems at all.

I will try and find some time over the next few days to take a look though, it does seem a bit strange that it'd just stop working now.

louthy avatar Jun 29 '22 01:06 louthy

Fine for me. 4.2.7 works perfect for me. Maybe someone else has the same problem, then it is already addressed here. Thanks and regards, Laszlo

LaszloLueck avatar Jun 29 '22 20:06 LaszloLueck

I've frozen development on the CodeGen project, the new Source-Generators based project will eventually take it over

@louthy , what is the up-to-date guidelines to integrate the source generations ?

jvmlet avatar Jan 24 '23 09:01 jvmlet

Thank goodness I ran into this thread which caused me to try downgrading to 4.2.7. That finally let me use codegen in a .NET 7 project. I had already tried DOTNET_ROLL_FORWARD=LatestMajor and --roll-forward LatestMajor to no avail (and verified with ProcMon that my msbuild file shenanigans had indeed been properly passed along to the dotnet codegen process). Requiring an older sdk version won't be an option for certain tightly controlled build environments.

DannyMeister avatar Jan 27 '23 22:01 DannyMeister

This way, I can get "[Union]" in the intellisense, and run the app:

    <PackageReference Include="LanguageExt.CodeGen" Version="4.4.3" />
    <PackageReference Include="LanguageExt.Core" Version="4.4.3" />
    <PackageReference Include="CodeGeneration.Roslyn.Tool" Version="0.7.63">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
    </PackageReference>
Though, I have this warning:
Severity	Code	Description	Project	File	Line	Suppression State
Warning	CGR1002	Using GeneratorAssemblySearchPaths is deprecated, please use CodeGenerationRoslynPlugin ItemGroup. See https://github.com/AArnott/CodeGeneration.Roslyn for more info. 
Suppress this warning by adding CGR1002 to MSBuildWarningsAsMessages PropertyGroup.	
MIF1.Modules	C:\Users\YT\.nuget\packages\codegeneration.roslyn.tool\0.7.63\build\CodeGeneration.Roslyn.Tool.targets	40
```	

I honnestly don't know if I would need this: `<Sdk Name="CodeGeneration.Roslyn.Plugin.Sdk" Version="0.7.63" />`

Anyone? @louthy Am I missing something? This doesn't work at all:
`<ItemGroup>
    <PackageReference Include="LanguageExt.Core" Version="3.4.10" />

    <PackageReference Include="LanguageExt.CodeGen" Version="3.4.10"
                      PrivateAssets="all" />

    <PackageReference Include="CodeGeneration.Roslyn.BuildTime"
                      Version="0.6.1"
                      PrivateAssets="all" />

    <DotNetCliToolReference Include="dotnet-codegen" Version="0.6.1" />
</ItemGroup>`

Thanks!

YkTru avatar Jul 27 '23 15:07 YkTru

You need 0.6.1, the later CodeGeneration versions were broken.

louthy avatar Jul 27 '23 15:07 louthy

I am also getting this: CodeGeneration.Roslyn.BuildTime.targets(73, 5): [CGR1001] CodeGeneration.Roslyn.Tool (dotnet-codegen) is not available, code generation won't run. Please check https://github.com/AArnott/CodeGeneration.Roslyn for usage instructions.

I tried setting DOTNET_ROLL_FORWARD=LatestMajor and it did not help.

I also tried downgrading to 4.2.7 as suggested above (https://github.com/louthy/language-ext/issues/1071#issuecomment-1407122047) and it did not work either.

reza-repo avatar Aug 01 '23 22:08 reza-repo