I am new to dotnet core and I have tried to view the help of dotnet cli but does not seem to find an answer. How do we add a new class file to a dotnet core console app from dotnet CLI ?
3 Answers
You can create your own custom templates for dotnet new (tutorial):
https://learn.microsoft.com/en-us/dotnet/core/tutorials/cli-templates-create-item-template
A list of samples of varying complexity can be found here....
https://github.com/dotnet/dotnet-template-samples
End of answer.
Non-answer
You didn't ask this but since vscode is a popular C# editor for people using dotnet new, if you happen to be using vscode you can create a new class file by typing e.g.
var myEye = new MyEye { color = "blue" };
Hit 'ctrl+.' over MyEye and select the option to create a new class in a file. You should see it created complete with properties and namespace.
Comments
You can add class using this extension: https://marketplace.visualstudio.com/items?itemName=jchannon.csharpextensions
Comments
One way that we can create a class from VSCode using a extension that is C# Extensions. this will help to create a new class into our solution.
Program.csmanually in your file explorer, or in cli:touch Program.csorvim Program.cs. Read more here: learn.microsoft.com/en-us/dotnet/core/tutorials/…