EasyAbp / AbpHelper.CLI

Providing code generation and more features to help you develop applications and modules with the ABP framework.
MIT License
285 stars 95 forks source link

Generate CRUD Error for module solution, and success for app solution #125

Closed davidnasar closed 3 years ago

davidnasar commented 3 years ago

.Net Core 3.1 Abp v3.3.0 (upgrades from v3.1.2) AbpHelper.CLI v0.7 (upgrades from v0.6) AbpHelper.GUI v0.7 (upgrades from v0.6)

Steps:

  1. use abphelper to create a app solution named MyDemo in this path: C:\Programs\Projects\MyDemo;
  2. use abphelper to create a module solution named QAManagement with un-check Create Solution Folder to put into this path: C:\Programs\Projects\MyDemo\modules;
  3. create a simple class named Question in the QAManagement.Domain in C:\Programs\Projects\MyDemo\modules\src\QAManagement.Domain\Questions folder;
  4. Generate CRUD, input Question in the Existing Entity Class, choose Separate Dtos & Skip DB Migrations, then click Execute;
  5. I double confirm there's no multiple XXXMenu.cs files. And as i remembered AbpHelper.GUI v0.6 + AbpHelper.CLI v0.6 won't get error, but when i uninstall those v0.7 things and re-install those v0.6 again, it still gets error like this, use Generate CRUD to generate files for app solution works fine. Don't know why?

-----here's the log------------------------------------------------------------------- %USERPROFILE%.dotnet\tools\abphelper generate crud "Question" -d "C:\Programs\Projects\MyDemo\modules" --separate-dto --skip-db-migrations

Running... [08:12:09 INF] Use directory: C:\Programs\Projects\MyDemo\modules [08:12:10 INF] Command 'crud' started.

[08:12:10 DBG] ProjectInfoProviderStep Input [excludeDirectories]: [08:12:10 DBG] ProjectInfoProviderStep Output [projectInfo]: 'BaseDirectory: C:\Programs\Projects\MyDemo\modules, FullName: QAManagement, Name: QAManagement, TemplateType: Module, UiFramework: RazorPages, Tiered: False'

[08:12:10 DBG] FileFinderStep Input [excludeDirectories]:

[08:12:10 DBG] FileFinderStep Output [filePathName]: Found file: 'C:\Programs\Projects\MyDemo\modules\src\QAManagement.Domain\Questions\Question.cs', stored in parameter: 'FileFinderResult'

[08:12:11 DBG] EntityConstructorsStep Output [modifications]: Modifications count: 2

[08:12:11 DBG] FileModifierStep Input [modifications]: Modifications count: 2

[08:12:11 DBG] TextGenerationStep Input [model]: '{ ProjectInfo = BaseDirectory: C:\Programs\Projects\MyDemo\modules, FullName: QAManagement, Name: QAManagement, TemplateType: Module, UiFramework: RazorPages, Tiered: False, Option = EasyAbp.AbpHelper.Commands.Generate.Crud.CrudCommandOption, EntityInfo = EasyAbp.AbpHelper.Models.EntityInfo, InterfaceInfo = , ClassInfo = , Bag = System.Dynamic.ExpandoObject, DtoInfo = EasyAbp.AbpHelper.Models.DtoInfo }'

[08:12:11 DBG] TextGenerationStep Output [text]: Length: 31

[08:12:11 DBG] TextGenerationStep Input [model]: '{ ProjectInfo = BaseDirectory: C:\Programs\Projects\MyDemo\modules, FullName: QAManagement, Name: QAManagement, TemplateType: Module, UiFramework: RazorPages, Tiered: False, Option = EasyAbp.AbpHelper.Commands.Generate.Crud.CrudCommandOption, EntityInfo = EasyAbp.AbpHelper.Models.EntityInfo, InterfaceInfo = , ClassInfo = , Bag = System.Dynamic.ExpandoObject, DtoInfo = EasyAbp.AbpHelper.Models.DtoInfo }'

[08:12:11 DBG] TextGenerationStep Output [text]: Length: 36

[08:12:11 DBG] FileFinderStep Input [excludeDirectories]:

[08:12:11 DBG] FileFinderStep Output [filePathName]: Found file: 'C:\Programs\Projects\MyDemo\modules\src\QAManagement.EntityFrameworkCore\EntityFrameworkCore\QAManagementDbContext.cs', stored in parameter: 'FileFinderResult'

[08:12:11 DBG] DbContextClassStep Output [modifications]: Modifications count: 2

[08:12:11 DBG] FileModifierStep Input [modifications]: Modifications count: 2

[08:12:11 DBG] FileFinderStep Input [excludeDirectories]:

[08:12:11 DBG] FileFinderStep Output [filePathName]: Found file: 'C:\Programs\Projects\MyDemo\modules\src\QAManagement.EntityFrameworkCore\EntityFrameworkCore\IQAManagementDbContext.cs', stored in parameter: 'FileFinderResult'

[08:12:11 DBG] DbContextInterfaceStep Output [modifications]: Modifications count: 3

[08:12:11 DBG] FileModifierStep Input [modifications]: Modifications count: 3

[08:12:11 DBG] FileFinderStep Input [excludeDirectories]:

[08:12:11 DBG] FileFinderStep Output [filePathName]: Found file: 'C:\Programs\Projects\MyDemo\modules\src\QAManagement.EntityFrameworkCore\EntityFrameworkCore\QAManagementDbContextModelCreatingExtensions.cs', stored in parameter: 'FileFinderResult'

[08:12:11 DBG] DbContextModelCreatingExtensionsStep Output [modifications]: Modifications count: 3

[08:12:11 DBG] FileModifierStep Input [modifications]: Modifications count: 3

[08:12:11 DBG] GroupGenerationStep Input [model]: '{ ProjectInfo = BaseDirectory: C:\Programs\Projects\MyDemo\modules, FullName: QAManagement, Name: QAManagement, TemplateType: Module, UiFramework: RazorPages, Tiered: False, Option = EasyAbp.AbpHelper.Commands.Generate.Crud.CrudCommandOption, EntityInfo = EasyAbp.AbpHelper.Models.EntityInfo, InterfaceInfo = , ClassInfo = , Bag = System.Dynamic.ExpandoObject, DtoInfo = EasyAbp.AbpHelper.Models.DtoInfo }' [08:12:11 DBG] Generating using template file: /Templates/Crud/Groups/Repository/src/{ProjectInfo.FullName}.Domain/{EntityInfo.RelativeDirectory}/I{EntityInfo.Name}Repository.cs [08:12:11 INF] File C:\Programs\Projects\MyDemo\modules/src/QAManagement.Domain/Questions/IQuestionRepository.cs successfully generated. [08:12:11 DBG] Generating using template file: /Templates/Crud/Groups/Repository/src/{ProjectInfo.FullName}.EntityFrameworkCore/{EntityInfo.RelativeDirectory}/{EntityInfo.Name}EfCoreQuerableExtensions.cs [08:12:11 INF] File C:\Programs\Projects\MyDemo\modules/src/QAManagement.EntityFrameworkCore/Questions/QuestionEfCoreQuerableExtensions.cs successfully generated. [08:12:11 DBG] Generating using template file: /Templates/Crud/Groups/Repository/src/{ProjectInfo.FullName}.EntityFrameworkCore/{EntityInfo.RelativeDirectory}/{EntityInfo.Name}Repository.cs [08:12:11 INF] File C:\Programs\Projects\MyDemo\modules/src/QAManagement.EntityFrameworkCore/Questions/QuestionRepository.cs successfully generated.

[08:12:11 DBG] FileFinderStep Input [excludeDirectories]:

[08:12:11 DBG] FileFinderStep Output [filePathName]: Found file: 'C:\Programs\Projects\MyDemo\modules\src\QAManagement.EntityFrameworkCore\EntityFrameworkCore\QAManagementEntityFrameworkCoreModule.cs', stored in parameter: 'FileFinderResult'

[08:12:11 DBG] EntityFrameworkCoreModuleStep Output [modifications]: Modifications count: 2

[08:12:11 DBG] FileModifierStep Input [modifications]: Modifications count: 2

[08:12:11 DBG] GroupGenerationStep Input [model]: '{ ProjectInfo = BaseDirectory: C:\Programs\Projects\MyDemo\modules, FullName: QAManagement, Name: QAManagement, TemplateType: Module, UiFramework: RazorPages, Tiered: False, Option = EasyAbp.AbpHelper.Commands.Generate.Crud.CrudCommandOption, EntityInfo = EasyAbp.AbpHelper.Models.EntityInfo, InterfaceInfo = , ClassInfo = , Bag = System.Dynamic.ExpandoObject, DtoInfo = EasyAbp.AbpHelper.Models.DtoInfo }' [08:12:11 DBG] Generating using template file: /Templates/Crud/Groups/Service/src/{ProjectInfo.FullName}.Application/{EntityInfo.RelativeDirectory}/{EntityInfo.Name}AppService.cs [08:12:11 INF] File C:\Programs\Projects\MyDemo\modules/src/QAManagement.Application/Questions/QuestionAppService.cs successfully generated. [08:12:11 DBG] Generating using template file: /Templates/Crud/Groups/Service/src/{ProjectInfo.FullName}.Application.Contracts/{EntityInfo.RelativeDirectory}/Dtos/{DtoInfo.CreateTypeName}.cs [08:12:11 INF] File C:\Programs\Projects\MyDemo\modules/src/QAManagement.Application.Contracts/Questions/Dtos/CreateQuestionDto.cs successfully generated. [08:12:11 DBG] Generating using template file: /Templates/Crud/Groups/Service/src/{ProjectInfo.FullName}.Application.Contracts/{EntityInfo.RelativeDirectory}/Dtos/{DtoInfo.ReadTypeName}.cs [08:12:11 INF] File C:\Programs\Projects\MyDemo\modules/src/QAManagement.Application.Contracts/Questions/Dtos/QuestionDto.cs successfully generated. [08:12:11 DBG] Generating using template file: /Templates/Crud/Groups/Service/src/{ProjectInfo.FullName}.Application.Contracts/{EntityInfo.RelativeDirectory}/Dtos/{DtoInfo.UpdateTypeName}.cs [08:12:11 INF] File C:\Programs\Projects\MyDemo\modules/src/QAManagement.Application.Contracts/Questions/Dtos/UpdateQuestionDto.cs successfully generated. [08:12:11 DBG] Generating using template file: /Templates/Crud/Groups/Service/src/{ProjectInfo.FullName}.Application.Contracts/{EntityInfo.RelativeDirectory}/Dtos/{EntityInfo.CompositeKeyName}.cs [08:12:11 INF] Evaluated value of SKIP_GENERATE is true, skip generating. [08:12:11 DBG] Generating using template file: /Templates/Crud/Groups/Service/src/{ProjectInfo.FullName}.Application.Contracts/{EntityInfo.RelativeDirectory}/I{EntityInfo.Name}AppService.cs [08:12:11 INF] File C:\Programs\Projects\MyDemo\modules/src/QAManagement.Application.Contracts/Questions/IQuestionAppService.cs successfully generated.

[08:12:11 DBG] FileFinderStep Input [excludeDirectories]:

[08:12:12 DBG] FileFinderStep Output [filePathName]: Found file: 'C:\Programs\Projects\MyDemo\modules\src\QAManagement.Application.Contracts\Permissions\QAManagementPermissions.cs', stored in parameter: 'FileFinderResult'

[08:12:12 DBG] PermissionsStep Output [modifications]: Modifications count: 1

[08:12:12 DBG] FileModifierStep Input [modifications]: Modifications count: 1

[08:12:12 DBG] FileFinderStep Input [excludeDirectories]:

[08:12:12 DBG] FileFinderStep Output [filePathName]: Found file: 'C:\Programs\Projects\MyDemo\modules\src\QAManagement.Application.Contracts\Permissions\QAManagementPermissionDefinitionProvider.cs', stored in parameter: 'FileFinderResult'

[08:12:12 DBG] PermissionDefinitionProviderStep Output [modifications]: Modifications count: 1

[08:12:12 DBG] FileModifierStep Input [modifications]: Modifications count: 1

[08:12:12 DBG] FileFinderStep Input [excludeDirectories]:

[08:12:12 DBG] FileFinderStep Output [filePathName]: Found file: 'C:\Programs\Projects\MyDemo\modules\src\QAManagement.Application\QAManagementApplicationAutoMapperProfile.cs', stored in parameter: 'FileFinderResult'

[08:12:12 DBG] ApplicationAutoMapperProfileStep Output [modifications]: Modifications count: 3

[08:12:12 DBG] FileModifierStep Input [modifications]: Modifications count: 3

[08:12:12 DBG] TextGenerationStep Input [model]: '{ ProjectInfo = BaseDirectory: C:\Programs\Projects\MyDemo\modules, FullName: QAManagement, Name: QAManagement, TemplateType: Module, UiFramework: RazorPages, Tiered: False, Option = EasyAbp.AbpHelper.Commands.Generate.Crud.CrudCommandOption, EntityInfo = EasyAbp.AbpHelper.Models.EntityInfo, InterfaceInfo = , ClassInfo = , Bag = System.Dynamic.ExpandoObject, DtoInfo = EasyAbp.AbpHelper.Models.DtoInfo }'

[08:12:12 DBG] TextGenerationStep Output [text]: Length: 577

[08:12:12 DBG] MultiFileFinderStep Input [excludeDirectories]:

[08:12:12 DBG] MultiFileFinderStep Output [files]: Found files count: 12, stored in parameter: 'MultiFilesFinderResult'

[08:12:12 DBG] GroupGenerationStep Input [model]: '{ ProjectInfo = BaseDirectory: C:\Programs\Projects\MyDemo\modules, FullName: QAManagement, Name: QAManagement, TemplateType: Module, UiFramework: RazorPages, Tiered: False, Option = EasyAbp.AbpHelper.Commands.Generate.Crud.CrudCommandOption, EntityInfo = EasyAbp.AbpHelper.Models.EntityInfo, InterfaceInfo = , ClassInfo = , Bag = System.Dynamic.ExpandoObject, DtoInfo = EasyAbp.AbpHelper.Models.DtoInfo }' [08:12:12 DBG] Generating using template file: /Templates/Crud/Groups/UiRazor/src/{ProjectInfo.FullName}.Web/Pages/{Bag.PagesFolder}/{EntityInfo.RelativeDirectory}/{EntityInfo.Name}/CreateModal.cshtml [08:12:12 INF] File C:\Programs\Projects\MyDemo\modules/src/QAManagement.Web/Pages/QAManagement/Questions/Question/CreateModal.cshtml successfully generated. [08:12:12 DBG] Generating using template file: /Templates/Crud/Groups/UiRazor/src/{ProjectInfo.FullName}.Web/Pages/{Bag.PagesFolder}/{EntityInfo.RelativeDirectory}/{EntityInfo.Name}/CreateModal.cshtml.cs [08:12:12 INF] File C:\Programs\Projects\MyDemo\modules/src/QAManagement.Web/Pages/QAManagement/Questions/Question/CreateModal.cshtml.cs successfully generated. [08:12:12 DBG] Generating using template file: /Templates/Crud/Groups/UiRazor/src/{ProjectInfo.FullName}.Web/Pages/{Bag.PagesFolder}/{EntityInfo.RelativeDirectory}/{EntityInfo.Name}/EditModal.cshtml [08:12:12 INF] File C:\Programs\Projects\MyDemo\modules/src/QAManagement.Web/Pages/QAManagement/Questions/Question/EditModal.cshtml successfully generated. [08:12:12 DBG] Generating using template file: /Templates/Crud/Groups/UiRazor/src/{ProjectInfo.FullName}.Web/Pages/{Bag.PagesFolder}/{EntityInfo.RelativeDirectory}/{EntityInfo.Name}/EditModal.cshtml.cs [08:12:12 INF] File C:\Programs\Projects\MyDemo\modules/src/QAManagement.Web/Pages/QAManagement/Questions/Question/EditModal.cshtml.cs successfully generated. [08:12:12 DBG] Generating using template file: /Templates/Crud/Groups/UiRazor/src/{ProjectInfo.FullName}.Web/Pages/{Bag.PagesFolder}/{EntityInfo.RelativeDirectory}/{EntityInfo.Name}/Index.cshtml [08:12:12 INF] File C:\Programs\Projects\MyDemo\modules/src/QAManagement.Web/Pages/QAManagement/Questions/Question/Index.cshtml successfully generated. [08:12:12 DBG] Generating using template file: /Templates/Crud/Groups/UiRazor/src/{ProjectInfo.FullName}.Web/Pages/{Bag.PagesFolder}/{EntityInfo.RelativeDirectory}/{EntityInfo.Name}/Index.cshtml.cs [08:12:12 INF] File C:\Programs\Projects\MyDemo\modules/src/QAManagement.Web/Pages/QAManagement/Questions/Question/Index.cshtml.cs successfully generated. [08:12:12 DBG] Generating using template file: /Templates/Crud/Groups/UiRazor/src/{ProjectInfo.FullName}.Web/Pages/{Bag.PagesFolder}/{EntityInfo.RelativeDirectory}/{EntityInfo.Name}/ViewModels/CreateEdit{EntityInfo.Name}ViewModel.cs [08:12:12 INF] Evaluated value of SKIP_GENERATE is true, skip generating. [08:12:12 DBG] Generating using template file: /Templates/Crud/Groups/UiRazor/src/{ProjectInfo.FullName}.Web/Pages/{Bag.PagesFolder}/{EntityInfo.RelativeDirectory}/{EntityInfo.Name}/ViewModels/Create{EntityInfo.Name}ViewModel.cs [08:12:12 INF] File C:\Programs\Projects\MyDemo\modules/src/QAManagement.Web/Pages/QAManagement/Questions/Question/ViewModels/CreateQuestionViewModel.cs successfully generated. [08:12:12 DBG] Generating using template file: /Templates/Crud/Groups/UiRazor/src/{ProjectInfo.FullName}.Web/Pages/{Bag.PagesFolder}/{EntityInfo.RelativeDirectory}/{EntityInfo.Name}/ViewModels/Edit{EntityInfo.Name}ViewModel.cs [08:12:12 INF] File C:\Programs\Projects\MyDemo\modules/src/QAManagement.Web/Pages/QAManagement/Questions/Question/ViewModels/EditQuestionViewModel.cs successfully generated. [08:12:12 DBG] Generating using template file: /Templates/Crud/Groups/UiRazor/src/{ProjectInfo.FullName}.Web/Pages/{Bag.PagesFolder}/{EntityInfo.RelativeDirectory}/{EntityInfo.Name}/index.css [08:12:12 INF] File C:\Programs\Projects\MyDemo\modules/src/QAManagement.Web/Pages/QAManagement/Questions/Question/index.css successfully generated. [08:12:12 DBG] Generating using template file: /Templates/Crud/Groups/UiRazor/src/{ProjectInfo.FullName}.Web/Pages/{Bag.PagesFolder}/{EntityInfo.RelativeDirectory}/{EntityInfo.Name}/index.js [08:12:12 INF] File C:\Programs\Projects\MyDemo\modules/src/QAManagement.Web/Pages/QAManagement/Questions/Question/index.js successfully generated.

