繁体   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