DotNet Core CLI May 17, 2021 Create Solution
Create Projects
1
2
3
dotnet new classlib -o ToasterLib
dotnet new mstest -o ToasterTests
dotnet new console -o ToasterConsole
Show help
Show all available project types
1
2
dotnet --help sln
dotnet new -l
show available dotnet runtimes and sdks
1
2
dotnet --list-runtimes
dotnet --list-sdks
New Solution :
1
2
3
md MyNewSolutionFolder
cd MyNewSolutionFolder
dotnet new sln
new Project :
1
dotnet new projecttype -n projectName
Add Projects to solution
1
2
dotnet sln add Folder\project.csproj
dotnet sln Toaster.sln add .\ToasterLib\ToasterLib.csproj
Add Reference
1
dotnet add reference ..\ToasterLib\ToasterLib.csproj
Add Package
1
dotnet add package Microsoft.AspNetCore.App.Ref
Check Version
1
2
dotnet --version
dotnet --info
Run application
1
2
Go in the folder of starting project
dotnet run
Auto run starting project :
Compile :
1
2
dotnet compile --native (compile into a single binary file)
dotnet compile --native --cpp (Optimizes using c++ code generator)
Publish in a Docker Container :
1
dotnet publish --os linux --arch x64 -p:PublishProfile=DefaultContainer -c Release
Publish in a Self-Contained
1
dotnet publish --runtime win-x64 --self-contained true
(RID win-x64 must be in the project file.)
Running Tests
1
2
3
4
5
6
** Run all tests
dotnet test solution.sln
** Run a specific test
dotnet test --filter FullyQualifiedName~Project.Namespace.Class.Method
** All the tests from a class
dotnet test --filter FullyQualifiedName~Project.Namespace.Class
References Microsoft .Net Core CLI
Microsoft .NET RID Catalog
Add porjects
Dotnet Core CLI Test commands