Giter Site home page Giter Site logo

template-dotnet's Introduction

Automation is necessary for lazy people

Template

Project for dotnet templates

Install templates

local version

You can build a local prelease version and install this to test it.

On windows run build-and-install-templates.cmd to install all templates.

install version from nuget feed

  1. Create a personal access token with the right read:packages
  2. Add the nuget source to the nuget feed.
dotnet nuget add source https://nuget.pkg.github.com/KinNeko-De/index.json --name github --username <MY_USER> --password <MY_PAT>
  1. Install the template
dotnet new install kinneko-de.template.dotnet

Read the documentation for more information.

New project

The template must be used to create new projects

Microservice

To create a new project based on the microservice template use

dotnet new microservice --name-dotnet <MyNameOfDotnetProject> --name-project <MyNameOfProject> --name-domain <MyNameOfDomain>

Example

dotnet new microservice --name-dotnet SvcExample --name-project Template --name-domain Example

Database

The microservice is created with a database by default.

If the microservice does not need a database, you must remove the database. Use the --database false flag.

dotnet new microservice [..] --database false

Database port number

The database port number for local debug is randomly generated to support running multiple services on one localhost.

If you want to use a specific port number us the --database-port flag.

dotnet new microservice [..] --database-port 12345

Metric

Metrics are created by default using OpenTelemtry

If the microservice does not need metrics, you must remove the metrics. Use the --metric false flag.

dotnet new microservice [..] --metric false

Multiple services for a domain

If you want to create multiple services for the same domain, as example a service and an api gateway, you can also set the the type of the service.

Example

dotnet new microservice --name-dotnet SvcExample --name-project Template --name-domain Example --name-type Api-Gateway --database false

Replacing variables

From dotnet templating

Choose the right output depending of your context.

Transform Input Output
Identity Template.1 Template.1
Namespace Template.1 Template._1
Class Name Template.1 Template__1
Lowercase Identity Template.1 template.1
Lowercase Namespace Template.1 template._1
Lowercase Class Name Template.1 template__1

Full mapping

Transform sourceName name generated replacement
Identity Template.1 My-App.1 Template.1 -> My-App.1
Namespace Template.1 My-App.1 Template._1 -> My_App.1
Class Name Template.1 My-App.1 Template__1 -> My_App_1
Lowercase Identity Template.1 My-App.1 template.1 -> my-app.1
Lowercase Namespace Template.1 My-App.1 template._1 -> my_app.1
Lowercase Class Name Template.1 My-App.1 template__1 -> my_app_1

Excluding template only config use the conditional expression templateonly to exlude code that is only there for the template and should never be take to the generated project.

Note Not all replacement are already implemented in the template

Sources

Dotnet Templating

ConditionalReplacement based on variables

Examples

SymbolGenerator

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.