It really depends on what exactly you are trying to achieve, but in general I would recommend using T4 templates.
And yes, you can use T4 templates inside your project to generate code in your project based on some local settings, but you must determine what you are trying to do.
If you want to generate code based on some classes that you define in one project, this does not seem to be something easily achievable (because you want to compile some of the classes in the current project, create code based on them and then generate classes ... umm ..?)
But if you want to save some settings, then run the T4 template and create code based on these settings - this is easily achievable. T4MVC is an example (they generate code based on the settings file, which is copied and saved in the project along with the T4 template). This template also considers the current files available in the solution and generates string constants based on each file. Sounds like this will really help you solve your problem, whatever that is :)
If you are still not sure, you can provide more detailed information about what you want to do, and we will try to help you :)
Artiom chilaru
source share