Closed Malgefor closed 2 weeks ago
To elaborate a bit more on why the dependency on the deprecated package isn't great: if you want to run the codegen tool in your build you need to .NET Core 2.1 SDK installed on the machine / Docker image to be able to build. So when building a .NET 5 project, you still need 2.1.
If you don't have the 2.1 SDK you will get errors along the lines of:
.nuget/packages/codegeneration.roslyn.buildtime/0.6.1/build/CodeGeneration.Roslyn.BuildTime.targets(61,5): warning MSB3073: The command "dotnet codegen --version" exited with code 150.
.nuget/packages/codegeneration.roslyn.buildtime/0.6.1/build/CodeGeneration.Roslyn.BuildTime.targets(61,5): warning MSB4181: The "Exec" task returned false but did not log an error.
.nuget/packages/codegeneration.roslyn.buildtime/0.6.1/build/CodeGeneration.Roslyn.BuildTime.targets(73,5): error 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.
To fix this you have to install the .NET Core 2.1 SDK, which goes out of support August 2021. (https://dotnet.microsoft.com/platform/support/policy/dotnet-core)
Example config of installing the 2.1 SDK in a Docker file:
FROM mcr.microsoft.com/dotnet/sdk:5.0-focal AS build
COPY --from=mcr.microsoft.com/dotnet/sdk:2.1-focal /usr/share/dotnet /usr/share/dotnet
you should not need 2.1 sdk. try to define roll forward policy https://github.com/AArnott/CodeGeneration.Roslyn/issues/180#issuecomment-562895670
Ah you are right! Thanks for pointing that out : ) Missed that when I was trying to get the codegen tool to work.
Regarding the original question, yes, I will be updating the CodeGen to use Source Generators. I'm super overloaded with other projects at the moment, so I'm having to keep my interaction with LangExt at a minimum for a while, so it probably won't be for a month or so.
you should not need 2.1 sdk. try to define roll forward policy
In my case, it was required to install the runtime 2.1. Installing the SDK was not enough.
Hi, I'm totally new to LanguageExt and tried to setup the codegen functionality as mentioned in the wiki. But I do have the same problem as other in that I can't get it to work with my .NET6 SDK. I saw there was no activity here for 6 months. Is this still on the roadmap, @louthy ?
@bmargula: Installing .NET 2.1 (SDK or runtime, don't know) on your developer machine (and your build server) should be enough to make codegen working as documented. This is not a runtime dependency for your binaries. Your project can target e.g. net60. It's working fine with latest LanguageExt, too.
you should not need 2.1 sdk. try to define roll forward policy AArnott/CodeGeneration.Roslyn#180 (comment)
Have you tried this? After I set the rollforwardpolicy as an environment variable it worked without having to install the 2.1 sdk/runtime
Hi!
I am using the LanguageExt.CodeGen package to generate Discriminated Unions. However, the dependency https://github.com/AArnott/CodeGeneration.Roslyn is marked as deprecated in the repo.
Are there plans to use the Source Generators (https://devblogs.microsoft.com/dotnet/introducing-c-source-generators/) for the CodeGen package?
Cheers