Skip to content

Instantly share code, notes, and snippets.

@benhysell
Created July 2, 2018 13:47
Show Gist options
  • Save benhysell/41df5fb7c88d6ea7cbb631e43333e0fc to your computer and use it in GitHub Desktop.
Save benhysell/41df5fb7c88d6ea7cbb631e43333e0fc to your computer and use it in GitHub Desktop.
Create Templates from Existing .NET core applications
  • ensure current project runs/compiles
  • Add template.json to project in same directory as sln in folder .template.config
  • for example, Web\web.sln will have a new directory Web.template.config\template.json
  • From PS - dotnet new --install "C:\jobs\PATH TO FOLDER CONTAINING .template.config"
  • i.e. dotnet new -- install "c:\jobs\web" -- since .template.config exists in c:\jobs\web
  • run -- dotnet new starterWeb4 -n NAMESPACE_NEWPROJECT
  • make sure to run in directory where you'd like it created
{
"author": "Benjamin Hysell",
"classifications": [ "Web" ],
"name": "Starter Web",
"identity": "StarterWeb4", // Unique name for this template
"shortName": "starterWeb4", // Short name that can be used on the cli
"tags": {
"language": "C#" // Specify that this template is in C#.
},
"sourceName": "Starter.Web", // Will replace the string 'Sayedha.StarterWeb' with the value provided via -n.
"preferNameDirectory": "true",
"sources": [
{
"source": "./src/",
"target": "./src/"
},
{
"source": "./test/",
"target": "./test/"
},
{
"source": "./build/",
"target": "./build/"
},
{
"source": "./",
"target": "./",
"exclude": ["./.vs", "./.git" ]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment