Closed frblondin closed 5 years ago
CodeGeneration.Roslyn
should have as few dependencies as possible.Overall it seems there's a problem in the dependency loading, although I thought it was already resolved.
I've created a minimal repro solution for reference and easier investigation: https://github.com/amis92/CodeGeneration.Roslyn-dependency-problem-repro
Thanks for your help @amis92 .
While debugging CodeGeneration.Roslyn.Tool
I think I've a better understanding of the cause of the problem. I set a breakpoint here and while inspecting I could see that the Microsoft.CodeAnalysis.Workspaces
name does not exactly exists as a NuGet dependency. The NuGet package name is Microsoft.CodeAnalysis.Workspaces.Common
. See this picture:
The only way is apparently to check the RuntimeAssemblyGroups.AssetPaths file names. I tested it locally and it seems to work fine.
I will submit a PR.
In order to create some syntax nodes I'm trying to add more NuGet dependencies to my custom generator project. More specifically I want to use some methods provided by CSharpSyntaxGenerator.cs from the Microsoft.CodeAnalysis.CSharp.Workspaces NuGet package - such as TypedConstantExpression(TypedConstant value).
When I test the code generator from unit tests it works perfectly well. When I'm running the build on a project which uses the generator it fails with the following error:
My understanding is that dotnet-codegen will only load the assemblies using this resolver. I don't know how to make sure that the additional dependencies I'm adding to my generator will work when executed by
<DotNetCliToolReference Include="dotnet-codegen" Version="0.4.88" />
.My questions:
<DotNetCliToolReference Include="dotnet-codegen" Version="0.4.88" />
?