Skip to content

Commit

Permalink
Fix ProjectReference -> PackageReference
Browse files Browse the repository at this point in the history
  • Loading branch information
Xeevis committed Jul 1, 2019
1 parent 4b2c6b2 commit 195779b
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,27 @@ private string ProcessReferenceNodes(XmlDocument doc, string content)

var nodes = doc.SelectNodes("/Project/ItemGroup/ProjectReference[@Include]");

foreach (XmlNode node in nodes)
foreach (XmlNode oldNode in nodes)
{
var valueAttr = node.Attributes["Include"];
var oldNodeIncludeValue = oldNode.Attributes["Include"].Value;

// ReSharper disable once PossibleNullReferenceException : Can not be null because nodes are selected with include attribute filter in previous method
if (valueAttr.Value.Contains($"{_companyNamePlaceHolder}.{_projectNamePlaceHolder}"))
if (oldNodeIncludeValue.Contains($"{_companyNamePlaceHolder}.{_projectNamePlaceHolder}"))
{
continue;
}

valueAttr.Value = ConvertToNugetReference(valueAttr.Value);
var newNode = doc.CreateElement("PackageReference");

var includeAttr = doc.CreateAttribute("Include");
includeAttr.Value = ConvertToNugetReference(oldNodeIncludeValue);
newNode.Attributes.Append(includeAttr);

var versionAttr = doc.CreateAttribute("Version");
versionAttr.Value = _latestNugetPackageVersion;
newNode.Attributes.Append(versionAttr);

node.Attributes.Append(versionAttr);
oldNode.ParentNode.ReplaceChild(newNode, oldNode);
}

return doc.OuterXml;
Expand Down

0 comments on commit 195779b

Please sign in to comment.