/// <summary> /// Note, no need for package version string since you can't have mulitple versions of the same package. /// </summary> public static bool HasPackageReference(this PackageReferencesItemGroupXElement packageReferencesItemGroupXElement, string name, out IPackageReference packageReference) { packageReference = packageReferencesItemGroupXElement.GetPackageReferenceXElementsWhereName(name) .Select(xElement => PackageReferenceXElement.From(xElement)) .SingleOrDefault(); var hasPackageReference = PackageReferenceHelper.WasFound(packageReference); return(hasPackageReference); }
public static PackageReferenceXElement New(string name, string versionString) { var xPackageReference = new XElement(ProjectFileXmlElementName.PackageReference); xPackageReference.AddAttribute(ProjectFileXmlElementName.Include, name); xPackageReference.AddAttribute(ProjectFileXmlElementName.Version, versionString); var packageReferenceXElement = PackageReferenceXElement.From(xPackageReference); return(packageReferenceXElement); }