4

I'm creating a multi-project template that has a solution as the root folder. I can't find out how to include the name of the solution in the namespace of the project.

$safeprojectname$ returns the name of the internal project of the solution.

According to the docs $specifiedSolutionName$ should be replaced by either the solution name or empty.

Assuming the solution name is mySolutionName and the project name is myProjectName this line :

namespace $specifiedSolutionName$.$safeprojectname$

should return

namespace mySolutionName.myProjectName

The parameter isn't replaced at all though and the result is :

namespace $specifiedSolutionName$.myProjectName

How can I fix that?

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236
Ali Fallah
  • 753
  • 1
  • 7
  • 17
  • Visual Studio templates have little to do with .NET or C#. Which version of Visual Studio are you using? I noticed in the [Template Parameters](Template parameters) page that VS 2015 has a `SpecifiedSolutionName` parameter while 2017 and later have `specifiedSolutionName`. As the same page explains, `Template parameters are case-sensitive` – Panagiotis Kanavos Sep 17 '19 at 14:57
  • If you use VS 2015 it's probably time you upgraded to a newer version – Panagiotis Kanavos Sep 17 '19 at 14:58
  • I use VS 2019 but $specifiedSolutionName$ doesn't work. @PanagiotisKanavos – Ali Fallah Sep 18 '19 at 06:35
  • Explain all that in the question itself, using the proper tags. The question was closed because it was unclear what you were talking about. BTW adding the *solution* name to the namespace is unusual. It could be that `$specifiedSolutionName$ can't be used in source files and people didn't notice because they don't use it there. Searching for that parameter returns several issues and SO questions that suggest it's probably not working as expected, [like this one](https://stackoverflow.com/questions/47217538/specificsolutionname-is-always-empty-how-can-i-tell-if-the-user-is-making-a-n). – Panagiotis Kanavos Sep 18 '19 at 07:31
  • If you check that question you'll see that 1) VS 2017 works with `specifiedsolutionname` 2) You can debug your template code by attaching another VS instance to the VS instance that runs the template and 3) the docs are wrong and you may be better off not using that parameter after all – Panagiotis Kanavos Sep 18 '19 at 07:36

0 Answers0