Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

How to create a scaffold for .NET project

Create the folders

mkdir MyProject

cd MyProject

mkdir src test

Create the project files

dotnet new classlib -o src/Library

dotnet new xunit -o test/Library.Tests

dotnet add test/Library.Tests/Library.Tests.csproj reference src/Library/Library.csproj

Making a Web API

dotnet new webapi -o src/WebApi

Making a console application

dotnet new console -o src/MyConsole

Run the tests

dotnet test test/Library.Tests/Library.Tests.csproj

Or run and watch for changes

dotnet watch -p test/Library.Tests/ test

Create the solution file

-n is optional, will default to folder name

dotnet new sln -n MyProject

Add projects to solution

dotnet sln MyProject.sln add src/Library/Library.csproj test/Library.Tests/Library.Tests.csproj

Run tests from solution

dotnet test MyProject.sln

Or run and watch tests from solution

dotnet watch -p MyProject.sln test

Run console application with input file

dotnet run -p Console.csproj < input.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment