March 10, 2017 by Anuraj
Visual Studio 2017 dotnet swagger
This post is about creating project template for the dotnet new command. As part of the new dotnet command, now you can create Empty Web app, API app, MS Test and Solution file as part of dotnet new command. This post is about creating a Web API template with Swagger support.
For creating the template, I already created an Web API project, and enabled swagger. Also I have added EF Core InMemory database support for CRUD operations. Here is the CSProj.
And here is the Startup.cs,
Now you need to create one folder and one json file, which is the core for dotnet new template. You need to create
.template.config folder and inside that folder you need to create
Here is my template.json file.
For more details and possible options you can visit the Wiki page
Once you’re added the file, you can install the template via dotnet command. Here is the syntax.
It will display the list of project templates available with the new template.
Now you can create a new project with your custom template using the following command.
This will create a new project in
HelloProjectTemplate folder using your custom template.
Right now there is no direct way to remove the templates, you can modify the template cache json files from
You need to remove the reference from three files inside this directory.
Also you can run the
dotnet new --debug:reinit command to re-initialize your environment.
You can deploy your template via nuget.
Happy Programming :)
Copyright © 2024 Anuraj. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Powered by Jekyll. Hosted with ❤ by GitHub