Last active
January 12, 2017 18:02
-
-
Save Trass3r/4d69097fe80f0c17f8440b43b2b7f970 to your computer and use it in GitHub Desktop.
check vcxproj files for non-existent header files causing MSBuild to rebuild
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
using System; | |
using System.IO; | |
using System.Xml.Linq; | |
static class Program | |
{ | |
static void check(string fileName) | |
{ | |
XDocument project = XDocument.Load(fileName); | |
XNamespace msbuild = XNamespace.Get("http://schemas.microsoft.com/developer/msbuild/2003"); | |
int present = 0, missing = 0; | |
string folder = Path.GetDirectoryName(fileName); | |
foreach (XElement elem in project.Root.Elements(msbuild + "ItemGroup").Elements(msbuild + "ClInclude")) | |
{ | |
string name = (string)elem.Attribute("Include"); | |
string itemPath = Path.Combine(folder, name); | |
if (!File.Exists(itemPath)) | |
{ | |
Console.WriteLine(name); | |
missing++; | |
} | |
else | |
{ | |
present++; | |
} | |
} | |
Console.WriteLine("{0} files present, {1} missing.", present, missing); | |
} | |
static void Main(string[] args) | |
{ | |
check(args[0]); | |
check(Path.ChangeExtension(args[0], ".vcxproj.filters")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment