简体   繁体   中英

Get name of template selected when user selected the template type from the visual studio new project window

I have a custom visual studio extension which now requires two types of project templates bundled into the extension. In visual studio, this comes up as two selectable project types. However, the IWizard implementation treats both projects the same and shows the same dialog. Is there a way to conditionally add items to the dialog based on the project that was selected by the user?

You should be able to use the customParams argument passed to your IWizard.RunStarted to differentiate between which .vstemplate was responsible for invoking the wizard.

Specifically, the customParams[0], is the fullpath to the .vstemplate, so you can extract just the base filename and conditionally invoke a specific dialog, or invoke a dialog with a flag determining what content to display.

The only example I have is linked with an old blog entry I wrote a couple years back:

Creating a VSIX Deployable C++ project template.

But that demo just uses the path of the .vstemplate, to locate a .vsxproj.filters file I needed to programmatically copy into the resulting project directory, because it wasn't referenced in the .vcxproj.

Sincerely, Ed Dore

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM