Skip to content

Commit

Permalink
Merge pull request #693 from fassadlr/merge692
Browse files Browse the repository at this point in the history
Merge Further improvements to package version check logging (#692)
  • Loading branch information
fassadlr authored Sep 2, 2021
2 parents 139daf1 + 393eec8 commit 4598973
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,16 @@ public void EnsureVersionsBumpedWhenChangingPublishedPackages()
XmlDocument doc2 = new XmlDocument();
doc2.Load(nuspecFile);

bool versionsMatch = true;
bool referencedPackagesMatch = true;
foreach (XmlNode x in doc.SelectNodes("/Project/ItemGroup/ProjectReference"))
{
string includePath = x.Attributes["Include"].Value;
string includeFullPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(projectFolder), includePath));

XmlDocument doc3 = projectFiles[includeFullPath];
string name3 = doc3.SelectSingleNode("Project/PropertyGroup/PackageId")?.InnerText;
if (name3 == null)
continue;

XmlNode depNode = doc2.SelectSingleNode($"//*[name()='dependency' and @id='{name3}']");
string cmpVersion = depNode.Attributes["version"].Value;
Expand All @@ -141,17 +143,20 @@ public void EnsureVersionsBumpedWhenChangingPublishedPackages()
{
string msg = $"Comparing the local project '{project.ProjectName}' version {version} with its published package, '{targetName}', the published package references version '{cmpVersion}' of '{name3}' while the local project references version '{referencedVersions[includeFullPath]}'.";
debugLog.AppendLine(msg);
versionsMatch = false;
referencedPackagesMatch = false;
break;
}
}

if (versionsMatch)
if (referencedPackagesMatch)
continue;
}

string msg2 = $"The project '{project.ProjectName}' has been modified since it was published but its local version {version} remains unchanged.";
debugLog.AppendLine(msg2);

modifiedPackages.Add(project.ProjectName);
referencedVersions[projectFolder] = "mismatch";
referencedVersions[projectFolder] += " (modified)";
}

Assert.True(modifiedPackages.Count == 0, $"{debugLog.ToString()} Affected packages: {string.Join(", ", modifiedPackages)}");
Expand Down Expand Up @@ -184,7 +189,9 @@ static bool FileEquals(string fileName1, string fileName2)

foreach (string line in File.ReadLines(fileName1))
{
if (source.Take(1).FirstOrDefault() != line)
string compare = source.Take(1).FirstOrDefault();

if (compare?.Trim() != line.Trim())
return false;

source = source.Skip(1);
Expand Down

0 comments on commit 4598973

Please sign in to comment.