Disclaimer: I am a consultant at Amazon Web Services, and this is my personal blog. The opinions expressed here are solely mine and do not reflect the views of Amazon Web Services (AWS). Any statements made should not be considered official endorsements or statements by AWS.
While working with .NET Core, it sometimes makes your life easy if know a few important .NET CLI commands.
Here are some of the most commonly used .NET CLI commands.
// To check current .NET info dotnet --info // To check installed SDKs dotnet --list-sdks // To check installed runtimes dotnet --list-runtimes
// To restore NuGet packages dotnet restore
You don't have to run
dotnet restore because it's run implicitly by all commands that require a restore to occur, such as
dotnet publish, and
dotnet pack. To disable implicit restore, use the
// To create a new dotnet application dotnet new <template> --output <output-directory> // To create a new console application dotnet new console --output sample1 // To create a new web application dotnet new webapp -o aspnetcoreapp
// To build a solution dotnet build solution.sln -c "Debug" // To build a project dotnet build project.csproj -c "Debug"
// To publish an application dotnet publish -c "Release" // To publish a project dotnet publish "AccountingSoftware.API" -c "Release" -f "net6.0" --self-contained false
dotnet publish compiles the application, reads through its dependencies specified in the project file, and publishes the resulting set of files to a directory.
// To run published app directly dotnet MyApp.dll // To run an application in debug mode dotnet run [--project sample1] [--launch-profile "launch-profile-name"]
dotnet buildand then runs the app from the output directory
dotnet build+ execute launch-profile command
That's all 🙂