VC++ project “Include in project” programmatically

余生长醉 提交于 2019-12-12 05:26:13

问题


Is there a way to include folder into VC++ project programmatically via VCProject or EnvDTE interface?


回答1:


Take a look at the sample macros - View -> Other Windows -> Macro Explorer. There's one in Samples/AddDirAsSlnFolder which shows you how to create nodes in a project and add files. It's in VisualBasic, but it's pretty easy to translate into C# once you see which methods in EnvDTE are used, eg

projItem = currentSlnFolder.Parent.ProjectItems.AddFromFile(file)

using EnvDTE.ProjectItems




回答2:


I have done this only for C# and VB.NET projects, but it should be the same:

var pr = new Microsoft.Build.Evaluation.Project();  
//Initialize (load from file or whatever)    
pr.AddItem("Folder", YourFoldersPath + @"\");  
pr.Save()


来源:https://stackoverflow.com/questions/13233390/vc-project-include-in-project-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!