Ejemplo n.º 1
0
        public async Task UpdateSolutionAsync(string solutionPath, bool includePreviews = false, bool includeReleaseCandidates = false, bool switchToStable = false, bool checkAll = false)
        {
            var projectPaths = ProjectFinder.GetProjectFiles(solutionPath);

            if (checkAll)
            {
                Task.WaitAll(projectPaths.Select(projectPath => UpdateInternalAsync(projectPath, includePreviews, includeReleaseCandidates, switchToStable)).ToArray());
            }
            else
            {
                var latestVersionFromNuget = await _nuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Core", includeReleaseCandidates : includeReleaseCandidates);

                var latestReleaseCandidateVersionFromNuget = await _nuGetService.GetLatestVersionOrNullAsync("Volo.Abp.Core", includeReleaseCandidates : true);

                var latestVersionFromMyGet = await GetLatestVersionFromMyGet("Volo.Abp.Core");

                async Task UpdateAsync(string filePath)
                {
                    var fileContent    = File.ReadAllText(filePath);
                    var updatedContent = await UpdateVoloPackagesAsync(fileContent,
                                                                       includePreviews,
                                                                       includeReleaseCandidates,
                                                                       switchToStable,
                                                                       latestVersionFromNuget,
                                                                       latestReleaseCandidateVersionFromNuget,
                                                                       latestVersionFromMyGet);

                    File.WriteAllText(filePath, updatedContent);
                }

                Task.WaitAll(projectPaths.Select(UpdateAsync).ToArray());
            }
        }
Ejemplo n.º 2
0
        public virtual async Task AddAsync(
            [NotNull] string solutionFile,
            [NotNull] string moduleName,
            string startupProject,
            string version,
            bool skipDbMigrations = false,
            bool withSourceCode   = false)
        {
            Check.NotNull(solutionFile, nameof(solutionFile));
            Check.NotNull(moduleName, nameof(moduleName));

            var module = await FindModuleInfoAsync(moduleName);

            Logger.LogInformation($"Installing module '{module.Name}' to the solution '{Path.GetFileNameWithoutExtension(solutionFile)}'");

            var projectFiles = ProjectFinder.GetProjectFiles(solutionFile);

            await AddNugetAndNpmReferences(module, projectFiles);

            if (withSourceCode)
            {
                var modulesFolderInSolution = Path.Combine(Path.GetDirectoryName(solutionFile), "modules");
                await DownloadSourceCodesToSolutionFolder(module, modulesFolderInSolution, version);

                await SolutionFileModifier.AddModuleToSolutionFileAsync(module, solutionFile);

                await NugetPackageToLocalReferenceConverter.Convert(module, solutionFile);

                await HandleAngularProject(modulesFolderInSolution, solutionFile);
            }

            ModifyDbContext(projectFiles, module, startupProject, skipDbMigrations);
        }
Ejemplo n.º 3
0
        public void UpdateSolution(string solutionPath, bool includePreviews)
        {
            var projectPaths = ProjectFinder.GetProjectFiles(solutionPath);

            foreach (var filePath in projectPaths)
            {
                UpdateInternal(filePath, includePreviews);
            }
        }
Ejemplo n.º 4
0
        public void UpdateSolution(string solutionPath, string newVersion)
        {
            var projectPaths = ProjectFinder.GetProjectFiles(solutionPath);

            foreach (var filePath in projectPaths)
            {
                UpdateInternal(filePath, newVersion);
            }
        }
Ejemplo n.º 5
0
        public async Task UpdateSolutionAsync(string solutionPath, bool includePreviews = false, bool switchToStable = false)
        {
            var projectPaths = ProjectFinder.GetProjectFiles(solutionPath);

            foreach (var filePath in projectPaths)
            {
                await UpdateInternalAsync(filePath, includePreviews, switchToStable);
            }
        }
Ejemplo n.º 6
0
        public async Task UpdateSolutionAsync(string solutionPath, bool includePreviews)
        {
            var projectPaths = ProjectFinder.GetProjectFiles(solutionPath);

            foreach (var filePath in projectPaths)
            {
                await UpdateInternalAsync(filePath, includePreviews).ConfigureAwait(false);
            }
        }
