Dotnet Templating Cheat Sheet


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.

"sources":[{
    "modifiers":[{ 
                "exclude":["**/*.nuspec"]
                }]
        }]
"symbols":{
            "PARAM_NAME":{
                "type":"parameter",
                "description":"PARAMETER_DESCRIPTION",
                "replaces":"TEXT_TO_BE_REPLACED",
                "isRequired":true,
                "FileRename":"TEXT_TO_BE_REPLACED_IN_FILE_NAMES"
            }
        }
"symbols":{
            "PARAM_NAME":{
                "type":"parameter",
                "description":"PARAMETER_DESCRIPTION",
                "replaces":"TEXT_TO_BE_REPLACED",
                "isRequired":true
            }
        }
"symbols":{
            "PARAM_NAME":{
                "type":"derived",
                "valueSource":"SOURCE_PARAM_NAME",
                "valueTransform":"AfterLastDot",
                "replaces":"TEXT_TO_BE_REPLACED"
            }
},
"Forms":{
            "AfterLastDot":{
                "identifier":"replace",
                "pattern":"^.*\\.(?=[^\\.]+$)",
                "replacement":""
            }
    }
"symbols":{
            "PARAM_NAME":{
                "type":"derived",
                "valueSource":"SOURCE_PARAM_NAME",
                "valueTransform":"ToLower",
                "replaces":"TEXT_TO_BE_REPLACED"
            }
},
"Forms":{
            "ToLower":{
                "identifier":"lowerCase"
            }
    }
"symbols":{
            "PARAM_NAME":{
                "type":"generated",
                "generator":"port",
                "parameters":{
                    "low":LOW_PORT_NUMBER,
                    "high":HIGH_PORT_NUMBER
                },
                "replaces":"TEXT_TO_BE_REPLACED"
            }
        }