This repo contains the Template Engine which is used by dotnet new
C# PowerShell Shell F# Batchfile CSS Other
Latest commit 4e57031 Feb 23, 2017 @mlorbetske mlorbetske committed on GitHub Merge pull request #365 from dotnet/rel/vs2017/post-rtw
Pull in newer templates from post-rtw
Permalink
Failed to load latest commit information.
build Template build Dec 18, 2016
scripts/common Adding a build.sh script to allow for CI to run for unix based OSes. Sep 2, 2016
src Make net45 builds depend only on Newtonsoft.JSON 8.0.3 Feb 22, 2017
template_feed TestPlatform branding changes: 15.0.0 Feb 23, 2017
test Add host event for confirming partial matches Feb 15, 2017
.editorconfig Get rid of statics Jan 22, 2017
.gitignore Fix build for local dev, tfms to netstandard1.3 Sep 9, 2016
DotnetNew3.sln Add mocks project, get new3 tests running Dec 21, 2016
Key.snk Strong name sign assemblies. Dec 22, 2016
LICENSE Initial commit Jun 28, 2016
Microsoft.TemplateEngine.sln Support sharing JExtensions across projects Feb 22, 2017
NuGet.Config Update mount system Jul 8, 2016
README.md updating readme (#289) Feb 9, 2017
Version.props Fix load strategy for handling locations, update test framework version Jan 23, 2017
appveyor.ps1 updating build to run tests Apr 10, 2016
appveyor.yml Last few name updates May 19, 2016
bin.cmd Updates Jun 1, 2016
build.cmd Adding netci.groovy for jenkins CI. Sep 2, 2016
build.ps1 Update to 1.1 Jan 30, 2017
build.sh More build cleanup Dec 12, 2016
buildfullframework.cmd Minor config changes (#60) Oct 13, 2016
bundle.cmd Simplified config May 29, 2016
dn3build.cmd C++ evaluator using the general evaluator (#55) Nov 9, 2016
dn3build.sh More build cleanup Dec 12, 2016
dn3buildmode-debug.cmd Setup improvements, error handling in runproj May 1, 2016
dn3buildmode-release.cmd Setup improvements, error handling in runproj May 1, 2016
global.json Modifying the projects to add P2P dependencies. Move the generated nu… Sep 2, 2016
harderreset.cmd Installer & build cleanup Dec 21, 2016
harderreset.sh Fix harderreset.sh Dec 12, 2016
hardreset.cmd Installer & build cleanup Dec 21, 2016
netci.groovy Try again to get Linux to run build Sep 16, 2016
setup.cmd Template build Dec 18, 2016
setup.sh removed stray quote Dec 12, 2016

README.md

Overview

This repository is the home for the .NET Core Template Engine. It contains the brains for dotnet new. When dotnet new is invoked, it will call the Template Engine to create the artifacts on disk. Template Engine is a library for manipulating streams, including operations to replace values, include/exclude regions and process if, else if, else and end if style statements.

Info for dotnet new users

You can create new projects with dotnet new, this section will briefly describe that. For more info take a look at Announcing .NET Core Tools Updates in VS 2017 RC.

To get started let's find out what options we have by executing dotnet new --help. The result is pasted in the block below.

$ dotnet new mvc --help

MVC ASP.NET Web Application (C#)
Author: Microsoft
Options:
  -au|--auth           The type of authentication to use
                           None          - No authentication
                           Individual    - Individual authentication
                       Default: None

  -uld|--use-local-db  Whether or not to use LocalDB instead of SQLite
                       bool - Optional
                       Default: false

  -f|--framework
                           1.0    - Target netcoreapp1.0
                           1.1    - Target netcoreapp1.1
                       Default: 1.0

Let's create a new project named "MyAwesomeProject" in the "src/MyProject" directory. This project should be an ASP.NET MVC project with Individual Auth. To create that template execute dotnet new mvc -n MyAwesomeProject -o src/MyProject -au Individual. Let's try that now, the result is below.

$ dotnet new mvc -n MyAwesomeProject -o src/MyProject -au Individual
The template "MVC Application" created successfully.

The project was successfully created on disk as expected in src/MyProject. From here, we can run normal dotnet commands like dotnet restore and dotnet build.

We have a pretty good help system built in, including template specific help (for example dotnet new mvc --help). If you're not sure the syntax please try that, if you have any difficulties please file a new issue.

Now that we've covered the basics of using dotnew new, lets move on to info for template authors and contributors.

How to build and run the latest

If you're authoring templates, or interested in contributing to this repo, then you're likely interested in how to use the latest version of this experience. The steps required are outlined below.

Step 1: Get the SDK for your platform from dotnet/cli

Step 2: Clone this repository to your local machine

Step 3: Run the setup script

When running the setup script, the existing built in command dotnet new will be preserved. A new command dotnet new3 will be enabled which allows you to create files with the latest Template Engine.

Step 4: That's it! Now you can run dotnet new3.

For example, here is the result of running dotnet new3 --help on a Mac (truncated to save space here).

$ dotnet new3 --help
Template Instantiation Commands for .NET Core CLI.

Usage: dotnet new3 [arguments] [options]

Arguments:
  template  The template to instantiate.

<truncated>

Installing templates

Templates can be installed from packages in any NuGet feed, directories on the file system or ZIP type archives (zip, nupkg, vsix, etc.) To install a new template use the command:

dotnet new3 -i {the path to the folder containing the templates}

Basic Commands

Showing help

dotnet new3 --help
dotnet new3 -h
dotnet new3

Listing templates

dotnet new3 --list
dotnet new3 -l
dotnet new3 mvc -l            Lists all templates containing the text "mvc"

Template parameter help

dotnet new3 mvc --help
dotnet new3 mvc -h

Template creation

dotnet new3 MvcWebTemplate --name MyProject --output src --ParameterName1 Value1 --ParameterName2 Value2 ... --ParameterNameN ValueN
dotnet new3 MvcWebTemplate -n MyProject -o src --ParameterName1 Value1 --ParameterName2 Value2 ... --ParameterNameN ValueN

Roadmap

  • Create formal docs
  • Interactive mode (i.e. interactive prompts similar to yo aspnet
  • Integration with Visual Studio One ASP.NET dialog
  • Integration with Visual Studio for Mac for .NET Core projects
  • Integration with yo aspnet
  • Template updates (both required and optional)
  • Visual Studio wizard to enable community members to plug into VS as well
  • Maybe: Visual Studio wizard which can display templates given a feed URL
  • Suggestions welcome, please file an issue