diff --git a/docs/en/CLI.md b/docs/en/CLI.md index dd3287ce12..3825f5884c 100644 --- a/docs/en/CLI.md +++ b/docs/en/CLI.md @@ -180,7 +180,8 @@ abp add-module Volo.Blogging * `--solution` or `-s`: Specifies the solution (.sln) file path. If not specified, CLI tries to find a .sln file in the current directory. * `--skip-db-migrations`: For EF Core database provider, it automatically adds a new code first migration (`Add-Migration`) and updates the database (`Update-Database`) if necessary. Specify this option to skip this operation. * `-sp` or `--startup-project`: Relative path to the project folder of the startup project. Default value is the current folder. -* `--with-source-code`: Add source code of the module instead of NuGet/NPM packages. +* `--with-source-code`: Downloads the source code of the module to your solution folder and uses local project references instead of NuGet/NPM packages. +* `--add-to-solution-file`: Adds the downloaded project to your solution file, so you will also see the projects of the module in your solution when you open it on a IDE. (only available when `--with-source-code` is used.) ### get-source diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddModuleCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddModuleCommand.cs index 5e690d8bb0..02eac070c8 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddModuleCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddModuleCommand.cs @@ -36,7 +36,8 @@ namespace Volo.Abp.Cli.Commands ); } - var withSourceCode = commandLineArgs.Options.ContainsKey("with-source-code"); + var withSourceCode = commandLineArgs.Options.ContainsKey(Options.SourceCode.Long); + var addSourceCodeToSolutionFile = withSourceCode && commandLineArgs.Options.ContainsKey("add-to-solution-file"); var skipDbMigrations = Convert.ToBoolean( commandLineArgs.Options.GetOrNull(Options.DbMigrations.Skip) ?? "false"); @@ -55,7 +56,8 @@ namespace Volo.Abp.Cli.Commands commandLineArgs.Options.GetOrNull(Options.StartupProject.Short, Options.StartupProject.Long), version, skipDbMigrations, - withSourceCode + withSourceCode, + addSourceCodeToSolutionFile ); } @@ -71,7 +73,8 @@ namespace Volo.Abp.Cli.Commands sb.AppendLine(" abp add-module [options]"); sb.AppendLine(""); sb.AppendLine("Options:"); - sb.AppendLine(" --with-source-code Downloads the source code of the module and adds it to your solution."); + sb.AppendLine(" --with-source-code Downloads the source code of the module to your solution folder."); + sb.AppendLine(" --add-to-solution-file Adds the downloaded project to your solution file. (only available when --with-source-code used)"); sb.AppendLine(" -s|--solution Specify the solution file explicitly."); sb.AppendLine(" --skip-db-migrations Specify if a new migration will be added or not."); sb.AppendLine(" -sp|--startup-project Relative path to the project folder of the startup project. Default value is the current folder."); @@ -158,6 +161,11 @@ namespace Volo.Abp.Cli.Commands public const string Short = "sp"; public const string Long = "startup-project"; } + + public static class SourceCode + { + public const string Long = "with-source-code"; + } } } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs index e4c4c655f7..4cbeb2ba26 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs @@ -68,7 +68,8 @@ namespace Volo.Abp.Cli.ProjectModification string startupProject, string version, bool skipDbMigrations = false, - bool withSourceCode = false) + bool withSourceCode = false, + bool addSourceCodeToSolutionFile = false) { Check.NotNull(solutionFile, nameof(solutionFile)); Check.NotNull(moduleName, nameof(moduleName)); @@ -85,7 +86,12 @@ namespace Volo.Abp.Cli.ProjectModification { var modulesFolderInSolution = Path.Combine(Path.GetDirectoryName(solutionFile), "modules"); await DownloadSourceCodesToSolutionFolder(module, modulesFolderInSolution, version); - await SolutionFileModifier.AddModuleToSolutionFileAsync(module, solutionFile); + + if (addSourceCodeToSolutionFile) + { + await SolutionFileModifier.AddModuleToSolutionFileAsync(module, solutionFile); + } + await NugetPackageToLocalReferenceConverter.Convert(module, solutionFile); await AddAngularSourceCode(modulesFolderInSolution, solutionFile); }