簡體   English   中英

EnvDTE.DTE為Visual Studio 2015創建一個空的C ++項目

[英]EnvDTE.DTE create empty C++ project for Visual Studio 2015

我正在嘗試使用EnvDTE以編程方式創建Visual C ++空項目 但是組成的項目文件夾不包含vcxproj和vcxproj.filter文件。 由於當我在Visual Studio中打開該解決方案時,文件結構已損壞。 如何通過EnvDTE創建正確的Empty C ++項目? 在哪里可以找到C ++空項目模板?

InitializeComponent();
System.Type type = System.Type.GetTypeFromProgID("VisualStudio.DTE.14.0");
Object obj = System.Activator.CreateInstance(type, true);
EnvDTE.DTE dte = (EnvDTE.DTE)obj;
dte.MainWindow.Visible = true; // optional if you want to See VS doing its thing

// create a new solution
dte.Solution.Create(@"C:\NewSolution\", "NewSolution");
var solution = dte.Solution;

 EnvDTE.Project project = solution.AddFromTemplate(@"C:\Program Files (x86)
 \Microsoft Visual Studio 14.0\Common7\IDE\ProjectTemplates\VC\General\
 sharedvcxitems\shared.vstemplate", @"C:\NewSolution\TestApp", "TestApp");

// save and quit
dte.ExecuteCommand("File.SaveAll");

dte.Quit();

通常,我在私有文件夾中有一個.vcxproj模板,其中包含諸如您的程序之類的程序,因此請不要使用標准模板。

此外,標准的VC template文件夾可以更改,因此必須通過代碼來解析位置(除非您只是為自己或已知的機器編寫代碼)。

在您的示例中,模板路徑無效

C:\\ Program Files(x86)\\ Microsoft Visual Studio 14.0 \\ Common7 \\ IDE \\ ProjectTemplates \\ VC \\ General \\ s haredvcxitems \\ shared.vstemplate

應該:-

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\ProjectTemplates\VC\General\sharedvcxitems\shared.vstemplate

編輯:通過打開或創建項目來創建自己的模板,然后單擊菜單File>Export Template

暫無
暫無

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

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