[08:12:12 DBG] FileFinderStep Input [excludeDirectories]:

[08:12:12 ERR] Error while invoking activity activity-53 of workflow a52e521b2743412583d139b3e27881be System.InvalidOperationException: Sequence contains more than one element at System.Linq.ThrowHelper.ThrowMoreThanOneElementException() at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source) at EasyAbp.AbpHelper.Steps.Common.FileFinderStep.OnExecuteAsync(WorkflowExecutionContext context, CancellationToken cancellationToken) in D:\Repos\EasyAbp\AbpHelper.CLI\src\AbpHelper\Steps\Common\FileFinderStep.cs:line 49 at Elsa.Services.ActivityInvoker.InvokeAsync(WorkflowExecutionContext workflowContext, IActivity activity, Func2 invokeAction) [08:12:12 ERR] Error activity: { "SearchFileName": { "Syntax": "JavaScript", "Expression": "${ProjectInfo.Name}Menus.cs", "Type": "System.String, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e" }, "Name": null }

wakuflair commented 3 years ago

Hi I will check it.

wakuflair commented 3 years ago

I followed your steps and generate successfully.

Are your sure there is only one QAManagementMenus.cs exists? Maybe there is a hidden one in some folder.

davidnasar commented 3 years ago

I clicked folders one by one to check the file duplication. It works fine for a app solution, but throws an error for a module solution in v0.7

wakuflair commented 3 years ago

It's weird. Can you upload your project?

davidnasar commented 3 years ago

OK. It's on my personal laptop at home, so I'll upload the project at 19:00 Time Zone in Singapore (GMT+8) later, then let u know

davidnasar commented 3 years ago

here's mine: https://github.com/davidnasar/MyAbpDemo

wakuflair commented 3 years ago

Hi I found the reason: In ABP v3.3.0+, there is a "Blazor" project in the module template, which contains another "XXXMenu.cs" file. This causes searching menu file error.(ABPHelper expects there is only one) I will fix this in the next version of ABPHelper.

As a workaround, you can delete (or move away) the "QAManagement.Blazor" project, then generating should be ok.

davidnasar commented 3 years ago

Thanks a lot