Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Generate a New Visual Studio Project in a Visual Studio Project Programmatically?

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?

like image 265
caner Avatar asked Jan 04 '13 08:01

caner


1 Answers

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

like image 144
Dhawalk Avatar answered Sep 24 '22 19:09

Dhawalk