问题描述:

Is there a way to modify Visual Studio 2008 or 2010 project pre-build events from within your code in C#? Does C# have such preprocessor directives that would allow one to configure what gets run before project compilation and build?

The purpose of this is to scan the project for shader effect files (.fx) and recompile them without editing the pre-build events manually each time I add a new shader effect file. If you know anything that would favor this scenario, you're more than welcomed to contribute.

网友答案:

There is not a way to have the build process execute the code it's building (think about it for a minute...).

However, you can use DynamicExecute from the MSBuild Extension Pack to include C# code in your MSBuild file that will be executed during the build. This works in both VS2008 and VS2010.

相关阅读:
Top