A few tips/examples on dotnet new
templating. The snippets should be put in the template.json file of your template. All the text in UNDERSCORE_CASE you should replace.
Excluding files ¶
"sources":[{
"modifiers":[{
"exclude":["**/*.nuspec"]
}]
}]
Replacing text in file names ¶
"symbols":{
"PARAM_NAME":{
"type":"parameter",
"description":"PARAMETER_DESCRIPTION",
"replaces":"TEXT_TO_BE_REPLACED",
"isRequired":true,
"FileRename":"TEXT_TO_BE_REPLACED_IN_FILE_NAMES"
}
}
Input parameter ¶
"symbols":{
"PARAM_NAME":{
"type":"parameter",
"description":"PARAMETER_DESCRIPTION",
"replaces":"TEXT_TO_BE_REPLACED",
"isRequired":true
}
}
Transformed parameter (text after the last dot) ¶
"symbols":{
"PARAM_NAME":{
"type":"derived",
"valueSource":"SOURCE_PARAM_NAME",
"valueTransform":"AfterLastDot",
"replaces":"TEXT_TO_BE_REPLACED"
}
},
"Forms":{
"AfterLastDot":{
"identifier":"replace",
"pattern":"^.*\\.(?=[^\\.]+$)",
"replacement":""
}
}
Transformed patrameter (to lower case) ¶
"symbols":{
"PARAM_NAME":{
"type":"derived",
"valueSource":"SOURCE_PARAM_NAME",
"valueTransform":"ToLower",
"replaces":"TEXT_TO_BE_REPLACED"
}
},
"Forms":{
"ToLower":{
"identifier":"lowerCase"
}
}
Generated port number parameter ¶
"symbols":{
"PARAM_NAME":{
"type":"generated",
"generator":"port",
"parameters":{
"low":LOW_PORT_NUMBER,
"high":HIGH_PORT_NUMBER
},
"replaces":"TEXT_TO_BE_REPLACED"
}
}