amis92 / RecordGenerator

C# immutable records generator
https://amis92.github.io/RecordGenerator/
MIT License
72 stars 10 forks source link

doesn't work with dotnet aspnet-codegenerator #141

Open pgrm opened 4 years ago

pgrm commented 4 years ago

Hello, when I run dotnet aspnet-codegenerator identity I get errors, that it can't find the auto generated constructors. Specifically: Failed to compile the project in memory

Building project ...
Finding the generator 'identity'...
Running the generator 'identity'...
Failed to compile the project in memory
/Users/peter/dev/.../File1.cs(50,21): error CS1729: 'YourClass' does not contain a constructor that takes 2 arguments
/Users/peter/dev/.../File2.cs(48,36): error CS1729: 'YourClass' does not contain a constructor that takes 2 arguments
   at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b__6_0()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
   at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)

dotnet build works of course, so I'm wondering if this is an issue with the aspnet-codegenerator tool chain, or rather with the way the RecordGenerator registers itself for the builds.

Thanks for your help

amis92 commented 4 years ago

Hi. I haven't used dotnet asp-codegenerator, but indeed indeed, there will always be issues when you use two different code generation frameworks.

RecordGenerator uses CodeGeneration.Roslyn underneath: https://github.com/AArnott/CodeGeneration.Roslyn

I won't have time to debug how aspnet-codegenerator runs MSBuild targets, but it should be possible. Have you tried building the project via dotnet build and then running dotnet aspnet-codegenerator identity --no-build?

pgrm commented 4 years ago

@amis92 thx for getting back to me, yes we tried that, and it's still saying Failed to compile the project in memory - the aspnet-generator is different from yours, as it should be rather similar to ef core migrations (which by the way work just fine), in the sense that the aspnet-generator should simply scaffold some views / models / ... which will be afterwards committed into the repository.

Ok, I'll get in touch with the repository where the generator is hosted and ask there as well 😃

12345-daredevil commented 9 months ago

@pgrm Hello. I have this problem too. How did you solve this error?