コード例 #1
0
ファイル: ModuleAdder.cs プロジェクト: wyaow/abp
        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);
            }
        }
コード例 #2
0
ファイル: ModuleAdder.cs プロジェクト: wyaow/abp
 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.");
     }
 }
コード例 #3
0
ファイル: ModuleAdder.cs プロジェクト: wyaow/abp
        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);
        }
コード例 #4
0
ファイル: ModuleAdder.cs プロジェクト: wyaow/abp
 private void NormalizeArgs(AddModuleArgs args)
 {
     args.ProjectFile  = NormalizePath(args.ProjectFile);
     args.SolutionFile = NormalizePath(args.SolutionFile);
 }