Top Related Projects
ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
Windows Forms is a .NET UI framework for building Windows desktop applications.
Visual Studio Code
Quick Overview
The .NET Templating project is a framework for creating and applying templates to generate source code and other text-based artifacts. It is used as the underlying engine for the .NET CLI's dotnet new
command, which allows developers to quickly scaffold new projects based on predefined templates.
Pros
- Extensibility: The templating engine is designed to be highly extensible, allowing developers to create custom templates and integrate them into the .NET CLI.
- Cross-platform: The .NET Templating project is cross-platform, supporting Windows, macOS, and Linux.
- Flexibility: The templating engine supports a wide range of input and output formats, including text, JSON, and XML.
- Integration with .NET CLI: The .NET Templating project is tightly integrated with the .NET CLI, providing a seamless experience for developers working with project templates.
Cons
- Learning Curve: The templating engine has a relatively steep learning curve, especially for developers who are new to the concept of code generation and templating.
- Limited Documentation: The project's documentation could be more comprehensive, making it challenging for new users to get started.
- Performance: In some cases, the templating engine may have performance issues when working with large or complex templates.
- Dependency on .NET CLI: The .NET Templating project is closely tied to the .NET CLI, which means that it may not be suitable for use in non-CLI-based environments.
Getting Started
To get started with the .NET Templating project, you can follow these steps:
- Install the .NET SDK on your machine.
- Open a terminal or command prompt and navigate to the directory where you want to create your new project.
- Run the following command to create a new project based on a template:
dotnet new <template-name>
Replace <template-name>
with the name of the template you want to use, such as console
, web
, or classlib
.
- The .NET CLI will generate the necessary files and folders for your new project based on the selected template.
- Open the generated project in your preferred code editor and start building your application.
For more advanced usage, you can explore the .NET Templating project's documentation to learn how to create and customize your own templates.
Competitor Comparisons
ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
Pros of dotnet/aspnetcore
- Comprehensive framework for building modern web applications and services
- Extensive documentation and community support
- Seamless integration with other .NET technologies
Cons of dotnet/aspnetcore
- Larger codebase and more complex to set up compared to dotnet/templating
- Steeper learning curve for developers new to the .NET ecosystem
- Potential performance overhead for smaller or simpler web applications
Code Comparison
dotnet/templating:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
}
dotnet/aspnetcore:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
});
}
Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
Pros of dotnet/sdk
- Provides a comprehensive set of tools and libraries for building .NET applications, including the .NET CLI, MSBuild, and the .NET runtime.
- Offers a consistent and reliable development experience across different platforms and .NET versions.
- Supports a wide range of project types, including console applications, web applications, and libraries.
Cons of dotnet/sdk
- The SDK is a larger and more complex project compared to dotnet/templating, which may make it more challenging to contribute to or understand for new developers.
- The SDK's focus on providing a broad set of functionality may result in a steeper learning curve for some developers, especially those new to .NET.
Code Comparison
dotnet/sdk:
public static int Main(string[] args)
{
try
{
return MainCore(args);
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.ToString());
return 1;
}
}
private static int MainCore(string[] args)
{
// ...
}
dotnet/templating:
public static int Main(string[] args)
{
try
{
return MainCore(args);
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.ToString());
return 1;
}
}
private static int MainCore(string[] args)
{
// ...
}
Windows Forms is a .NET UI framework for building Windows desktop applications.
Pros of dotnet/winforms
- Provides a mature and well-established Windows desktop application development framework.
- Offers a rich set of UI controls and components for building feature-rich desktop applications.
- Integrates seamlessly with the .NET ecosystem, allowing developers to leverage existing .NET libraries and tools.
Cons of dotnet/winforms
- Perceived as a legacy technology, with a focus on traditional desktop applications.
- May have a steeper learning curve for developers more familiar with modern web-based or cross-platform development.
- Limited support for newer UI design patterns and technologies compared to more recent frameworks.
Code Comparison
dotnet/templating:
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
dotnet/winforms:
public class Form1 : Form
{
private Button button1;
public Form1()
{
this.button1 = new Button();
this.button1.Text = "Click me";
this.button1.Click += Button1_Click;
this.Controls.Add(this.button1);
}
private void Button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Button clicked!");
}
}
Visual Studio Code
Pros of VSCode
- Extensive plugin ecosystem with thousands of extensions available
- Highly customizable with a wide range of settings and themes
- Excellent support for a variety of programming languages and frameworks
Cons of VSCode
- Larger codebase and resource-intensive compared to dotnet/templating
- Potential privacy concerns due to Microsoft's involvement and data collection
Code Comparison
dotnet/templating:
public static void Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
host.Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
VSCode:
function main() {
const app = new App();
app.start();
}
class App {
start() {
// Initialize the application
}
}
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Overview
This repository is the home for the .NET Template Engine. It contains the libraries for template instantiation and template package management used in dotnet new
and New Project Dialog and New Item Dialog in Visual Studio and Visual Studio for Mac. The libraries are also distributed as the NuGet packages on nuget.org.
The key packages are:
Package name | Description |
---|---|
Microsoft.TemplateEngine.Edge | The template engine infrastructure: managing template packages, templates, components, executing template. Main API surface for the products aiming to use template engine. See 'Inside Template Engine' article for more information. |
Microsoft.TemplateEngine.Abstractions | Contains the main contracts between Edge and components |
Microsoft.TemplateEngine.Orchestrator.RunnableProjects | The template generator based on template.json configuration |
Microsoft.TemplateSearch.Common | Facilitates template packages search on nuget.org |
Microsoft.TemplateEngine.IDE | Lightweight API overlay over Microsoft.TemplateEngine.Edge . |
Microsoft.TemplateEngine.Authoring.Tasks | Authoring tools: MSBuild tasks for template authoring |
Microsoft.TemplateEngine.Authoring.CLI | Authoring tools: dotnet CLI tool with utilities for template authoring |
Microsoft.TemplateEngine.Authoring.TemplateVerifier | Authoring tools: snapshot testing framework for the templates |
dotnet new
dotnet new
CLI is now located in dotnet/sdk repo.
The issues for dotnet new
CLI UX should be opened in that repository.
Template Content Repositories
.NET default templates are not located in this repository. The templates are located in the following repositories:
Templates | Repository |
---|---|
Common project and item templates | dotnet/sdk |
ASP.NET and Blazor templates | dotnet/aspnetcore |
ASP.NET Single Page Application templates | dotnet/spa-templates |
Aspire templates | dotnet/aspire |
WPF templates | dotnet/wpf |
Windows Forms templates | dotnet/winforms |
Test templates | dotnet/test-templates |
MAUI templates | dotnet/maui |
Issues for the template content should be opened in the corresponding repository. Suggestions for new templates should be opened in closest repository from the list above. For example, if you have a suggestion for new web template, please create an issue in dotnet/aspnetcore repository.
How to author the templates
This repository contains a lot of useful information on how to create the templates supported by dotnet new
, Visual Studio
and other tools that uses template engine.
The starting point tutorial on how to create new templates is available in Microsoft Learn. More advanced information can be found in the Wiki or docs folder in the repo.
Still have a question about template authoring? Do not hesitate to open new discussion in GitHub Template Authoring.
Authoring Tools
Besides the actual implementation of .NET Template Engine, the repo contains various tools that help to author the templates. They are not shipped together with .NET SDK, but available on NuGet.org. More information can be found here
Template Samples
We have created dotnet template samples, which shows how you can use the template engine to create new templates. The samples are setup to be stand alone for specific examples. More documentation can be found in the Wiki.
Contributing
We welcome contributions! You can contribute by:
- creating the issue
- starting the discussion
- contributing by creating the PR that fixes the issue or implements new feature
See our good first issue candidates for the list of issues we consider as good starting point for first contribution to the repo.
See our help wanted issues for a list of issues we think are great for community contribution.
We have a number of features where we are actively looking for the feedback. They are marked with gathering-feedback
label.
If you think they are useful for your templates, please let us know in comments or by reacting on those.
Check out our contributing page to learn more details.
How to build, run & debug
Check out our contributing page to learn how you can build, run and debug.
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoftâs Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-partyâs policies.
Top Related Projects
ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
Windows Forms is a .NET UI framework for building Windows desktop applications.
Visual Studio Code
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot