question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Epic] Common template features for .NET templates (sln, editorconfig)

See original GitHub issue

Audience: template authors

Background

At the moment a lot of .NET project templates have to manually create similar configuration related to:

  • framework
  • restore post action
  • optional adding of sln
  • language-specific features
  • nullable, global usings and other common MSBuild properties
  • AOT configurations
  • NuGet Packaging Properties (license, package name, authors, etc)

Moreover more common features will be nice to have:

  • optional editorconfig (original intention of the issue)
  • optional gitignore/gitattributes; git init

Implementing all of above is possible but will result in extra ~300 lines configuration in template.json and corresponding testing and maintenance effort. The configuration will be very similar to the same in all the templates.

Technical suggestion

We are considering to create a specific generator for .NET project templates which implicitly supports the features above. All the author needs to do is to opt-in to desired behaviors via corresponding feature flags.

Justification

  • facilitate much easier entry point for template authoring via simpler configuration
  • decrease manual json configuration
  • unify configuration for the items above
  • unify experience with .NET SDK template

original description below Copying Kathleen’s comments from below:

The template team maintains the .NET standard .editorconfig. Logically this is the same one you get with dotnet new .editorconfig. Templates will not include .editorconfig. When the user creates a project, they have the option to use --sln to create the project in a solution (a different feature that this assumes, although it might be later). If this switch is used, a .editorconfig will be placed at the solution level. If the user either creates the new project with a parent directory that has a .sln file, or they use the --sln switch, no .editorconfig will be placed in the project file. Otherwise, it will be. This might be managed by a post action so template authors could skip it, but we think it is probably the best behavior for all project templates.

The part about -sln is probably not relevant. Therefore, it should be considered out of the scope of this issue.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mikadumontcommented, May 25, 2021

Both but my issue is with regards to dotnet new console to include .editorconfig file (.NET) template which has the prepopulated default .NET code style, formatting, and naming conventions: https://docs.microsoft.com/en-us/visualstudio/ide/create-portable-custom-editor-options?view=vs-2019#add-an-editorconfig-file-to-a-project

0reactions
bekir-ozturkcommented, Aug 30, 2021

The details of the design can be found here (internal).

Read more comments on GitHub >

github_iconTop Results From Across the Web

NET default templates for dotnet new - .NET CLI
The following table shows the templates that come pre-installed with the .NET SDK. The default language for the template is shown inside the ......
Read more >
EditorConfig settings - Visual Studio (Windows)
EditorConfig settings take precedence over global Visual Studio ... NET) template to add an EditorConfig file prepopulated with default .
Read more >
What's new in .NET 7 Preview 2 [WIP] · Issue #7107
The entry should include the team name and feature title as the first line as shown in the template below. ## Team Name:...
Read more >
Add template for .editorconfig · Issue #2448 · dotnet/ ...
Generally there are visual studio templates for editorconfig, but dotnet new templateengine does not support .editorconfig items.
Read more >
Looking for a community "standard" .editorconfig with ...
16 votes, 21 comments. I'm fairly new to using C# & .NET (5) and I'm looking into enforcing Code Style checks in our...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found