Stuio template visual parameters don't return values?

I'm trying to get these parameters when I create a visual studio template, but it doesn't return a value, it just looks like this:

string rootnamespace = $rootnamespace$; // this is the output, it just stays as it was declared
string SpecificSolutionName = $SpecificSolutionName$; // this is the output, it just stays as it was declared

      

According to msdn - Template parameters :

SpecificSolutionName: The name of the solution. When "create solution directory" is checked, SpecificSolutionName has the name of the solution. When "create solution directory" is not checked, SpecificSolutionName is empty.

And I made sure "create solution directory" was checked, but still it doesn't give any value.

How can I get these values. you are welcome...?

+3


source to share


4 answers


I also found that $ SpecificSolutionName $ will be broken. As it works around, it turns out that the solution directory usually matches the name of the solution and thus:



  • If your solution template only has one project: the solution and project names are identical and therefore you can simply use $ projectname $ instead of the broken $ SpecificSolutionName $.

  • If your solution template has multiple projects (eg ProjectCollection): add the CopyParameters = "true" attribute to the desired ProjectTemplateLink element and use $ ext_projectname $ instead of the broken $ SpecificSolutionName $.

+2


source


I think the documentation is not clear enough when it comes to multi-project templates. Putting a wizard declaration into the vstemplate of your multiproject definition and in the project / s you want to use results in a "broken" variable. This is because it runs a wizard for each of its declarations, so to speak, and behaves differently depending on the context. Note that the variable $SpecificSolutionName$

is valid the first time you run the vstemplate multistject declaration and only executes the RunStarted

, ProjectFinishedGenerating

and methods RunFinished

. So in order to use it in a global context, you need to figure out some mechanism to maintain the value between Wizard execution, like adding a new key to replacementsDictionary

or whatever. Hope for this help.



+1


source


I fixed this by adding this doctype to the top of my .vstemplate.

<?xml version="1.0" encoding="utf-8"?>

      

The doctype declaration is not provided by the template wizard, but it is present in all predefined templates. Good luck and thanks for your patience as I investigated this matter.

0


source


$ SpecificSolutionName $ is always empty. How do I know if a user is creating a new solution directory or not?

Surprisingly, the docs are wrong in two ways.

  • There is no "SpecificSolutionName". This is "SpecifiedSolutionName".

  • If the user opts out of Create Directory for Solution, then $ SpecifiedSolutionName $ is not empty as specified; it actually becomes the same as $ projectname $. How you determine when it happened or not, and what you read is the unique name of the solution folder or not, is another story.

0


source







All Articles