Skip to content

dotnet CLI

CLI

dotnet

  • CLI = command line interface
  • create projects
  • run applications
  • test applications

dotnet new <type>

  • Program.cs - main entrypoint code dotnet run
  • compile application
  • create output
  • run Program.cs
  • dotnet and c# is compiled
  • creates bin directory (binaries) code .
  • code opens vscode
  • . opens current directory (in vscode)
  • change
  • save
  • f5 -> c# add dependency
  • dotnet add <project> reference <dependent project> add package
  • `dotnet add package run a project
  • dotnet run --project <project>

New Project

  1. make solution: ``dotnet new sln -o BuberBreakfast`
  2. make contracts (request/response): dotnet new classlib -o BuberBreakfast.Contracts
  3. make web server: dotnet new webapi -o BuberBreakfast
  4. dotnet build
  5. add contracts and apis to solution: dotnet sln add BuberBreakfast.Contracts BuberBreakfast
    1. (ls -r **/*.csproj for recursive)
  6. add contracts to web server code as dependency: dotnet add BuberBreakfast reference BuberBreakfast.Contracts
  7. build: dotnet build
  8. run: dotnet run BuberBreakfast