I'm writing a Visual Studio extension of a new c++ project template on Visual Studio 2010. I 'm doing it by the method of .vsz template. I expanded the default.js code according to my needs. iN THE OnFinish(selProj, selObj) function I copy an existing solution from some directory in my computer to the current solution directory, I add the new generated project to that solution, and run it.
I'm doing this like:
function OnFinish(selProj, selObj) {
try
{
var strProjectPath = wizard.FindSymbol('PROJECT_PATH');
var strProjectName = wizard.FindSymbol('PROJECT_NAME');
selProj = CreateCustomProject(strProjectName, strProjectPath);
AddConfig(selProj, strProjectName);
AddFilters(selProj);
var InfFile = CreateCustomInfFile();
AddFilesToCustomProj(selProj, strProjectName, strProjectPath, InfFile);
PchSettings(selProj);
InfFile.Delete();
selProj.Object.Save();
debugger;
//My Added Code
var strSolutionPath = strProjectPath + "\\..";
var EmulationPath = "C:\\Users\\username\\Desktop\\TestSln";
var TreePath = strSolutionPath + "\\apps";
var fso = new ActiveXObject("Scripting.FileSystemObject");
fso.CopyFolder(EmulationPath, strSolutionPath);
var Solution = dte.Solution;
Solution.Open(strSolutionPath + "\\TestSln.sln");
var p = Solution.AddFromFile(strProjectPath + "\\" + strProjectName + ".vcxproj");
}
catch(e)
{
if (e.description.length != 0)
SetErrorInfo(e);
return e.number
}
}
but I have to add the new project to a specific sub-folder of the solution: the above code adds the new project to the solution straightly, and I'ld like to add it to the solutionDir\apps. BTW, the "apps" folder is empty, and I want it to contain the new generated project from now on.
Do you know about any way to do thus? thanks!!
I found my way:
for (var i = 1; i <= solution.Projects.Count; i++)
{
if(Solution.Projects.Item(i).Name == "apps")
{
appsFolder = Solution.Projects.Item(i);
project = appsFolder.Object.AddFromFile(newProjectPath + "\\" + strProjectName + "\\" + strProjectName + ".vcxproj");
break;
}
}
Thanks you all for trying help :)