AArnott / CodeGeneration.Roslyn

Assists in performing Roslyn-based code generation during a build.
Microsoft Public License
408 stars 59 forks source link

dotnetcore: Version for package dotnet-codegen could not be resolved #121

Closed avonheimburg closed 5 years ago

avonheimburg commented 5 years ago

I am sorry if I abuse this as a support forum. I am having trouble getting a project using a code generator to work under Linux (necessary for our build infrastructure).

I can compile the codegenerator project itself just fine, but when I try to build a project that uses that, I get

Version for package `dotnet-codegen` could not be resolved.
/home/anno/.nuget/packages/codegeneration.roslyn.buildtime/0.4.88/build/CodeGeneration.Roslyn.BuildTime.targets(47,5): warning MSB3073: The command "dotnet codegen --version" exited with code 1. [/home/anno/Workspace/lib-cs-immutable/src/ImmutableExt.Test/ImmutableExt.Test.csproj]
Version for package `dotnet-codegen` could not be resolved.
/home/anno/.nuget/packages/codegeneration.roslyn.buildtime/0.4.88/build/CodeGeneration.Roslyn.BuildTime.targets(59,5): warning MSB3073: The command "dotnet codegen "@obj/Debug/netcoreapp2.2/ImmutableExt.Test.csproj.dotnet-codegen.rsp"" exited with code 1. [/home/anno/Workspace/lib-cs-immutable/src/ImmutableExt.Test/ImmutableExt.Test.csproj]
/home/anno/.nuget/packages/codegeneration.roslyn.buildtime/0.4.88/build/CodeGeneration.Roslyn.BuildTime.targets(61,5): warning CGR1000: dotnet-codegen: Failed to generate the list of generated files. The tool didn't run succesfully. Please check https://github.com/AArnott/CodeGeneration.Roslyn for usage instructions. [/home/anno/Workspace/lib-cs-immutable/src/ImmutableExt.Test/ImmutableExt.Test.csproj]

... and the subsequent compilation failures because of the missing generated files, of course.

Installed sdks.

2.1.504 [/usr/share/dotnet/sdk]
2.2.104 [/usr/share/dotnet/sdk]

The dotnet-codegen.dll exists, trying to run it manually yields another error (though that may be fine):

$ dotnet /home/anno/.nuget/packages/dotnet-codegen/0.4.88/lib/netcoreapp2.0/dotnet-codegen.dll 

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'CodeGeneration.Roslyn, Version=0.4.0.0, Culture=neutral, PublicKeyToken=ec41cf4c17a5eaf3'. The system cannot find the file specified.

Aborted (core dumped)

I have tried targeting netcoreapp2.0, netcoreapp2.1 and netcoreapp2.2 - all with the same result. Any pointers on where to go from here?

AArnott commented 5 years ago

@amis92 can you help?

amis92 commented 5 years ago

Question 1: Have you followed README? Often-missed point is the <DotNetCliToolReference> element in https://github.com/AArnott/CodeGeneration.Roslyn#apply-code-generation

Question 2: If still not working: Can you check whether https://github.com/jaredthirsk/CodeGeneration.Roslyn.Walkthrough builds for you?

Question 3: If still not working: Can you provide output of your dotnet --info?

amis92 commented 5 years ago

Closing because OP didn't follow up.