<p>I had an idea, if I add a python .py file to my C# project, and tag the file with a custom generator that would execute the python file, and treat the output as the result of the code generation, ie. put it into a C# file, that would allow me to do quite a lot of code generation as part of the build process.</p>

<p>Does anyone know if such a custom generator for Visual Studio 2008 exists?</p>

[{'answer_id': 24199, 'author': 'Greg Hewgill', 'author_id': 893, 'author_profile': 'https://Stackoverflow.com/users/893', 'pm_score': 2, 'selected': False, 'text': '<p>I recall that in previous versions of VS, there was a way to add custom build steps to the build process. I used that a lot to do exactly the kind of automated code generation you describe.</p>\n\n<p>I imagine the custom build step feature is still there in 2008.</p>\n'}, {'answer_id': 24236, 'author': 'dguaraglia', 'author_id': 2384, 'author_profile': 'https://Stackoverflow.com/users/2384', 'pm_score': 1, 'selected': False, 'text': "<p>I don't understand what you are trying to do here. Are you trying to execute a Python script that generates a C# file and then compile that with the project? Or are you trying to compile a Python script to C#?</p>\n"}, {'answer_id': 24248, 'author': 'dguaraglia', 'author_id': 2384, 'author_profile': 'https://Stackoverflow.com/users/2384', 'pm_score': 3, 'selected': True, 'text': '<p>OK, I see. Well, as far as I know there isn\'t any code generator for Python. There is a good introduction on how to roll your own <a href="http://www.drewnoakes.com/snippets/WritingACustomCodeGeneratorToolForVisualStudio/" rel="nofollow noreferrer">here</a>.</p>\n\n<p>Actually, that\'s quite an under-used part of the environment, I suppose it\'s so because it needs you to use the IDE to compile the project, as it\'d seem only the IDE knows about these "generators", but MSBuild ignores them.</p>\n'}, {'answer_id': 222427, 'author': 'jwfearn', 'author_id': 10559, 'author_profile': 'https://Stackoverflow.com/users/10559', 'pm_score': 2, 'selected': False, 'text': '<p>I think <a href="http://nedbatchelder.com/code/cog/" rel="nofollow noreferrer">Cog</a> does what you want.</p>\n'}, {'answer_id': 223387, 'author': 'technomalogical', 'author_id': 6173, 'author_profile': 'https://Stackoverflow.com/users/6173', 'pm_score': 1, 'selected': False, 'text': '<p>I dug through my old bookmarks (I love Del.icio.us!) and found this article: <a href="http://blogs.acceleration.net/ryan/articles/577.aspx" rel="nofollow noreferrer">Code Generation with Python, Cog, and Nant</a>. Keep in mind that anything you can do in NAnt can probably be done in MSBuild as well. This should be enough to get you started.</p>\n'}]
['https://Stackoverflow.com/questions/24193', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/267/']