Exemplo n.º 1
0
        internal void ReportArrear(List <OurOwnNuSpec> allNuSpecs, IReporter reporter)
        {
            var lst = allNuSpecs.Where(x => x.Identity == null).ToArray();

            foreach (var l in lst)
            {
                Debug.Write("");
            }

            if (!Dependencies.Any())
            {
                return;
            }

            reporter.AppendLine(@"===" + SpecFile.FullName, Brushes.Blue);
            reporter.AppendLine($"[{Identity.Id}, {Identity.Version}]");
            foreach (var dep in Dependencies)
            {
                var depName  = dep.Id;
                var depReq   = dep.Version;
                var depRes   = "<unknown>";
                var depMatch = allNuSpecs.FirstOrDefault(x => x.Identity != null && x.Identity.Id == depName);
                if (depMatch != null)
                {
                    depRes = depMatch.Identity.Version;
                }

                Brush repColor = null;
                if (depRes != "<unknown>")
                {
                    var depRequirement = VersionRange.Parse(depReq);
                    var sv             = NuGet.Versioning.NuGetVersion.Parse(depRes);

                    if (!depRequirement.Satisfies(sv))
                    {
                        repColor = Brushes.OrangeRed;
                    }
                    if (depRequirement.MinVersion < sv)
                    {
                        repColor = Brushes.Orange;
                    }
                }

                reporter.AppendLine($" - {depName}: req: {depReq} avail: {depRes}", repColor);
            }
        }
Exemplo n.º 2
0
        internal void Report(IReporter reporter)
        {
            if (!Dependencies.Any())
            {
                return;
            }

            reporter.AppendLine(@"===" + SpecFile.FullName, Brushes.Blue);
            foreach (var dep in Dependencies)
            {
                reporter.AppendLine(@"  - " + dep.Id + " " + dep.Version);
                var depRequirement = VersionRange.Parse(dep.Version);
                foreach (var project in Projects)
                {
                    var rp = project.RequiredPackages.FirstOrDefault(p => p.Id == dep.Id);
                    if (rp == null)
                    {
                        continue;
                    }

                    try
                    {
                        var sv  = NuGet.Versioning.NuGetVersion.Parse(rp.Version);
                        var sat = depRequirement.Satisfies(sv);
                        if (!sat)
                        {
                            reporter.AppendLine(
                                $"    - Mismatch: {rp.Version} referenced in {project.ConfigFile.Directory.Name}/{project.ConfigFile.Name}", Brushes.OrangeRed);
                        }
                        else if (string.Compare(rp.Version, depRequirement.MinVersion.ToString(), StringComparison.CurrentCulture) != 0)
                        {
                            reporter.AppendLine(
                                $"    - Warning: MinVersion {depRequirement.MinVersion.ToString()} is lower than installed {rp.Version} in {project.ConfigFile.Directory.Name}/{project.ConfigFile.Name}", Brushes.Orange);
                        }
                    }
                    catch (Exception)
                    {
                        if (string.Compare(rp.Version, dep.Version, StringComparison.CurrentCulture) != 0)
                        {
                            reporter.AppendLine(
                                $"    - Mismatch: {rp.Version} referenced in {project.ConfigFile.Directory.Name}/{project.ConfigFile.Name}", Brushes.OrangeRed);
                        }
                    }
                }
            }
        }