Overview:
Part I described how to automate the DLL organization of a project. This section describes how to modify templates so that all projects based off of them automatically organize their DLL’s. The template may be created with ProjectGen, which is a tool included with Visual Studio 2005 Tools for Applications, or manually. This walkthrough assumes you have a pre-existing template. Once complete, the projects based off the modified template will automatically store the DLL’s in a folder specified in the fileInstallAddIn.js and the input to the file from the post-build event command line (see Part I for details). For new templates created manually- follow the instructions in Part I instead of creating the template and then modifying it. Templates created with ProjectGen must be created and then modified.
Step-by-Step: How to modify a template so that all add-ins have their DLL’s copied to %MyDocuments%\<HostId>\Addins.
1) Open the Template in Visual Studio 2005.
a. Open Visual Studio 2005.
b. Under the File menu, select New then Project.
c. Under the Project types pane select the language and host application the template is associated with, or if the template is not associated with a host, select only the language.
d. Under the Templates pane, select the template to update.
e. Specify the new template name, location, and solution name.
f. Select OK to open the template.
2) Follow the steps from Part I in Step-by-Step: How to update a project so that its DLL is copied to %MyDocuments%\<HostId>\Addins.
3) Under File, select Export Template. The Export Template Wizard should now appear.
4) Select the Project Template option.
5) Select Next to move to the next screen.
6) Specify the icon, name and description for the template.
7) Select the option to import the template into Visual Studio.
8) Select Finish.
9) The project is exported into a zip file, placed in the output location displayed on the final screen, and imported into Visual Studio. The default location for the zip file to be exported to is %My Documents%\Visual Studio 2005\My Exported Templates. The folder should appear once the template is exported.
10) A copy of the template should now appear in %MyDocuments%\<HostId>\Project Templates\[CSharp, Visual Basic]. The file being present here will cause the updated template to be displayed under the My Templates section of the Templates pane when VSTA is run for the host application.
11) Copy the zip file into the Project Templates folder (located at %Program Files%\Microsoft Visual Studio 8\Common7\IDE\ProjectTemplates\[CSharp, VisualBasic]\%HostId%\1033), then run the command “devenv /setup” (you may need to change the directory to %ProgramFiles%\C:\Program Files\Microsoft Visual Studio 8\Common7\IDE) from the Visual Studio 2005 Command Prompt. This will populate the Project Templates Cache folder with the new template.
12) According to the SDK, you may replace the old template with the version just modified by copying and pasting the updated template in all locations where the original template was found. This seems attractive because if the original template was registered with the host application you would want the updated template to appear there as well. If the template is to replace the original, remove the original template and re-name the updated template to match the original. This did not work for me. To get this to work I needed to rename the file “MyTemplate.vstemplate” in the updated template to match the original.
If you created the original template using ProjectGen and specified project templates location as C:\<HostID>\Templates then the original template should be located in the following 6 directories:
a. C:\Documents and Settings\<user>\Application Data\Microsoft\VSTAHost\<HostId>\8.0\Templates Cache\Project\[CSharp, Visual Basic]\<language #>
b. C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\Project Templates\[CSharp, Visual Basic]\<HostId>\<language #>
c. C:\<HostId>\Templates\[CSharp, Visual Basic]\<language #>
13) This process should be repeated for each language- Visual C# and Visual Basic. Take care to place the correct zip file in the corresponding language folder.
Goto Part I: Projects
Goto Part III: Supporting Projects