我正在尝试使用EnvDTE以编程方式创建Visual C++空项目。但是,组成的项目文件夹中不包括vcxproj和vcxproj.filter文件。由于当我在Visual Studio中打开该解决方案时,文件结构被破坏了。如何通过EnvDTE创建正确的空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();