Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Wizard Template - Change Project solution and directory

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!!

like image 294
user1835297 Avatar asked Feb 21 '26 17:02

user1835297


1 Answers

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).

like image 190
user3114639 Avatar answered Feb 23 '26 05:02

user3114639



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!