Skip to content

Instantly share code, notes, and snippets.

@DiomedesDominguez
Forked from jonlabelle/dotnetcheatsheet.md
Last active March 16, 2024 12:43
Show Gist options
  • Save DiomedesDominguez/835b0fdc720080a8165fc216015db06a to your computer and use it in GitHub Desktop.
Save DiomedesDominguez/835b0fdc720080a8165fc216015db06a to your computer and use it in GitHub Desktop.
Dotnet core Cheat Sheet
title subtitle author date source notoc
Dotnet Core Cheat Sheet
This cheat sheet is courtesy Ben Day
Ben Day
August 22, 2017
false

This cheat sheet is courtesy Ben Day and is available here. This Markdown file is just for easy reference for programmers.

What follows are the excerpts from Ben's blog.

The nice thing about the items on this 'cheat sheet' is that they work on Windows, Mac, and Linux. Note 2/13/2017: Want an example script? Check this out.

Create a new Solution (*.sln)

cd {directory where you want to create the *.sln file}
dotnet new sln

Create a new Class Library (*.csproj)

cd {directory where you want to create the *.csproj file}
dotnet new classlib

Create a new Class Library (*.csproj) targeting .NET Core

cd {directory where you want to create the *.csproj file}
dotnet new classlib -f netcoreapp2.1

Create a new ASP.NET MVC project

cd {directory where you want to create the *.csproj file}
dotnet new mvc

Create a new ASP.NET MVC project targeting .NET Core

cd {directory where you want to create the *.csproj file}
dotnet new mvc -f netcoreapp2.1

Create a new MSTest unit test project targeting .NET Core

cd {directory where you want to create the *.csproj file}
dotnet new mstest -f netcoreapp2.1

Create a new xUnit testing project

dotnet new xunit

Add a project (*.csproj) to a Solution (*.sln)

cd {directory that contains the *.sln file}
dotnet sln MySolutionFile.sln add .\src\MySolution.WebUi\MySolution.WebUi.csproj

Add all projects (*.csproj) in a directory to a Solution (*.sln)

cd {directory that contains the *.sln file and root of all *.csproj}
for project in $(find . -name "*.csproj"); do dotnet sln add $project; done

Add a reference from one Project to another

cd {directory that contains the source/from *.csproj file}
dotnet add reference ..\MySolution.Api\MySolution.Api.csproj

Restore NuGet dependencies so that you can be ready to do a build

cd {directory that contains the *.sln file or *.csproj file}
dotnet restore

Use dotnet to do a build

cd {directory that contains the *.sln file or *.csproj file}
dotnet build
@DiomedesDominguez
Copy link
Author

New command code added

@DiomedesDominguez
Copy link
Author

New command code added

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