簡體   English   中英

以編程方式將多個項目添加到Visual Studio解決方案中?

[英]Add multiple projects programmatically into Visual Studio solution?

如何以編程方式將多個項目添加到Visual Studio解決方案中?

如果我正在使用

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

然后用template1覆蓋項目嗎?

取決於您究竟願意實現什么。 如果要創建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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM