Pergunta

I'm writing a Visual Studio Wizard Template using c# on visual studio 2012.

I followed the MSDN steps: I created a VS template, then I created a Class Library project with a class which implements the IWizard interface, I configured the .vstemplate file and etc...

Now, my target is to write in the RunFinished() function code, which does the following:

On the project creation, it uses ENVDTE , gets the project kind and adds to the solution .sln file dependencies for this project.

for example:

The user created a new project "myProject" with the kind "8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942", and I would like to sign that this project is depends on another project with the kind "9E779BC1-B9D6-425C-B552-CF04B5B786A2".

On the project creation, this text is added to the .sln file:

Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "myProject", "myProject\myProject.vcxproj", "{20C9C96E-09FB-4DA3-A5C6-DE699FEF3916}"
EndProject

And I want my code to edit this text so it will be like:

Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "myProject", "myProject\myProject.vcxproj", "{20C9C96E-09FB-4DA3-A5C6-DE699FEF3916}"
    ProjectSection(ProjectDependencies) = postProject
        {9E779BC1-B9D6-425C-B552-CF04B5B786A2} = {9E779BC1-B9D6-425C-B552-CF04B5B786A2}
    EndProjectSection
EndProject

As for now I have this code:

DTE dte;  
dte = (DTE)automationObject; 
Solution solution;
solution = dte.Solution;
Projects ps = solution.Projects;

var item = ps.GetEnumerator();
while (item.MoveNext())
{
     var project = item.Current as Project;
     string kind = project.Kind;
     //TODO: edit project dependencies...          
}

Do you have any idea about this issue? Thanks!!

Foi útil?

Solução

I found my solution:

var bldDepends = Solution.SolutionBuild.BuildDependencies.Item(project.UniqueName);
bldDepends.AddProject("PATH\\project_name.vcxproj");

Thanks you all for trying help...

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top