From be2bb4ba274657e325c71a2d03f69843518c5d08 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Thu, 9 May 2019 14:49:05 +0300 Subject: [PATCH] Split add-package and add-module commands. --- .../Volo/Abp/Cli/AbpCliCoreModule.cs | 1 + .../Abp/Cli/Args/CommandLineArgumentParser.cs | 6 +- .../Volo/Abp/Cli/CliService.cs | 28 ++-- .../Volo/Abp/Cli/CliUsageException.cs | 19 +++ .../Volo/Abp/Cli/Commands/AddCommandHelper.cs | 20 +-- .../Volo/Abp/Cli/Commands/AddModuleCommand.cs | 91 +++++++++--- .../Abp/Cli/Commands/AddPackageCommand.cs | 110 ++++++++++++++ .../Volo/Abp/Cli/Utils/PathHelper.cs | 23 +++ .../Volo/Abp/Cli/Utils/VersionHelper.cs | 15 ++ .../Abp/ProjectBuilding/ProjectBuilder.cs | 3 +- .../Abp/ProjectModification/AddModuleArgs.cs | 26 ---- .../Abp/ProjectModification/ModuleAdder.cs | 137 ------------------ 12 files changed, 264 insertions(+), 215 deletions(-) create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliUsageException.cs create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddPackageCommand.cs create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/PathHelper.cs create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/VersionHelper.cs delete mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectModification/AddModuleArgs.cs delete mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectModification/ModuleAdder.cs diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs index 101e9134d7..c1894b2e6b 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs @@ -22,6 +22,7 @@ namespace Volo.Abp.Cli { options.Commands["help"] = typeof(HelpCommand); options.Commands["new"] = typeof(NewCommand); + options.Commands["add-package"] = typeof(AddPackageCommand); options.Commands["add-module"] = typeof(AddModuleCommand); options.Commands["login"] = typeof(LoginCommand); options.Commands["logout"] = typeof(LogoutCommand); diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs index 7125699546..1dd29e5df7 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs @@ -16,7 +16,7 @@ namespace Volo.Abp.Cli.Args var argumentList = args.ToList(); - //Get command + //Command var command = argumentList[0]; argumentList.RemoveAt(0); @@ -26,7 +26,7 @@ namespace Volo.Abp.Cli.Args return new CommandLineArgs(command); } - //Get target + //Target var target = argumentList[0]; if (target.StartsWith("-")) @@ -43,7 +43,7 @@ namespace Volo.Abp.Cli.Args return new CommandLineArgs(command, target); } - //Get options + //Options var commandLineArgs = new CommandLineArgs(command, target); diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs index 854eabea96..40629a17c7 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliService.cs @@ -1,28 +1,22 @@ using System; -using System.Reflection; using Microsoft.Extensions.DependencyInjection; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Volo.Abp.Cli.Args; using Volo.Abp.Cli.Commands; +using Volo.Abp.Cli.Utils; using Volo.Abp.DependencyInjection; -using Volo.Abp.ProjectBuilding; namespace Volo.Abp.Cli { public class CliService : ITransientDependency { - //public static string Version => typeof(AbpCliCoreModule).Assembly - // .GetFileVersion() - // .RemovePostFix(".0"); - public static string Version => "0.17.0.0"; - public ILogger Logger { get; set; } protected ICommandLineArgumentParser CommandLineArgumentParser { get; } protected ICommandSelector CommandSelector { get; } - public IHybridServiceScopeFactory ServiceScopeFactory { get; } + protected IHybridServiceScopeFactory ServiceScopeFactory { get; } public CliService( ICommandLineArgumentParser commandLineArgumentParser, @@ -38,8 +32,8 @@ namespace Volo.Abp.Cli public async Task RunAsync(string[] args) { - Logger.LogInformation("ABP CLI (abp.io)"); - Logger.LogInformation("Version: " + Version); + Logger.LogInformation($"ABP CLI, version {VersionHelper.Version}."); + Logger.LogInformation("https://abp.io"); var commandLineArgs = CommandLineArgumentParser.Parse(args); var commandType = CommandSelector.Select(commandLineArgs); @@ -47,7 +41,19 @@ namespace Volo.Abp.Cli using (var scope = ServiceScopeFactory.CreateScope()) { var command = (IConsoleCommand)scope.ServiceProvider.GetRequiredService(commandType); - await command.ExecuteAsync(commandLineArgs); + + try + { + await command.ExecuteAsync(commandLineArgs); + } + catch (CliUsageException usageException) + { + Logger.LogWarning(usageException.Message); + } + catch (Exception ex) + { + Logger.LogException(ex); + } } } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliUsageException.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliUsageException.cs new file mode 100644 index 0000000000..5ce2b7a1b3 --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliUsageException.cs @@ -0,0 +1,19 @@ +using System; + +namespace Volo.Abp.Cli +{ + public class CliUsageException : Exception + { + public CliUsageException(string message) + : base(message) + { + + } + + public CliUsageException(string message, Exception innerException) + : base(message, innerException) + { + + } + } +} diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddCommandHelper.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddCommandHelper.cs index 0704ecdbf3..d1b5c9d716 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddCommandHelper.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddCommandHelper.cs @@ -4,24 +4,6 @@ namespace Volo.Abp.Cli.Commands { public static class AddCommandHelper { - public static void WriteUsage(ILogger logger) - { - logger.LogWarning(""); - logger.LogWarning("'add' command is used to add a module to a solution or to a project."); - logger.LogWarning("Use in a solution folder to add a multi-package module to a solution."); - logger.LogWarning("Use in a project folder to add a single-package module to a project."); - logger.LogWarning(""); - logger.LogWarning("Usage:"); - logger.LogWarning(" abp add [-s|--solution] [-p|--project]"); - logger.LogWarning(""); - logger.LogWarning("Options:"); - logger.LogWarning(" -s|--solution Specify solution file explicitly."); - logger.LogWarning(" -p|--project Specify project file explicitly."); - logger.LogWarning(""); - logger.LogWarning("Examples:"); - logger.LogWarning(" abp add Volo.Abp.TenantManagement Adds tenant management module packages to the solution."); - logger.LogWarning(" abp add Volo.Abp.FluentValidation Adds a single module package to the project."); - logger.LogWarning(""); - } + } } \ No newline at end of file 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 6c5209c2e4..68204389f1 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 @@ -1,7 +1,11 @@ -using Microsoft.Extensions.Logging; +using System; +using System.IO; +using System.Text; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using System.Threading.Tasks; using Volo.Abp.Cli.Args; +using Volo.Abp.Cli.Utils; using Volo.Abp.DependencyInjection; using Volo.Abp.ProjectModification; @@ -11,11 +15,11 @@ namespace Volo.Abp.Cli.Commands { public ILogger Logger { get; set; } - protected ModuleAdder ModuleAdder { get; } + protected SolutionModuleAdder SolutionModuleAdder { get; } - public AddModuleCommand(ModuleAdder moduleAdder) + public AddModuleCommand(SolutionModuleAdder solutionModuleAdder) { - ModuleAdder = moduleAdder; + SolutionModuleAdder = solutionModuleAdder; Logger = NullLogger.Instance; } @@ -23,18 +27,75 @@ namespace Volo.Abp.Cli.Commands { if (commandLineArgs.Target == null) { - Logger.LogWarning("Module name is missing."); - AddCommandHelper.WriteUsage(Logger); - return; + throw new CliUsageException("Module name is missing!" + Environment.NewLine + Environment.NewLine + GetUsageInfo()); } - await ModuleAdder.AddModuleAsync( - new AddModuleArgs( - commandLineArgs.Target, - commandLineArgs.Options.GetOrNull(Options.Solution.Short, Options.Solution.Long), - commandLineArgs.Options.GetOrNull(Options.Project.Short, Options.Project.Long) + await SolutionModuleAdder.AddAsync( + GetSolutionFile(commandLineArgs), + commandLineArgs.Target + ); + } + + private string GetSolutionFile(CommandLineArgs commandLineArgs) + { + var providedSolutionFile = PathHelper.NormalizePath( + commandLineArgs.Options.GetOrNull( + AddPackageCommand.Options.Project.Short, + AddPackageCommand.Options.Project.Long ) ); + + if (!providedSolutionFile.IsNullOrWhiteSpace()) + { + return providedSolutionFile; + } + + var foundSolutionFiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.sln"); + if (foundSolutionFiles.Length == 1) + { + return foundSolutionFiles[0]; + } + + if (foundSolutionFiles.Length == 0) + { + throw new CliUsageException("'abp add-module' command should be used inside a folder contaning a .sln file!"); + } + + //foundSolutionFiles.Length > 1 + + var sb = new StringBuilder("There are multiple solution (.sln) files in the current directory. Please specify one of the files below:"); + + foreach (var foundSolutionFile in foundSolutionFiles) + { + sb.AppendLine("* " + foundSolutionFile); + } + + sb.AppendLine("Example:"); + sb.AppendLine($"abp add-module {commandLineArgs.Target} -p {foundSolutionFiles[0]}"); + + throw new CliUsageException(sb.ToString()); + } + + protected virtual string GetUsageInfo() + { + var sb = new StringBuilder(); + + sb.AppendLine(""); + sb.AppendLine("'add-module' command is used to add a multi-package ABP module to a solution."); + sb.AppendLine("It should be used in a folder containing a .sln file."); + sb.AppendLine(""); + sb.AppendLine("Usage:"); + sb.AppendLine(" abp add-module [-s|--solution]"); + sb.AppendLine(""); + sb.AppendLine("Options:"); + sb.AppendLine(" -s|--solution Specify the solution file explicitly."); + sb.AppendLine(""); + sb.AppendLine("Examples:"); + sb.AppendLine(" abp add Volo.Blogging Adds the module to the current soluton."); + sb.AppendLine(" abp add Volo.Blogging -s Acme.BookStore Adds the module to the given soluton."); + sb.AppendLine(""); + + return sb.ToString(); } public static class Options @@ -44,12 +105,6 @@ namespace Volo.Abp.Cli.Commands public const string Short = "s"; public const string Long = "solution"; } - - public static class Project - { - public const string Short = "p"; - public const string Long = "project"; - } } } } diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddPackageCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddPackageCommand.cs new file mode 100644 index 0000000000..842a07fd64 --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/AddPackageCommand.cs @@ -0,0 +1,110 @@ +using System; +using System.IO; +using System.Text; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Volo.Abp.Cli.Args; +using Volo.Abp.Cli.Utils; +using Volo.Abp.DependencyInjection; +using Volo.Abp.ProjectModification; + +namespace Volo.Abp.Cli.Commands +{ + public class AddPackageCommand : IConsoleCommand, ITransientDependency + { + public ILogger Logger { get; set; } + + protected ProjectNugetPackageAdder ProjectNugetPackageAdder { get; } + + public AddPackageCommand(ProjectNugetPackageAdder projectNugetPackageAdder) + { + ProjectNugetPackageAdder = projectNugetPackageAdder; + Logger = NullLogger.Instance; + } + + public virtual async Task ExecuteAsync(CommandLineArgs commandLineArgs) + { + if (commandLineArgs.Target == null) + { + throw new CliUsageException("Package name is missing!" + Environment.NewLine + Environment.NewLine + GetUsageInfo()); + } + + await ProjectNugetPackageAdder.AddAsync( + GetProjectFile(commandLineArgs), + commandLineArgs.Target + ); + } + + protected virtual string GetProjectFile(CommandLineArgs commandLineArgs) + { + var providedProjectFile = PathHelper.NormalizePath( + commandLineArgs.Options.GetOrNull( + Options.Project.Short, + Options.Project.Long + ) + ); + + if (!providedProjectFile.IsNullOrWhiteSpace()) + { + return providedProjectFile; + } + + var foundProjectFiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.csproj"); + if (foundProjectFiles.Length == 1) + { + return foundProjectFiles[0]; + } + + if (foundProjectFiles.Length == 0) + { + throw new CliUsageException("'abp add-package' command should be used inside a folder contaning a .csproj file!"); + } + + //foundProjectFiles.Length > 1 + + var sb = new StringBuilder("There are multiple project (.csproj) files in the current directory. Please specify one of the files below:"); + + foreach (var foundProjectFile in foundProjectFiles) + { + sb.AppendLine("* " + foundProjectFile); + } + + sb.AppendLine("Example:"); + sb.AppendLine($"abp add-package {commandLineArgs.Target} -p {foundProjectFiles[0]}"); + + throw new CliUsageException(sb.ToString()); + } + + protected virtual string GetUsageInfo() + { + var sb = new StringBuilder(); + + sb.AppendLine(""); + sb.AppendLine("'add-package' command is used to add an ABP package to a project."); + sb.AppendLine("It should be used in a folder containing a .csproj file."); + sb.AppendLine(""); + sb.AppendLine("Usage:"); + sb.AppendLine(" abp add-package [-p|--project]"); + sb.AppendLine(""); + sb.AppendLine("Options:"); + sb.AppendLine(" -p|--project Specify the project file explicitly."); + sb.AppendLine(""); + sb.AppendLine("Examples:"); + sb.AppendLine(" abp add Volo.Abp.FluentValidation Adds the package to the current project."); + sb.AppendLine(" abp add Volo.Abp.FluentValidation -p Acme.BookStore.Application Adds the package to the given project."); + sb.AppendLine(""); + + return sb.ToString(); + } + + public static class Options + { + public static class Project + { + public const string Short = "p"; + public const string Long = "project"; + } + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/PathHelper.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/PathHelper.cs new file mode 100644 index 0000000000..eeb1751c84 --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/PathHelper.cs @@ -0,0 +1,23 @@ +using System.IO; +using JetBrains.Annotations; + +namespace Volo.Abp.Cli.Utils +{ + public static class PathHelper + { + public static string NormalizePath([CanBeNull] string path) + { + if (string.IsNullOrEmpty(path)) + { + return path; + } + + if (Path.IsPathRooted(path)) + { + return path; + } + + return Path.Combine(Directory.GetCurrentDirectory(), path); + } + } +} diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/VersionHelper.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/VersionHelper.cs new file mode 100644 index 0000000000..c57c447822 --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/VersionHelper.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; + +namespace Volo.Abp.Cli.Utils +{ + public static class VersionHelper + { + //public static string Version => typeof(AbpCliCoreModule).Assembly + // .GetFileVersion() + // .RemovePostFix(".0"); + public static string Version => "0.17.0.0"; + } +} diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs index 3a5c7a6b8a..100ed6a7ff 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectBuilding/ProjectBuilder.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using Volo.Abp.Cli; +using Volo.Abp.Cli.Utils; using Volo.Abp.DependencyInjection; using Volo.Abp.ProjectBuilding.Building; @@ -31,7 +32,7 @@ namespace Volo.Abp.ProjectBuilding } } - var version = CliService.Version; + var version = VersionHelper.Version; var templateFile = await TemplateStore.GetAsync(args.TemplateName, version); diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectModification/AddModuleArgs.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectModification/AddModuleArgs.cs deleted file mode 100644 index eba87227f3..0000000000 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectModification/AddModuleArgs.cs +++ /dev/null @@ -1,26 +0,0 @@ -using JetBrains.Annotations; - -namespace Volo.Abp.ProjectModification -{ - public class AddModuleArgs - { - [NotNull] - public string ModuleName { get; set; } - - [CanBeNull] - public string SolutionFile { get; set; } - - [CanBeNull] - public string ProjectFile { get; set; } - - public AddModuleArgs( - [NotNull] string moduleName, - [CanBeNull] string solutionFile = null, - [CanBeNull] string projectFile = null) - { - ModuleName = Check.NotNullOrWhiteSpace(moduleName, nameof(moduleName)); - SolutionFile = solutionFile; - ProjectFile = projectFile; - } - } -} diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectModification/ModuleAdder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectModification/ModuleAdder.cs deleted file mode 100644 index d6da6fea68..0000000000 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/ProjectModification/ModuleAdder.cs +++ /dev/null @@ -1,137 +0,0 @@ -using JetBrains.Annotations; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Volo.Abp.Cli.Commands; -using Volo.Abp.DependencyInjection; - -namespace Volo.Abp.ProjectModification -{ - public class ModuleAdder : ITransientDependency - { - public ILogger Logger { get; set; } - - protected ProjectNugetPackageAdder ProjectNugetPackageAdder { get; } - protected SolutionModuleAdder SolutionModuleAdder { get; } - - public ModuleAdder(ProjectNugetPackageAdder projectNugetPackageAdder, SolutionModuleAdder solutionModuleAdder) - { - ProjectNugetPackageAdder = projectNugetPackageAdder; - SolutionModuleAdder = solutionModuleAdder; - - Logger = NullLogger.Instance; - } - - public async Task AddModuleAsync(AddModuleArgs args) - { - ValidateArgs(args); - NormalizeArgs(args); - - if (args.ProjectFile.IsNullOrEmpty() && args.SolutionFile.IsNullOrEmpty()) - { - if (!TryToFillProjectOrSolutionName(args)) - { - Logger.LogWarning("Could not find any project (.csproj) or solution (.sln) file in the current directory!"); - AddCommandHelper.WriteUsage(Logger); - return; - } - } - - if (!args.ProjectFile.IsNullOrEmpty()) - { - await ProjectNugetPackageAdder.AddAsync(args.ProjectFile, args.ModuleName); - } - - if (!args.SolutionFile.IsNullOrEmpty()) - { - await SolutionModuleAdder.AddAsync(args.SolutionFile, args.ModuleName); - } - } - - private bool TryToFillProjectOrSolutionName(AddModuleArgs args) - { - var projectFiles = FindFiles(Directory.GetCurrentDirectory(), ".csproj"); - if (projectFiles.Length == 1) - { - args.ProjectFile = projectFiles.First(); - return true; - } - - if (projectFiles.Length > 1) - { - Logger.LogWarning( - "There are multiple project (.csproj) files in the current directory. Please specify one of the files below:"); - foreach (var projectFile in projectFiles) - { - Logger.LogWarning("* " + projectFile); - } - - Logger.LogWarning("Example:"); - Logger.LogWarning($"abp add {args.ModuleName} -p {projectFiles[0]}"); - return false; - } - - var solutionFiles = FindFiles(Directory.GetCurrentDirectory(), ".sln"); - if (solutionFiles.Length == 1) - { - args.SolutionFile = solutionFiles.First(); - return true; - } - - if (solutionFiles.Length > 1) - { - Logger.LogWarning( - "There are multiple solution (.sln) files in the current directory. Please specify one of the files below:"); - foreach (var solutionFile in solutionFiles) - { - Logger.LogWarning("* " + solutionFile); - } - - Logger.LogWarning("Example:"); - Logger.LogWarning($"abp add {args.ModuleName} -s {solutionFiles[0]}"); - } - - return false; - } - - private void ValidateArgs(AddModuleArgs args) - { - if (!args.ProjectFile.IsNullOrEmpty() && - !args.SolutionFile.IsNullOrEmpty()) - { - throw new ArgumentException("Can not specify a solution name and project name together."); - } - } - - private void NormalizeArgs(AddModuleArgs args) - { - args.ProjectFile = NormalizePath(args.ProjectFile); - args.SolutionFile = NormalizePath(args.SolutionFile); - } - - private static string NormalizePath([CanBeNull] string path) - { - if (string.IsNullOrEmpty(path)) - { - return path; - } - - if (Path.IsPathRooted(path)) - { - return path; - } - - return Path.Combine(Directory.GetCurrentDirectory(), path); - } - - - private string[] FindFiles(string directory, string fileExtension) - { - return Directory.GetFiles(directory, "*" + fileExtension); - } - } -}