Skip to content

Instantly share code, notes, and snippets.

@Trass3r
Last active January 12, 2017 18:02
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 Trass3r/4d69097fe80f0c17f8440b43b2b7f970 to your computer and use it in GitHub Desktop.
Save Trass3r/4d69097fe80f0c17f8440b43b2b7f970 to your computer and use it in GitHub Desktop.
check vcxproj files for non-existent header files causing MSBuild to rebuild
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