Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Solution Items in a project template wizard

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.

like image 887
ulu Avatar asked Jan 21 '26 22:01

ulu


1 Answers

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)
like image 107
Swoogan Avatar answered Jan 23 '26 21:01

Swoogan