private void AddEntry(XDocument document, string id, SemanticVersion version, FrameworkName targetFramework)
{
XElement element = FindEntry(document, id, version);
if (element != null)
{
element.Remove();
}
var newElement = new XElement("package",
new XAttribute("id", id),
new XAttribute("version", version));
if (targetFramework != null)
{
newElement.Add(new XAttribute("targetFramework", VersionUtility.GetShortFrameworkName(targetFramework)));
}
// Restore the version constraint
string versionConstraint;
if (_constraints.TryGetValue(id, out versionConstraint))
{
newElement.Add(new XAttribute("allowedVersions", versionConstraint));
}
document.Root.Add(newElement);
SaveDocument(document);
}