0
如何以编程方式将多个项目添加到Visual Studio解决方案中?以编程方式将多个项目添加到Visual Studio解决方案中?
如果我使用
solution.addfromtemplate(template1);
solution.addfromtemplate(template2);
然后它会覆盖项目与模板1?
如何以编程方式将多个项目添加到Visual Studio解决方案中?以编程方式将多个项目添加到Visual Studio解决方案中?
如果我使用
solution.addfromtemplate(template1);
solution.addfromtemplate(template2);
然后它会覆盖项目与模板1?
取决于你愿意实现的目标。如果你正在创建一个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);
但是,如果我再这样做sln.AddFromTemplate(...);然后,它覆盖现有项目而不是创建另一个项目。 –
您是否更改了碰巧是项目名称的方法的第三个参数?如果没有 - 这就是为什么现有的一个被覆盖。 FMI请参阅:http://msdn.microsoft.com/en-us/library/ms228767.aspx – NValchev