0

I have created a Visual Studio template using this link: http://msdn.microsoft.com/en-us/library/ms185301.aspx.

I am able to create a dialog where the user enters a custom message and it gets displayed:

namespace TemplateProject
{
    class WriteMessage
    {
        static void Main(string[] args)
        {
             Console.WriteLine("$custommessage$");
        }
    }
}

What I want to do it allow the user to rename the class names so I want to do something like:

enter image description here

But you see I'm getting errors of "Unexpected character $"

How can I do this?

EDIT

I see from this link: http://msdn.microsoft.com/en-us/library/eehb4faa(v=vs.110).aspx that

To enable parameter substitution in templates: In the .vstemplate file of the template, locate the ProjectItem element that corresponds to the item for which you want to enable parameter replacement. Set the ReplaceParameters attribute of the ProjectItem element to true.

BUT above I have not yet generated the template yet as I am still defining the classes. I understnad that the above step needs to be done in order to get the parameter substitution enabled for a File-->New Project scenario.

Harry Boy
  • 4,159
  • 17
  • 71
  • 122

1 Answers1

1

It looks like you have your template file as a cs file, which is causing Visual Studio to attempt to build it directly.

From what I can tell you should create a functioning Project, export it, and then modify the resulting template to add any replacements you need.

Guvante
  • 18,775
  • 1
  • 33
  • 64
  • My project is evolving and I may have to make changes to it going forward. So will I have to repeat the process each time? i.e Create a functioning project, then export as template then replace the values..?? – Harry Boy May 30 '14 at 10:02
  • 1
    @HarryBoy: I would assume that after the initial export you can manually modify the files for any changes you need to make. I do not know offhand what the intended workflow is for the process, sorry. – Guvante May 30 '14 at 18:10