IWizard and MultiProject
Example: click here.
It is a Draft document In the previous month I should create a Wizard that it generates a solution with 3 complex projects. The first thinks is use the IWizard interface of Visual Studio. It works fine with a single project template but when you create a MultiProject template this mechanism doesn’t work! For exactly the replacement mechanism that is embedded in Visual Studio don’t propagates the repalcementsDictionary to the other template. I have resolved this problem in the follow way: I have added in each template a WizardExtenstion and a WizardData. In this way for each template is called my IWizard implementation and with static members a communicate between IWizard instances. In each call of RunStart I add in the repalcementsDictionary the correct value (for example projectname and all custom template parameters) for the current template
At this link you can download an example of solution click here.
Installing the example
In the example you can find a folder called “Template” and “IWizardImpl”, in the first folder you find the template that should be decompressed in <User>/Visual Studio 2008/Templates/ProjectTemplates/Visual C#/ (the same thing with VS2005 but the folder is Visual Studio 2005 not Visual Studio 2008) folder.
After that you must register in the GAC the IWizardImpl.dll assembly. This example came with a Debug version placed in IWizardImpl\bin\Debug folder.
You should call the “gacutil.exe” application from the Visual Studio command line or providing full path (for example” C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil.exe”) with the /I param and passing the dll that you won’t store in the GAC.
gacutil.exe /i IWizardImpl.dll
For more detail you can found information about this steps on the MSDN about Visual Studio IWizard.
Example structure of template
The template folder contains a MutiProject template this template refers other two templates . Each templates call the same Wizard but each call has a different custom parameter.
This custom parameter is defined in the WizardData tag, an example is the follow portion of template file of UserControl/MyTemplate.vstemplate.
<WizardData Name="ProjectPart">UserControl</WizardData>
This tag at runtime means that in the replacementDictionary an element with key “ProjectPart” and value “UserControl” is added and you can read this value.
Summering the steps
-
Understands if the calling template is a MultiProject or a Project with WizardRunKind enumeration
- If it is a MultiProject, shows my wizard and collect some information and stores it in statics members.
- If a Project I read the custom parameter to understand if I working over the Skins or UserControl. Go to step 2
- Populates the replacementDictionary with my customization and replacing for example the projectname with an appropriate value.
This steps are useful for avoiding the problem of no replacing mechanism don’t work properly in the case of MultiProject template.
Tags: Visual Studio
May 13th, 2008 at 6:56 pm
I had the same problem; can’t substitute custom params in multi-project template. Exactly what members in your IWizard implementation did you make static? How was “WizardData” used? Do you have a code sample for all this? Thanks.
May 13th, 2008 at 7:39 pm
In the Multi-Project template I have setted for each templates to call the IWizard implementation. In this way for each sub-project of the solution is created an instance of my IWizard implementation and it called. For each instance I populate the replaceDictionary.
Obviously I show the Wizard dialog if only the wizard that is called from the Multi-Project template (WizardRunKind runKind arguments). After the wizard dialog I stores in statics members of my IWizard implementation and i can read this static members from the other instance of IWizard.
WizardData is used in the single template of sub-project.Base ” you can read in
For example if you setting the follow line after the WizardExtension “
object[] customParams an object with key “Name” and value “Base”.
In this way I can perform particulars task for each sub-project.
I hope this description is good starting point but in the next days I hope to post a source code of an example.
May 15th, 2008 at 10:55 pm
Update with an example
October 15th, 2008 at 9:14 pm
What’s with the password on the solution?
WTF!!
October 15th, 2008 at 9:34 pm
?_?
The example don’t have any password. Anyway if the solution makes some strange behavior you can remove it and open only the csproj.
October 17th, 2008 at 3:28 pm
You are correct. My apologies. Thanks for this, I’ve been trying to figure out the one for hours. A very nice and elegant solution to this problem.
March 25th, 2009 at 1:22 pm
Is the example code still available? I’m getting an Error 404, not available.
March 25th, 2009 at 2:22 pm
hooo, I’m sorry my error.
At soon as possible, I upload example on the server. I hope this example became available for tomorrow.
March 25th, 2009 at 10:09 pm
Uploaded.
March 26th, 2009 at 12:06 pm
Thanks for uploading, but now the zip will not open. I get the following error while trying to unzip with WinZip:
End-of-central-directory signature not found. Either this file is not a Zip file, or it constitutes one disk of a multi-part Zip file.
Thanks,
Darren
March 26th, 2009 at 12:18 pm
I performed a fix on the file using the zip tool in cygwin, and things are working now.
Thanks for the example!
Darren
March 26th, 2009 at 8:31 pm
Thanks, I have repacked this zip and uploaded. I hope this zip works better.
November 11th, 2009 at 9:46 am
Hi, Thanks for the implementation. I have a sitation where I do not want to use GAC. I do not want eh wizardimpl.dll to be installed in GAC. Is there any other way any one knows about to get the wizard workign without having to put it in the GAC? Or should i resort to IDTWizard if i need something like this?
November 11th, 2009 at 9:57 am
I remember that the GAC registration is mandatory for a security reason.
Anyway I remember that exists a way to avoid registration for debug purpose but isn’t applicable in a production environment and automatize with an installer.
December 30th, 2009 at 6:28 pm
I downlaoded your solution, but there is a key needed to open it, please can you provide it?