AArnott / CodeGeneration.Roslyn

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

Nothing works #111

Closed MdmrBerlin closed 5 years ago

MdmrBerlin commented 5 years ago

Whitch status have this project?

Ready for use, alpha or beta?

I tryed the readme steps, downloadet the CodeGeneration.Roslyn.Walkthrough and another example. There is actual no way to compile the projects or generate code, also the the example projects. Maybe your documentation and example projects are out of date?

amis92 commented 5 years ago

Hello, can you provide a little more context, e.g. what version of Visual Studio are you using?

I've updated the walkthrough (see PR: https://github.com/jaredthirsk/CodeGeneration.Roslyn.Walkthrough/pull/2) for 0.4.88 and it does work for me under VS2017 v15.9.5 (latest).

jaredthirsk commented 5 years ago

I haven't looked at this in a while. I merged the PR but maybe I shouldn't have -- I can't get it to work. It looks like dotnet codegen is missing? 0.4.11 had DLL code in nuget: ~.nuget\packages\codgeneration.roslyn.buildtime\0.4.11\build\net45 and ...\netstandard1.5, but under 0.4.88\build, these folders don't even exist!?

Here is my log to attempt to rebuild:

1>------ Rebuild All started: Project: Walkthrough.Generators, Configuration: Debug Any CPU ------
1>Walkthrough.Generators -> e:\dev\CodeGeneration.Roslyn.Walkthrough\bin\Walkthrough.Generators\Debug\net462\Walkthrough.Generators.dll
1>Walkthrough.Generators -> e:\dev\CodeGeneration.Roslyn.Walkthrough\bin\Walkthrough.Generators\Debug\netstandard1.6\Walkthrough.Generators.dll
2>------ Rebuild All started: Project: Walkthrough.Foo, Configuration: Debug Any CPU ------
2>Version for package `dotnet-codegen` could not be resolved.
2>C:\Users\ja\.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.
2>Version for package `dotnet-codegen` could not be resolved.
2>C:\Users\ja\.nuget\packages\codegeneration.roslyn.buildtime\0.4.88\build\CodeGeneration.Roslyn.BuildTime.targets(59,5): warning MSB3073: The command "dotnet codegen "@e:\dev\CodeGeneration.Roslyn.Walkthrough\src\..\obj\Walkthrough.Foo\Debug\net462\Walkthrough.Foo.csproj.dotnet-codegen.rsp"" exited with code 1.
2>C:\Users\ja\.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.
2>Foo.cs(10,28,10,32): error CS0246: The type or namespace name 'FooA' could not be found (are you missing a using directive or an assembly reference?)
2>Done building project "Walkthrough.Foo.csproj" -- FAILED.
2>Version for package `dotnet-codegen` could not be resolved.
2>C:\Users\ja\.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.
2>Version for package `dotnet-codegen` could not be resolved.
2>C:\Users\ja\.nuget\packages\codegeneration.roslyn.buildtime\0.4.88\build\CodeGeneration.Roslyn.BuildTime.targets(59,5): warning MSB3073: The command "dotnet codegen "@e:\dev\CodeGeneration.Roslyn.Walkthrough\src\..\obj\Walkthrough.Foo\Debug\netstandard1.6\Walkthrough.Foo.csproj.dotnet-codegen.rsp"" exited with code 1.
2>C:\Users\ja\.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.
2>Foo.cs(10,28,10,32): error CS0246: The type or namespace name 'FooA' could not be found (are you missing a using directive or an assembly reference?)
2>Done building project "Walkthrough.Foo.csproj" -- FAILED.
3>------ Rebuild All started: Project: FooUser, Configuration: Debug Any CPU ------
3>CSC : error CS0006: Metadata file 'e:\dev\CodeGeneration.Roslyn.Walkthrough\bin\Walkthrough.Foo\Debug\netstandard1.6\Walkthrough.Foo.dll' could not be found
3>Done building project "FooUser.csproj" -- FAILED.
3>CSC : error CS0006: Metadata file 'e:\dev\CodeGeneration.Roslyn.Walkthrough\bin\Walkthrough.Foo\Debug\net462\Walkthrough.Foo.dll' could not be found
3>Done building project "FooUser.csproj" -- FAILED.
========== Rebuild All: 1 succeeded, 2 failed, 0 skipped ==========
jaredthirsk commented 5 years ago
NuGet package restore finished.
Time Elapsed: 00:00:00.9341625
========== Finished ==========

NU1603: dotnet-codegen-netcoreapp2.2-[0.4.12, ) depends on dotnet-codegen (>= 0.4.12) but dotnet-codegen 0.4.12 was not found. An approximate best match of dotnet-codegen 0.4.37 was resolved.
NU1603: dotnet-codegen 0.4.37 depends on System.CommandLine (>= 0.1.0-e170407-3) but System.CommandLine 0.1.0-e170407-3 was not found. An approximate best match of System.CommandLine 1.0.0.1 was resolved.
NU1102: Unable to find package CodeGeneration.Roslyn with version (>= 1.0.0)
  - Found 22 version(s) in api.nuget.org [ Nearest version: 0.4.88 ]
  - Found 0 version(s) in Microsoft Visual Studio Offline Packages
NuGet package restore failed. Please see Error List window for detailed warnings and errors.
Time Elapsed: 00:00:09.3663684
========== Finished ==========

Time Elapsed: 00:00:00.2954482
========== Finished ==========

NuGet package restore failed. Please see Error List window for detailed warnings and errors.
Time Elapsed: 00:00:01.4044432
========== Finished ==========

Time Elapsed: 00:00:01.0255837
========== Finished ==========
jaredthirsk commented 5 years ago

Update: I got the https://github.com/jaredthirsk/CodeGeneration.Roslyn.Walkthrough solution compiling. I remember I had uninstalled a VS2017 preview recently, and noticed I didn't have .NET Core 2.0 SDK installed (it is past end of life -- I have several newer SDKs installed, including 2.1, 2.2, 3.0-preview). I went to install it and it thought it was already installed, so I did a repair. Now the Walkthrough builds in VS 2019 preview, and VS 2017. So there could have been something broken on my machine, or perhaps 2.0 SDK is needed (if so, that should probably be changed because it is past EOL).

amis92 commented 5 years ago

Yes, it's true that the experience (when no SDK 2.0) is bad. There's the thing called prefercliruntime but it's undocumented and I do not know if this'll work or what it does :)

jaredthirsk commented 5 years ago

Can you just easily upgrade this repo to depend upon a newer (non-EOL / non-obsolete) SDK?

amis92 commented 5 years ago

(I'm not the owner of CG.R) Well, the thing is that we'd need to upgrade the tool for each new SDK version, which is just bad. Probably using prefercliruntime we'd "declare" ourselves compatible with the running/available SDK so that we could work for more targets. :<

AArnott commented 5 years ago

Thanks, @amis92. I have no objection to targeting a newer .NET Core if someone can send a PR to update that (and @amis92's new documentation to match :smile:).