From 15de3fc6b1aa383cbf73770a704a73f8916ee71b Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 28 Jul 2022 15:12:07 +0800 Subject: [PATCH] Allow to create with MAUI in ABP CLI --- docs/en/CLI-New-Command-Samples.md | 2 +- docs/en/CLI.md | 1 + .../Abp/Cli/Commands/ProjectCreationCommandBase.cs | 2 ++ .../Volo/Abp/Cli/ProjectBuilding/Building/MobileApp.cs | 5 ++++- .../ProjectBuilding/Templates/App/AppTemplateBase.cs | 10 ++++++++++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/en/CLI-New-Command-Samples.md b/docs/en/CLI-New-Command-Samples.md index 614fb24a5f..26d098c98e 100644 --- a/docs/en/CLI-New-Command-Samples.md +++ b/docs/en/CLI-New-Command-Samples.md @@ -1,6 +1,6 @@ # ABP CLI - New Solution Sample Commands -The `abp new` command creates an ABP solution or other artifacts based on an ABP template. [ABP CLI](CLI.md) has several parameters to create a new ABP solution. In this document we will show you some sample commands to create a new solution. All the project names are `Acme.BookStore`. Currently, the only available mobile project is a `React Native` mobile app. Available database providers are `Entity Framework Core` and `MongoDB`. All the commands starts with `abp new`. +The `abp new` command creates an ABP solution or other artifacts based on an ABP template. [ABP CLI](CLI.md) has several parameters to create a new ABP solution. In this document we will show you some sample commands to create a new solution. All the project names are `Acme.BookStore`. Currently, the available mobile projects are `React Native` and `MAUI` mobile app. Available database providers are `Entity Framework Core` and `MongoDB`. All the commands starts with `abp new`. ## Angular diff --git a/docs/en/CLI.md b/docs/en/CLI.md index ffde52eff0..8dc6d425dc 100644 --- a/docs/en/CLI.md +++ b/docs/en/CLI.md @@ -124,6 +124,7 @@ For more samples, go to [ABP CLI Create Solution Samples](CLI-New-Command-Sample * `--separate-auth-server`: The Identity Server project comes as a separate project and runs at a different endpoint. It separates the Identity Server from the API Host application. If not specified, you will have a single endpoint in the server side. * `--mobile` or `-m`: Specifies the mobile application framework. If not specified, no mobile application will be created. Available options: * `react-native`: React Native. + * `maui`: MAUI. * `--database-provider` or `-d`: Specifies the database provider. Default provider is `ef`. Available providers: * `ef`: Entity Framework Core. * `mongodb`: MongoDB. diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs index 026b4ca48c..a30b16ee41 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs @@ -493,6 +493,8 @@ public abstract class ProjectCreationCommandBase return MobileApp.None; case "react-native": return MobileApp.ReactNative; + case "maui": + return MobileApp.Maui; default: throw new CliUsageException(ExceptionMessageHelper.GetInvalidOptionExceptionMessage("Mobile App")); } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/MobileApp.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/MobileApp.cs index 882cb9166c..641740bce0 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/MobileApp.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/MobileApp.cs @@ -7,7 +7,8 @@ namespace Volo.Abp.Cli.ProjectBuilding.Building; public enum MobileApp { None, - ReactNative + ReactNative, + Maui } public static class MobileAppExtensions @@ -18,6 +19,8 @@ public static class MobileAppExtensions { case MobileApp.ReactNative: return "react-native"; + case MobileApp.Maui: + return "MAUI"; } throw new Exception("Mobile app folder name is not set!"); diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs index fb1fc79399..397a35222a 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs @@ -5,6 +5,7 @@ using NuGet.Versioning; using Volo.Abp.Cli.Commands; using Volo.Abp.Cli.ProjectBuilding.Building; using Volo.Abp.Cli.ProjectBuilding.Building.Steps; +using Volo.Abp.Cli.ProjectBuilding.Templates.Maui; using Volo.Abp.Cli.ProjectBuilding.Templates.Microservice; namespace Volo.Abp.Cli.ProjectBuilding.Templates.App; @@ -161,6 +162,15 @@ public abstract class AppTemplateBase : TemplateInfo steps.Add(new RemoveFolderStep(MobileApp.ReactNative.GetFolderName().EnsureStartsWith('/'))); } + if (context.BuildArgs.MobileApp == MobileApp.Maui) + { + steps.Add(new MauiChangeApplicationIdGuidStep()); + } + else + { + steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Maui")); + } + if (!context.BuildArgs.PublicWebSite) { steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web.Public"));