Starting from scratch

TL;DR

Prepare your machine

On a MacOs, to prepare your machine to be ready for .NET Core development, go get a really great tool from Pivotal: Workstation Setup

git clone https://github.com/pivotal/workstation-setup
cd workstation-setup
chmod +x setup.sh

# Run the script that specifically downloads dotnet dependencies alongside common tooling
./setup.sh dotnet

If you’d like a leaner install, refer Installing the .NET Core SDK section to get started.

Creating a Solution

To create a new solution, use the .NET Core CLI to generate it:

dotnet new sln --name [name-of-your-solution] --output [path-to-new-solution-on-file-system]

# E.g.
dotnet new sln --name NeverendingTeaShop --output NeverendingTeaShop/

This command creates a new folder in the directory where you ran the command with the given name that was passed in via the output flag.

Initializing a Git repository

When navigating into the Solution folder, now is the optimal time to initialize the repository via

git init

Create an ignore file

Now that your project is a Git tracked code base, let’s make sure to create a .gitignore file specifically tailored for .NET Core and C#.

Simply run the following:

curl https://www.toptal.com/developers/gitignore/api/visualstudio > .gitignore

Alternatively, go to gitignore.io and copy the VisualStudio ignore file and paste it into an empty .gitignore within your Solution.

Add an EditorConfig

EditorConfig configuration allows you to commit and track your code formatting style of your project. It’s important to make this decision early on (if you can!) of how your code should format, so anyone who contributes knows exactly what the formatting should be and the task of prettifying is left to the IDE.

Microsoft has published its own example EditorConfig file for .NET projects

Create an .editorconfig file and run the following:

curl https://gist.githubusercontent.com/ddubson/754257ef0b6037d2710b7750f0747ead/raw/513ef70ae856a4e5c30e5a4abd50c22c48d89d3f/.editorconfig > .editorconfig