private static void RemoveNugetDependency(String projectOutput, String targetFramework, String dependency) { Console.WriteLine($"Removing '{targetFramework} => {dependency}' from nuget dependencies for '{Path.GetFileName(GetNugetFileFromProjectOutput(projectOutput))}'..."); var nuget = new NugetPackage(projectOutput); var node = nuget.Document.Descendants().Where(x => x.Name.LocalName == "group").First(x => x.Attribute("targetFramework").Value == targetFramework) .Descendants().Where(x => x.Name.LocalName == "dependency") .FirstOrDefault(x => x.Attribute("id").Value == dependency); if (node != null) { node.Remove(); nuget.Commit(); Console.WriteLine("Dependency removed successfully."); } else { Console.WriteLine("The specified dependency was not found on the nuget package."); } }