9

I coded a project that takes your database tables - which you choose and build C# classes related to tables' columns. Like, filter, query etc.

It totally works, I can generate 6 different classes with full functionality - depends on my needs - for a table with one click. T4 really rocks!

But, I want to create a new project for these classes. As you understood, it was not my ultimate aim to just create these files.

Now, I am trying to generate a new project/solution for these classes programmatically.

I read different questions related to this issue, but that wasn't enough for me. For example, Create a Visual Studio project programmatically is close to my issue, but it didn't satisfy me. I couldn't find how to choose the type of new project.

I looked at Programmatically generate Visual Studio Solution but I couldn't find a way to give new solution to my generated classes. Also I looked at Tree Surgeon. It didn't satisfy me. After installing it, I saw that it was designed to at most Visual Studio 2008 and it just takes the project name from the user. So, Tree Surgeon was not a solution for this problem.

What I need is, to learn how to code a new project's structure and create it programmatically. After finding the answer, I'm planning to have a project such that, when you write your new project name, database name(s), table name(s) and which type of classes you need in your browser,then both T4 and C# will works for you and ta-da! You will have a new project that has controller, helpers and in there new classes.

Is it possible?

Community
  • 1
  • 1
caner
  • 158
  • 8
  • 2
    Never used it, but have a look at Guidance Automation: http://msdn.microsoft.com/en-us/library/ff687174.aspx – Preben Huybrechts Jan 04 '13 at 09:50
  • Thanks for info, I'm looking at the site now. I appreciate it. – caner Jan 04 '13 at 09:59
  • I think C# projects like all other projects are in MSBuild format. Try looking at [this post](http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/b3db4d7c-b7d1-4958-9145-bfd34cc75320). What I would do in this case is to create a template with a project and a solution that has placeholders for files and just inject the filenames into the template. – Buzzy Jan 04 '13 at 12:11

1 Answers1

4

GAT/GAX is your best bet. I did it exactly what you are asking for in my previous job. Jelle Druyts explains GAX/GAT at best. I used his 6 blogs(2 links below) to generate projects and classes in a VS solution. His session 3 to 6 will be your best bet

http://jelle.druyts.net/2006/06/29/GAS05TuningTheCProjects.aspx

http://jelle.druyts.net/2006/07/03/GAS06GeneratingClasses.aspx

please find hist post 1-4 from his blog. As a new member, I am not allow to post all the links here

jrummell
  • 42,637
  • 17
  • 112
  • 171
Dhawalk
  • 1,257
  • 13
  • 28