VC++ project "Include in project" programmatically
Asked Answered
P

2

0

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

Pulver answered 5/11, 2012 at 13:45 Comment(0)
F
2

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

Finicky answered 16/10, 2013 at 13:14 Comment(0)
M
1

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()
Megavolt answered 5/11, 2012 at 14:15 Comment(1)
Thank you for your response. I didn't try your code for VC++ project, because I wasn't able to figure out which on from Project's constructors is creating and which one is loading project from MSDN documentation :P. I did some investigation and found out that VS doesn't store info about included folder neither in .vcxproj nor in .vcxproj.filter file. It just runs through folder's directory tree and add all files to the project. And I did the same thing :)Pulver

© 2022 - 2024 — McMap. All rights reserved.