Question

I am creating multiproject visual studio template. I created VSIX package project and Wizard class library. Added those projects as assets in source.extension.vsixmanifest file of VSIX project. In Wizard class library I added a Windows Form, to collect user inputs. I need to, based on user inputs, add to generated solution from template additional projects. My solution vstemplate file looks like that:

<?xml version="1.0" encoding="utf-8"?>
<VSTemplate Version="3.0.0" Type="ProjectGroup" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" xmlns:sdk="http://schemas.microsoft.com/developer/vstemplate-sdkextension/2010">
   <TemplateData>
   ...
   </TemplateData>
   <TemplateContent>
     <ProjectCollection>
       <SolutionFolder Name="App">
          <ProjectTemplateLink ProjectName="$safeprojectname$.Core">
            Core\Core.vstemplate
          </ProjectTemplateLink>
          ...
       </SolutionFolder>
     </ProjectCollection>
   </TemplateContent>
   <WizardExtension>
     ...
   </WizardExtension>
</VSTemplate>

But the probles is that not listed projects in that file not added to zip with template. So I thought, that I have two ways to deal with that:

  1. Add all my projects to VSTEMPLATE, and programmatically prevent some of them to add to solution.
  2. Somehow change build process and force visual studio to add contents to zip file during build.

I think that second way is more complicated. So my final ask is how to stop generating project from template from Wizzard?

Was it helpful?

Solution

Well it seems that I found an answer. I created additional Wizard and added link to it in all child .vstemplate files. In this wizard I check replacementsDictionary["$safeprojectname$"] and if I do not need to add this project I simply throw WizardCanceledException and this project will not be generated. But folder for this project will still be created. Simple call Directory.Delete() fixes it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top