How to pass custom parameter a value

Category: visual studio extensibility


FavJ on Sun, 29 Jul 2018 12:48:57

I developed an item template whos's located in: 
> C:\..\..\Documents\Visual Studio 2017\Templates\ItemTemplates

On my code i'm using `AddFromTemplate()` method to load my item template. The item template has a `$CustomParameter$` but i dont want to pass the value in the `vstemplate` file. I want to pass a value from my code.

I'm trying to use `replacementsDictionary.Add("$CustomParameter$", "WhatIwant")` but this not working because the item it's not on my solution. But if i use this:

        <CustomParameter Name="$CustomParameter$" Value=""/>  

 on the vstemplate located in the folder above it works well but i can pass the value who i want.

Any suggestion?



Wendy Zang on Mon, 30 Jul 2018 07:42:17

Hi FavJ,

Thank you for posting here.

Since your question is more related to Visual Studio Integrate, I will move it to Visual Studio Integrate forum for suitable support.

The Visual C# forum discuss and ask questions about the C# programming language, IDE, libraries, samples, and tools.

Best Regards,


Zhanglong Wu on Thu, 02 Aug 2018 06:24:03

Hi FavJ,

As far as i know, it seems that we have not related API to map CustomParameters. if you want to change it via code, I would suggest that you could related .vstemplate and change the node via XmlDocument.

Best regards,


FavJ on Thu, 02 Aug 2018 14:21:17

I cant find any solution for this. I dont know how i can related the vstemplate and change the node via XmlDocument. Any sample?

I have a solution with 2 projects: Project template and the wizard project. My project template have no item, im trying to add items using AddFromTemplate(). And the template is located in C:\..\..\Documents\Visual Studio 2017\Templates\ItemTemplates. 

Ed Dore on Sat, 11 Aug 2018 17:47:43

You did not elaborate as to why using the replacementsDictionary.Add isn't working.

I presume you were implementing and associating a custom IWizard assembly with your item template. If you had done this correctly, you should have implemented the IWizard.RunStarted method, which is passed a replacementsDictionary argument. And from the RunStarted, you should have been able to programmatically add your additional token values.

   How to: Use wizards with project templates (works with item templates as well)

   Creating a VSIX Deployable Project (or item) Template with Custom Wizard Support


FavJ on Tue, 14 Aug 2018 16:34:19

It's not working because the item template it's not "fisically" located in my solution. I'm using the addFromTemplate() method to load the item template. If i have an item, for exeample a Class with custom paramters in my solution, i can use the replacementsDictionary.Add to replace.

Ed Dore on Fri, 17 Aug 2018 17:42:08

Item and Project templates are typically deployed via a .VSIX file these days, and do not reside in the solution folder. I'm still unclear as to what sort of "item template" you have here, how it is implemented, and how exactly you are attempting to invoke the AddFromTemplate API.