It's Template week! All this week, we're highlighting templates in all their glory.
First off, we're talking the new templating engine in .NET Core.
Jerrie Pelser has a great post on just that!
When creating a new project with the
dotnet newcommand, you are offered a list of templates you can use. These templates allow you to quickly bootstrap a new application according to a specific configuration. There are for example templates to create an MVC application, a Razor application, an API etc.
You are also able to develop your own templates, either for internal use, or to make it available on NuGet for other people to take advantage of.
I recently developed templates that allow developers to bootstrap a new application that makes use of Auth0 for authentication.
Here are useful resources I came across, as well as some tips for issues I ran into.
A few issues I ran into
Identity and Group Identity...
Customise parameter names ...
I am very happy about the inclusion of the new .NET Templating engine. It is still a little limited in some senses, but it is a great step forward. I hope to see the community contribute a lot of new templates.
Next is a must read post from Sayed-Ibrahim-Hashimi that takes you from zero to template hero...
You can now create your own templates for
dotnet new. Creating and installing your own templates is an experimental feature at this point, but one that we are seeing significant interest in and that deserves more of your feedback before we enable it for broad use with .NET Core 2.0. The version of
dotnet newshipped with the .NET Core 1.0 SDK has a new command line parameter
--install. This is an undocumented feature, and is not currently included in the help output.
You can try the new template experience if you have the new SDK or Visual Studio 2017 installed. If you didn’t you can right now.
The goal of this post is to connect with developers who are interested in creating templates. If you maintain a library or framework project on GitHub, then you are a great candidate to be a template author. There are lots of other cases too, where creating templates makes sense. If you can create a sample, you can create a template. It’s not hard at all.
In the last update for .NET Core, we have updated
dotnet new. This new version of
dotnet newis now built on top of the new Template Engine, which is a library that we are developing. To learn more about how to use
dotnet newsee the docs. In this article, we’ll show how to create some custom templates and then use them from
In this post, we have shown how you can get started with creating your own custom templates for
dotnet new. We are still working on enabling the end user scenarios where templates are acquired and used. In this release, the
--installswitch is hidden because it’s currently in preview. The syntax of this command is likely to change. After installing templates, to reset your templates back to the default list you can run the command
dotnet new --debug:reinitIn the following section, you’ll find some links to existing resources. Please share your comments here and file issues as needed. You can also reach me on twitter
@SayedIHashimiWe’re very excited to see the awesome templates that the community creates. In addition to this blog, we may post
dotnet newrelated posts to the .NET Web Developer Blog.
Next up is the current home of the community's dotnet new template gallery, http://dotnetnew.azurewebsites.net/
Here's a 30,000 foot few of all the templates (looks like allot doesn't it? That's because it is!)
Here's another list of available templates for dotnet new, from the official github repo;
Last, but not least, is that offical templating repo, https://github.com/dotnet/templating
This repository is the home for the .NET Core Template Engine. It contains the brains for
dotnet new. When
dotnet newis invoked, it will call the Template Engine to create the artifacts on disk. Template Engine is a library for manipulating streams, including operations to replace values, include/exclude regions and process
end ifstyle statements.
We have created a dotnet template samples repo, which shows how you can use the Template Engine to create new templates. The samples are setup to be stand alone for specific examples. If you are in need of a sample, and it doesn't exist please create an issue in the samples repo.
You can create new projects with
dotnet new, this section will briefly describe that. For more info take a look at Announcing .NET Core Tools Updates in VS 2017 RC.
To get started let's find out what options we have by executing
dotnet new --help. The result is pasted in the block below.
What to expect when working with this repo
The instructions below enable a new command at the
dotnet new3, that uses the bits and templates contained in this repo. Think of it as a "preview" version of
dotnet newfor trying out new switches, interactions and display styles before rolling them in to the product.
Commands executed against
dotnet new3won't impact the behavior of
dotnet new, Visual Studio for Mac, Visual Studio, nor any other environment.
Debugging code requires your current
dotnet new3session to have its active build session configured to DEBUG, and a debugger from your application of choice to be attached to the current running
dotnet new3process. The steps required to accomplish this are outlined below.
Templates can be installed from packages in any NuGet feed, directories on the file system or ZIP type archives (zip, nupkg, vsix, etc.) To install a new template use the command:
... [Click through for the rest] ...