Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save benbenbenbenbenben/ff124ad863ace447ac7eca994800fe2a to your computer and use it in GitHub Desktop.
Save benbenbenbenbenben/ff124ad863ace447ac7eca994800fe2a to your computer and use it in GitHub Desktop.
void Main()
{
var file = @"someproject.csproj";
var dir = System.IO.Path.GetDirectoryName(file);
var proj = XDocument.Load(file);
var files = proj.Descendants().Where(p => p.Name.LocalName == "Content" && p.Attributes().Any(a => a.Name.LocalName == "Include"));
var toRemove = new List<XElement>();
foreach (var f in files)
{
var rel = f.Attributes().Single(p => p.Name.LocalName == "Include").Value;
var act = Path.Combine(dir, rel);
if (!File.Exists(act))
{
toRemove.Add(f);
}
}
foreach (var t in toRemove)
{
t.Remove();
}
proj.Save(file);
}
// Define other methods and classes here
@benbenbenbenbenben
Copy link
Author

that feature bower users/everyone wants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment