Speed Up with Project Templates Using Visual Studio 2005 - Part 3
page 2 of 10
by Ameet Phadnis
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 41547/ 125

IWizard Interface

Before we start looking at building our own template with a Wizard, I would like to explain some elements of the IWizard interface.

IWizard interface allows us to define the logic for a template.  You have to create a class by implementing the IWizard interface.

The IWizard interface has the following methods.

BeforeOpeningFile - Runs custom wizard logic before opening an item in the template.

ProjectFinishedGenerating - Runs custom wizard logic when a project has finished generating.

ProjectItemFinishedGenerating - Runs custom wizard logic when a project item has finished generating.

RunFinished - Runs custom wizard logic when the wizard has completed all tasks.

RunStarted - Runs custom wizard logic at the beginning of a template wizard run.

ShouldAddProjectItem - Indicates whether the specified project item should be added to the project.

Based on your Wizard template requirements you can code any of the above events.  In this article I will code the RunStarted event.

$<variable>$ Use

The majority of the time the templates are required to replace a few words when the project is created.  For example, if you wanted to assign the connectionstring in Web.Config file based on user input, then you would create the Web.Config connectionstrings section as the following.

Listing 1

<connectionStrings>
    <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer" connectionString="$LocalHostString$"
 providerName="System.Data.SqlClient"/>
  </connectionStrings>

The Wizard Interface will be tasked with replacing the $LocalHostString$ value.  The way the Wizard replaces this string is by using the System.Collections.Generic.Dictionary object.


View Entire Article

User Comments

Title: Clarification   
Name: Jon
Date: 2007-01-09 3:34:33 PM
Comment:
As a clarification, VS will still use the old version even after I go into the cache through the control panel and remove it.
Title: Development Process   
Name: Jon
Date: 2007-01-09 3:32:22 PM
Comment:
What's the best way to actually build and test a wizard from the ground up?

I have my build process for the Wizard's project set up to sign the DLL and automatically add itself to the GAC (using: "gacutil.exe /if $(TargetPath)").

The problem is they will stay in the cache after every rebuild, so I need to either update the version number in the vsTemplate file and the project after each compile, or restart Visual Studio each time I want to test a new build.

Advice?
Title: VB Bug ?   
Name: frisla
Date: 2006-09-20 9:52:51 AM
Comment:
Hi A

The test for C# and VB.NET wore created as separated projects - C# Custom wizard and template project, VB Custom wizard and template project.

In VB as soon as I try to access my IWizard implementation, my VB template project wil not unfold, hence the error message. The template itself executes perfectly, but again as soon as I try to reference my custom wizard, using an "WizardExtension" entry in the xx.vstemplate I get the error message.

Any suggestions

- Thanks -
Title: No   
Name: Ameet
Date: 2006-09-19 7:37:26 PM
Comment:
The article was written using VB.NET and not C#.NET.

Check whether you have created the template itself for C#.NET...
Title: VB Bug ?   
Name: frisla
Date: 2006-09-19 4:01:54 PM
Comment:
Why is it you get a, "Unable to copy the file 'Application.myapp' from the project template to the project. Cannot find file ...." failure when you use VB.NET (2005), but using C# is a walk in the park ??????

Is the execution of the IWizard interface different in VB.NET ?????

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2019 ASPAlliance.com  |  Page Processed at 2019-11-12 1:07:26 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search