2
To do this you must instantiate a variable equivalent to your project, add the item to it by identifying its type and save it.
Here’s an example of how to do this:
var proj = new Microsoft.Build.Evaluation.Project(@"C:\projects\Proj\test\test.csproj");
proj.AddItem("Folder", @"C:\projects\Proj\test\test2");
proj.AddItem("Compile", @"C:\projects\Proj\test\test2\Class1.cs");
proj.Save();


Both folders are created, but the folder
sildeyou didn’t add it to the project, just created it, while the folderexemplois as the project folder. This is the difference of both. If you want to put the folderslidein the project, or you put it in thecsprojor right-click on it and choose the optionInclude in Projector something like that.– Tiedt Tech
The OP is asking about how to do include via CODE @Tiedttech
– Paz