Skip to content

Instantly share code, notes, and snippets.

@Xeinaemm
Created November 18, 2019 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xeinaemm/3a43e580bdb1a9d08b3d29e067c75130 to your computer and use it in GitHub Desktop.
Save Xeinaemm/3a43e580bdb1a9d08b3d29e067c75130 to your computer and use it in GitHub Desktop.
using System.IO;
using System.Linq;
using System.Xml.Linq;
using Microsoft.Build.Utilities;
public class RemoveRuntimeNode : Task
{
public string ConfigFilePath { get; set; }
public override bool Execute()
{
var doc = XDocument.Load(this.ConfigFilePath);
if (doc == null) return false;
doc.Root.Nodes().OfType<XElement>().FirstOrDefault(e => e.Name.LocalName == "runtime")?.Remove();
using (var stream = new StreamWriter(this.ConfigFilePath))
{
doc.Save(stream);
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment