Search code examples
code-generationt4

Creating a Visual Studio project directory using T4


I am trying to use T4 for source code generation. Mostly, I am able to generate individual files using it. How do I create a complete Visual Studio directory (preferably separate from the T4 template directory) having the below sample structure:

/MyProject – Contains MyProject.sln.
/app - Contains the core project layers.
    /MyProject.ApplicationServices
    /MyProject.Core
    /MyProject.Data
    /MyProject.Web
    /MyProject.Web.Controllers
/build - Empty folder for housing build related stuff.
/lib - Contains the solution items for the deployable application.
/db - Contains database schema information; e.g., the result of scaffolding and/or NHibernate's schema export.
/docs - Project documents.
/logs - Output location for log files.
/tests
    /MyProject.Tests
/tools
    /lib - Contains the solution items for the tests project and all other non-deployable assemblies.
    /CrudScaffolding - Customizable CRUD, scaffolding generation code.

Solution

  • You may take a look at the Guidance Automation Extensions and Toolkit for Visual Studio from Microsoft. They are intended for exactly that purpose to be able to author project and solution generation wizards and leverage T4 a lot. In fact, they are the reason why T4 came into being in the first place. However, as they can be seen as a "Software Factory Factory", they do have a steep learning curve.