Ejemplo n.º 7
0
        public virtual async Task AddAsync(
            [NotNull] string solutionFile,
            [NotNull] string moduleName,
            string version,
            bool skipDbMigrations            = false,
            bool withSourceCode              = false,
            bool addSourceCodeToSolutionFile = false,
            bool newTemplate    = false,
            bool newProTemplate = false)
        {
            Check.NotNull(solutionFile, nameof(solutionFile));
            Check.NotNull(moduleName, nameof(moduleName));

            var module = await GetModuleInfoAsync(moduleName, newTemplate, newProTemplate);

            module = RemoveIncompatiblePackages(module, version);

            Logger.LogInformation(
                $"Installing module '{module.Name}' to the solution '{Path.GetFileNameWithoutExtension(solutionFile)}'");

            var projectFiles = ProjectFinder.GetProjectFiles(solutionFile);

            await AddNugetAndNpmReferences(module, projectFiles, !(newTemplate || newProTemplate));

            if (withSourceCode || newTemplate || newProTemplate)
            {
                var modulesFolderInSolution = Path.Combine(Path.GetDirectoryName(solutionFile), "modules");
                await DownloadSourceCodesToSolutionFolder(module, modulesFolderInSolution, version, newTemplate, newProTemplate);
                await RemoveUnnecessaryProjectsAsync(Path.GetDirectoryName(solutionFile), module, projectFiles);

                if (addSourceCodeToSolutionFile)
                {
                    await SolutionFileModifier.AddModuleToSolutionFileAsync(module, solutionFile);
                }

                if (newTemplate || newProTemplate)
                {
                    await NugetPackageToLocalReferenceConverter.Convert(module, solutionFile, $"{module.Name}.");
                }
                else
                {
                    await NugetPackageToLocalReferenceConverter.Convert(module, solutionFile);
                }

                await AddAngularSourceCode(modulesFolderInSolution, solutionFile, module.Name, newTemplate || newProTemplate);
            }
            else
            {
                await AddAngularPackages(solutionFile, module);
            }

            await RunBundleForBlazorAsync(projectFiles, module);

            ModifyDbContext(projectFiles, module, skipDbMigrations);
        }
Ejemplo n.º 8
0
        private string GetProjectFile(string solutionFile, NugetPackageInfo package)
        {
            var projectFiles     = Directory.GetFiles(Path.GetDirectoryName(solutionFile), "*.csproj", SearchOption.AllDirectories);
            var isSolutionTiered = IsSolutionTiered(projectFiles);

            var projectFile = ProjectFinder.FindNuGetTargetProjectFile(
                projectFiles,
                isSolutionTiered && package.TieredTarget != NuGetPackageTarget.Undefined
                    ? package.TieredTarget
                    : package.Target);

            return(projectFile);
        }
Ejemplo n.º 9
0
        private async Task AddNugetAndNpmReferences(ModuleWithMastersInfo module, string[] projectFiles,
                                                    bool useDotnetCliToInstall)
        {
            var webPackagesWillBeAddedToBlazorServerProject = SouldWebPackagesBeAddedToBlazorServerProject(module, projectFiles);

            foreach (var nugetPackage in module.NugetPackages)
            {
                var nugetTarget =
                    await IsProjectTiered(projectFiles) && nugetPackage.TieredTarget != NuGetPackageTarget.Undefined
                        ? nugetPackage.TieredTarget
                        : nugetPackage.Target;

                if (webPackagesWillBeAddedToBlazorServerProject && nugetTarget == NuGetPackageTarget.Web)
                {
                    nugetTarget = NuGetPackageTarget.BlazorServer;
                }

                var targetProjectFile = ProjectFinder.FindNuGetTargetProjectFile(projectFiles, nugetTarget);
                if (targetProjectFile == null)
                {
                    Logger.LogDebug($"Target project is not available for this NuGet package '{nugetPackage.Name}'");
                    continue;
                }

                await ProjectNugetPackageAdder.AddAsync(null, targetProjectFile, nugetPackage, null, useDotnetCliToInstall);
            }

            var mvcNpmPackages = module.NpmPackages?.Where(p => p.ApplicationType.HasFlag(NpmApplicationType.Mvc))
                                 .ToList();

            if (!mvcNpmPackages.IsNullOrEmpty())
            {
                var targetProjects = ProjectFinder.FindNpmTargetProjectFile(projectFiles);
                if (targetProjects.Any())
                {
                    NpmGlobalPackagesChecker.Check();

                    foreach (var targetProject in targetProjects)
                    {
                        foreach (var npmPackage in mvcNpmPackages)
                        {
                            await ProjectNpmPackageAdder.AddMvcPackageAsync(Path.GetDirectoryName(targetProject), npmPackage);
                        }
                    }
                }
                else
                {
                    Logger.LogDebug("Target project is not available for NPM packages.");
                }
            }
        }
Ejemplo n.º 10
0
        public virtual async Task AddAsync(
            [NotNull] string solutionFile,
            [NotNull] string moduleName,
            string startupProject,
            bool skipDbMigrations = false)
        {
            Check.NotNull(solutionFile, nameof(solutionFile));
            Check.NotNull(moduleName, nameof(moduleName));

            var module = await FindModuleInfoAsync(moduleName).ConfigureAwait(false);

            Logger.LogInformation($"Installing module '{module.Name}' to the solution '{Path.GetFileNameWithoutExtension(solutionFile)}'");

            var projectFiles = ProjectFinder.GetProjectFiles(solutionFile);

            foreach (var nugetPackage in module.NugetPackages)
            {
                var targetProjectFile = ProjectFinder.FindNuGetTargetProjectFile(projectFiles, nugetPackage.Target);
                if (targetProjectFile == null)
                {
                    Logger.LogDebug($"Target project is not available for this NuGet package '{nugetPackage.Name}'");
                    continue;
                }

                await ProjectNugetPackageAdder.AddAsync(targetProjectFile, nugetPackage).ConfigureAwait(false);
            }

            if (!module.NpmPackages.IsNullOrEmpty())
            {
                var targetProjects = ProjectFinder.FindNpmTargetProjectFile(projectFiles);
                if (targetProjects.Any())
                {
                    NpmGlobalPackagesChecker.Check();

                    foreach (var targetProject in targetProjects)
                    {
                        foreach (var npmPackage in module.NpmPackages.Where(p => p.ApplicationType.HasFlag(NpmApplicationType.Mvc)))
                        {
                            await ProjectNpmPackageAdder.AddAsync(Path.GetDirectoryName(targetProject), npmPackage).ConfigureAwait(false);
                        }
                    }
                }
                else
                {
                    Logger.LogDebug("Target project is not available for NPM packages.");
                }
            }

            ModifyDbContext(projectFiles, module, startupProject, skipDbMigrations);
        }
Ejemplo n.º 11
0
        private async Task AddNugetAndNpmReferences(ModuleWithMastersInfo module, string[] projectFiles)
        {
            foreach (var nugetPackage in module.NugetPackages)
            {
                var nugetTarget =
                    await IsProjectTiered(projectFiles) && nugetPackage.TieredTarget != NuGetPackageTarget.Undefined
                        ? nugetPackage.TieredTarget
                        : nugetPackage.Target;

                var targetProjectFile = ProjectFinder.FindNuGetTargetProjectFile(projectFiles, nugetTarget);
                if (targetProjectFile == null)
                {
                    Logger.LogDebug($"Target project is not available for this NuGet package '{nugetPackage.Name}'");
                    continue;
                }

                await ProjectNugetPackageAdder.AddAsync(targetProjectFile, nugetPackage);
            }

            if (!module.NpmPackages.IsNullOrEmpty())
            {
                var targetProjects = ProjectFinder.FindNpmTargetProjectFile(projectFiles);
                if (targetProjects.Any())
                {
                    NpmGlobalPackagesChecker.Check();

                    foreach (var targetProject in targetProjects)
                    {
                        foreach (var npmPackage in module.NpmPackages.Where(p =>
                                                                            p.ApplicationType.HasFlag(NpmApplicationType.Mvc)))
                        {
                            await ProjectNpmPackageAdder.AddAsync(Path.GetDirectoryName(targetProject), npmPackage);
                        }
                    }
                }
                else
                {
                    Logger.LogDebug("Target project is not available for NPM packages.");
                }
            }
        }