Search code examples
visual-studio-2010templateswizardproject-templatemulti-project

Conditionally exclude project creation in a multi-project Visual Studio project template


I have a multi-project Visual Studio project template. I want to be able to, conditionally, exclude specific projects from the created solution.

I've looked into the ProjectFinishedGenerating method of my IWizard implementation, but I can't seem to figure out how to simply ignore a project.

So, essentially I want to do something like this pseudo-code in my IWizard implementation for projects:

public void ProjectFinishedGenerating(Project project)
{
   if(ExcludeAcmeProject && project.Name=="Acme"))
   {
      project.Cancel();
   }
}

Solution

  • I figured it out. I can look at the customParams parameter in the RunStarted method (it contains the path of the .vstemplate file) and throw a WizardCancelledException if I want to skip that specific project.