RecordGenerator icon indicating copy to clipboard operation
RecordGenerator copied to clipboard

doesn't work with dotnet aspnet-codegenerator

Open pgrm opened this issue 4 years ago • 3 comments

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

pgrm avatar Aug 20 '20 06:08 pgrm

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?

amis92 avatar Aug 20 '20 09:08 amis92

@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 😃

pgrm avatar Aug 22 '20 13:08 pgrm

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

12345-daredevil avatar Dec 16 '23 18:12 12345-daredevil