Skip to content
Create a gist now

Instantly share code, notes, and snippets.

A quick-and-dirty python script to find invalid ClInclude nodes in VS 2010 projects
import sys
import os.path
import xml.etree.ElementTree as ET
ns = '{}'
filterTree = ET.parse(sys.argv[1]+".filters")
filterRoot = filterTree.getroot()
filterDict = dict()
missingDict = dict()
for inc in filterRoot.iter(ns+'ClInclude'):
incFileRel = inc.get('Include')
incFilter = inc.find(ns+'Filter')
if incFileRel != None and incFilter != None:
filterDict[incFileRel] = incFilter.text
if incFilter.text not in missingDict:
missingDict[incFilter.text] = []
projTree = ET.parse(sys.argv[1])
projRoot = projTree.getroot()
for inc in projRoot.iter(ns+'ClInclude'):
incFileRel = inc.get('Include')
if incFileRel != None:
incFile = os.path.abspath( os.path.dirname(sys.argv[1]) +"\\"+ incFileRel )
if not os.path.exists(incFile):
for (missingGroup, missingList) in missingDict.items():
if len(missingList) > 0:
for missing in missingList:
print(" " + os.path.basename(missing) + " (" + missing + ")")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.