I'm trying to add a file to a Visual Studio "Solution Items" folder, using a Project Template Wizard. I'm able to create the folder itself, but when I add a file, it doesn't do anything.
My code (executed from ProjectFinishedGenerating) is
fullPath = @"path_to_existing_file";
_solutionFolder.AddFromFile(fullPath);
Where _solutionFolder is a Project instance corresponding the the solution folder.
I hit the same snag. You need to add it to the ProjectItems:
var _solutionFolder = _vsSolution.AddSolutionFolder(folder);
_solutionFolder.ProjectItems.AddFromFile(fullPath);
Note, I haven't tried the above code. I'm adapting it from my code (which runs in an AddIn):
Dim project As EnvDTE.Project = _vsSolution.AddSolutionFolder(folderName)
_folder = CType(project.Object, SolutionFolder)
_folder.Parent.ProjectItems.AddFromFile(file)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With