Beispiel #1
0
        public override Task ExecuteAsync(CancellationToken cancellationToken)
        {
            var nuspecDirectoryName = Path.GetDirectoryName(NuspecFile.FileName);
            var packagesConfig      = PackagesConfigFile.Load(nuspecDirectoryName);
            var csProj = CsProjFile.Load(Path.Combine(nuspecDirectoryName, $"{NuspecFile.Id}{CsProjFile.Extension}"));

            var packageDependencies = packagesConfig.Packages.Concat(csProj.PackageReferences).Select(package => new NuspecDependency {
                Id = package.Id, Version = package.Version
            });
            var projectDependencies = csProj.ProjectReferences.Select(projectReferenceName => new NuspecDependency {
                Id = projectReferenceName, Version = Version
            });

            NuspecFile.Dependencies = packageDependencies.Concat(projectDependencies);
            NuspecFile.Version      = Version;
            NuspecFile.Save();

            return(Task.CompletedTask);
        }
Beispiel #2
0
        public override Task ExecuteAsync(CancellationToken cancellationToken)
        {
            var solutionFileName = _fileSearch.FindSolutionFile();
            var nuspecFiles      = _fileSearch.FindNuspecFiles();

            foreach (var nuspecFile in nuspecFiles.OrderBy(x => x.FileName))
            {
                var nuspecDirectoryName = Path.GetDirectoryName(nuspecFile.FileName);
                var packagesConfig      = PackagesConfigFile.Load(nuspecDirectoryName);

                var csProj = CsProjFile.Load(Path.Combine(nuspecDirectoryName, $"{nuspecFile.Id}{CsProjFile.Extension}"));
                var projectDependencies = csProj.ProjectReferences.Select(projectReferenceName => new NuspecDependency {
                    Id = projectReferenceName, Version = _roboNuGetFile.FullVersion
                }).ToList();
                var packageDependencies = packagesConfig.Packages.Concat(csProj.PackageReferences).Select(package => new NuspecDependency {
                    Id = package.Id, Version = package.Version
                }).ToList();

                var dependencyCount = projectDependencies.Count + packageDependencies.Count;

                //dependencyCount = nuspecFile.Dependencies.Count();

                if (!Short)
                {
                    Logger.ConsoleMessageLine(m => m);
                }
                Logger.ConsoleMessageLine(m => m
                                          .Indent()
                                          .text($"{Path.GetFileNameWithoutExtension(nuspecFile.FileName)} ")
                                          .span(s => s.text($"({dependencyCount})").color(ConsoleColor.Magenta)));

                if (!Short)
                {
                    ListDependencies("Projects", projectDependencies.OrderBy(x => x.Id));
                    ListDependencies("Packages", packageDependencies.OrderBy(x => x.Id));
                }
            }

            return(Task.CompletedTask);
        }