Adding Solution Items to the Project Template Wizard

I am trying to add a file to the Solutions folder in Visual Studio using the Project Template Wizard. I can create the folder myself, but when I add the file it doesn't do anything.

My code (executed from ProjectFinishedGenerating

) -

    fullPath = @"path_to_existing_file";
    _solutionFolder.AddFromFile(fullPath);

      

Where _solutionFolder is the project instance corresponding to the solution folder.

+3


source to share


1 answer


I fell into the same trap. You need to add it to ProjectItems:

var _solutionFolder = _vsSolution.AddSolutionFolder(folder);
_solutionFolder.ProjectItems.AddFromFile(fullPath);

      



Note, I have not tried the above code. I am adapting it from my code (which works in AddIn):

Dim project As EnvDTE.Project = _vsSolution.AddSolutionFolder(folderName)
_folder = CType(project.Object, SolutionFolder)
_folder.Parent.ProjectItems.AddFromFile(file)

      

+2


source







All Articles