Jun 142017
 
 June 14, 2017  Posted by at 12:45 pm Debugging, Visual Studio  Add comments

As we are slowly migrating our solution, a group of microservices, to .NET Core I decided to throw together a template with boilerplate code that we want to keep within the project. But, for some odd reason the templates I created wouldn’t show any content when I created a project based on them.

OBS! The templates I’m talking about aren’t templates created to be used with the new templating engine. I’ll write a separate post on that =)

Here is an example (tested on two different machines, with fresh installs of Visual Studio 2017) with a console app:

I created a console application

I added a folder and a class file with a method

I then exported the project as a template, making sure that is directly imported into Visual Studio so it will show up as an option when I want to create a new project.

First it wouldn’t even show up.

I ran installvstemplates in the Developer Command Prompt, but no luck.

So I navigated to the cache- which was missing and therefore I manually created the ProjectTemplatesCache folder.

C:\Users\[USER]\AppData\Roaming\Microsoft\VisualStudio\15.0_ab2f93a7\ProjectTemplatesCache\

I then restarted Visual Studio, and voila I could choose the template.

2017-06-14_20-57-50

But, to my dismay, the project was completely empty- the content was missing!

2017-06-14_21-00-24

I looked at other project templates, those that come with Visual Studio, and compared the template files. I think I had tried most tags at some point, until I decided to add the CreateInPlace tag. According to the documentation this tag should be optional, and default to true. But, it turns out that adding this tag, and setting it to true, solved the missing content problem. Setting it to false did not- in case you wonder.

2017-06-14_21-10-00

 

2017-06-14_21-09-21

I have to admit that I don’t understand why this tag is required, and if it indeed it is but isn’t created then it’s a bug. I’ll dig a bit deeper, let me know if you know if I’ve missed something 🙂

From the docs:

Specifies whether to create the project and perform parameter replacement in the specified location, or perform parameter replacement in a temporary location and then save the project to the specified location.

CreateInPlace is an optional element. The default value is true.

 

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

What is 6 + 15 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)