简体   繁体   English

如何以编程方式在Visual Studio项目中生成新的Visual Studio项目?

[英]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. 我编写了一个带有数据库表的项目 - 您选择并构建与表列相关的C#类。 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. 它完全有效,我可以生成6个不同的类,具有完整的功能 - 取决于我的需要 - 只需点击一下即可获得一个表。 T4 really rocks! T4真的很摇滚!

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. 例如, 以编程方式创建Visual Studio项目接近我的问题,但它不满足我。 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. 我查看了以编程方式生成Visual Studio解决方案,但我找不到一种方法来为我生成的类提供新的解决方案。 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. 安装后,我发现它最初是为Visual Studio 2008设计的,它只是从用户那里获取项目名称。 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! 找到答案之后,我计划有一个项目,当你在浏览器中编写新的项目名称,数据库名称,表名和所需类别时,那么T4和C#将适合你和ta-da! You will have a new project that has controller, helpers and in there new classes. 您将拥有一个具有控制器,帮助程序和新类的新项目。

Is it possible? 可能吗?

GAT/GAX is your best bet. GAT / GAX是您最好的选择。 I did it exactly what you are asking for in my previous job. 我完成了你在我以前的工作中所要求的。 Jelle Druyts explains GAX/GAT at best. Jelle Druyts充其量解释了GAX / GAT。 I used his 6 blogs(2 links below) to generate projects and classes in a VS solution. 我使用他的6个博客(下面的2个链接)在VS解决方案中生成项目和类。 His session 3 to 6 will be your best bet 他的第3至第6场比赛将是你最好的选择

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

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

please find hist post 1-4 from his blog. 请从他的博客中找到1-4帖子。 As a new member, I am not allow to post all the links here 作为新成员,我不允许在此发布所有链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 以编程方式创建Visual Studio项目 - Create a Visual Studio project programmatically 如何以编程方式更新Visual Studio项目中的项目引用 - How to programmatically update project references in a Visual Studio project Visual Studio - 以编程方式获取启动项目 - Visual Studio - Get the startup project programmatically 以编程方式升级Visual Studio解决方案和项目文件 - Upgrade Visual Studio solution and project files programmatically Visual Studio可扩展性,以编程方式创建项目 - Visual Studio Extensibility, Programmatically Creating A Project 以编程方式调用第二个Visual Studio项目 - Invoking a second Visual Studio project programmatically C# 如何以编程方式将文件导入 Visual Studio 项目 - C# How to programmatically import files into Visual Studio project C# 如何使用 Visual Studio 2019 以编程方式启动项目实例 - C# how to programmatically launch an instance of a project with Visual Studio 2019 如何在Visual Studio 2008中以编程方式检索已加载的项目? - How can I programmatically retrieve a loaded project in Visual Studio 2008? 如何在已经运行的Visual Studio中以编程方式打开项目/解决方案? - How to programmatically open project/solution in already running Visual Studio?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM