以编程方式将多个项目添加到Visual Studio解决方案?

时间:2014-01-14 06:44:16

标签: c# .net visual-studio envdte

如何以编程方式将多个项目添加到Visual Studio解决方案中?

如果我正在使用

solution.addfromtemplate(template1);
solution.addfromtemplate(template2);

然后用image1覆盖项目?

1 个答案:

答案 0 :(得分:0)

取决于您愿意实现的目标。如果要创建VSX包,则可以使用Visual Studio自动化对象模型中的顶级对象 - DTE:

var dte = Package.GetGlobalService(typeof(DTE)) as DTE2;
Solution2 sln= (Solution2)dte.Solution;
//this will create a solution
sln.Create("<PATH>", "<SOLUTION NAME>");

//here you get the project template which you want to use     
string csTemplatePath = sln.GetProjectTemplate("ConsoleApplication.zip", "CSharp"); 
sln.AddFromTemplate(csTemplatePath, @"C:\fooFolder\FooBar", "Foo", false);
相关问题