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 RunStarted function code, which does the following:

On the project creation, it copies another existing solution directory from another location to the new project selected location, and then, instead of creating the new project in a new solution, the new project will be added to the copied solution, in a specific "apps" folder, and no new solution will be created.

In the RunStarted method I wrote a simple CopyDirectory code which copies the wanted solution to the $SolutionDirectory$ which I extracted from the ReplacementsDictionary parameter. But now, I don't success to continue and change the new project configuration though it will be generated as a project of the copied solution.

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

Foi útil?

Solução

You have 2 options:

  1. If you have the DTE \ Solution2 object of the solution, you can use the AddFromFile() method or directly add the project from the template by using AddFromTemplate() method.

    The current DTE object can be obtained by the GetService() method:

    // Get an instance of the currently running Visual Studio IDE

    DTE dte = (DTE)GetService(typeof(DTE));

  2. If you can't get the solution as DTE object, you can edit the .sln file by using XML editing (look in existing .sln file how the projects added).

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