0

How can I make my VS2017 automatically add namespaces to new *.vb files?

I tried to create new item templates using $itemfolder$, but it doesn't work:

Template

Namespace $itemfolder$

    Public Class $safeitemrootname$

    End Class

End Namespace

Output

Namespace $itemfolder$

    Public Class MyClass2

    End Class

End Namespace

Using the $rootnamespace$ parameter, it doens't work as I'm expecting:

Template

Namespace $itemfolder$

    Public Class $safeitemrootname$

    End Class

End Namespace

Output

Namespace ConsoleApp1

    Public Class MyClass

    End Class

End Namespace

Solution Explorer

I was expecting the namespace to be ConsoleApp1.TestNamespace or TestNamespace in that case.

Is there any way to VS2017 automatically add namespaces to my new classes? I also know that Resharper can do this job, but I'm looking for a free solution.

vinibrsl
  • 6,563
  • 4
  • 31
  • 44

1 Answers1

0

You seem to have been on the right track but you may have missed a step. There's a command you have to execute from the command line: devenv.exe /InstallVSTemplates as seen on this thread here. Have a look and see if it solves your problem.

Fabulous
  • 2,393
  • 2
  • 20
  • 27