For people using monodevelop for #os - that script resolves all
'<Compile Include="*.cs" />' and similar in .csproj files to literal
filenames.
Just run it and it will patch every .csproj file in current dir and all subdirs.

(it may also eat your family, burn your cpu, etc.)
#!/usr/bin/env python

import os, sys, re
from stat import *

re_include = re.compile('^\s+<Compile Include="(.*)\*.cs" (Exclude=[\S]+ )?\/>$')

def monodevelopize(top, entry):
	path = os.path.join(top, entry)
	print 'Changing: %s' % (path)
	file = open(path, 'r+')
	contents = []
	for line in file:
		m = re_include.match(line)
		if m:
			files = []
			base = m.group(1)
			if m.group(1)=='**\\':
				base = ''
				files = [(x+y)[len(top):len(x+y)] for x,y in deep_glob(top, '.cs')]
			else:
				files = os.listdir(os.path.join(top, m.group(1).replace('\\', '/')))
			for cs in files:
				if cs.endswith('.cs'):
					contents.append("<Compile Include=\"%s%s\" />\n" % (base, cs))
		else:
			contents.append(line)
	file.seek(0)
	file.truncate()
	file.write("".join(contents))
	file.close()

def deep_glob(top, ending):
	result = []
	for entry in os.listdir(top):
		if entry == '.svn':
			continue
		path = os.path.join(top, entry)
		mode = os.stat(path)[ST_MODE]
		if S_ISDIR(mode):
			result += deep_glob(path, ending)
		elif S_ISREG(mode):
			if entry.endswith(ending):
				result.append((top, entry))
		else:
			print 'Skipping: %s' % (path)
	return result

projects = deep_glob('.', '.csproj')
for (top, p) in projects:
	monodevelopize(top, p)

print 'Done.'

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
SharpOS-Developers mailing list
SharpOS-Developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sharpos-developers

Reply via email to