Created
July 27, 2017 14:46
-
-
Save benbenbenbenbenben/ff124ad863ace447ac7eca994800fe2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
that feature bower users/everyone wants