Aller au contenu

ASP.NET Core 10 CLI

De Banane Atomic

Nuget packages management

Run the commands from the solution or project folder.

# list outdated packages
dotnet list package --outdated

# update all outdated packages to to latest stable
dotnet package update

# list the installed packages
dotnet list package

# add a package
dotnet add package <package_name>
dotnet add package <package_name> --version 2.0.0

# remove a package
dotnet remove package <package_name>

Build and deploy

# restore and build with the release configuration
dotnet build --configuration Release

# restore, build and run
dotnet run

# force url and port (default: http://127.0.0.1:5000)
ASPNETCORE_URLS="http://127.0.0.1:5123" dotnet run         # linux
dotnet run --ASPNETCORE_ENVIRONMENT Development            # powershell
$env:ASPNETCORE_URLS="http://127.0.0.1:5123" ; dotnet run  # powershell

New solution / project

# list available templates (webapi, blazor)
dotnet new
# create a new Web API project
dotnet new webapi -o [project-name] --no-https

# create a solution file and folder
dotnet new sln --name MySolution
# add a project to the solution
dotnet sln add ./MyProject/MyProject.csproj

# add a reference to another project
dotnet add reference ../otherproject/otherproject.csproj

Miscellaneous

# get the versions of the installed .NET SDK, Host and runtimes
dotnet --info

# run all the unit tests
dotnet test