Search code examples
c#templatesasp.net-core-mvcaspnetboilerplate

How to create an ASP.NET Core MVC boilerplate from a custom base project


Like a lot of developers, I often create new projects with the same features (Authentication, IoC, tests etc..).

What I want to do?

I would like to be able to create a new project based on a custom template code project.

What kind of project?

Currently I'm creating a lot of new in ASP.NET Core MVC projects. My goal is to generate those new project from a specific template (with some configuration options like the project name).

It's possible in the JavaScript world (with some command lines like expo init my-react-native-project). So is it possible to do it for ASP.NET Core MVC projects?

I hope what I want to do is correctly explained :) Thank you very much for your help.


Solution

  • You can create a custom template from an existing project by adding a .template.configtemplate.json file

    Essentially, you can setup the project to have all of the common functionality you required i.e. Authentication, test, IOC and re-use this in a new project.

    Have a look at this post for futher details:

    https://devblogs.microsoft.com/dotnet/how-to-create-your-own-templates-for-dotnet-new/