Create your first .Net Core 5.0 WebApi

DotNet Core 5.0

Follow with me!

  • SDK: DotNet Core 5.0 Software Development Kit,
  • Editor: Visual Studio Code, VIM,
  • Container Builder: Podman (low footprint, no daemon needed), or in worst cases use Docker ;)

Create Solution File

dotnet new sln -n green-wave
dotnet new webapi -n green-wave
- “Startup.cs”: Contains all the settings and configurations,
- “Program.cs”: Contains the method “Main”, which is the entry point of the ASP DotNet Core application,
- “green-solution.csproj” defines what libraries are referenced,
- “green-solution/Pages” directory holds example web pages for the application.
dotnet sln green-wave.sln add ./green-wave/green-wave.csproj
dotnet new xunit -n green-wave.Test
dotnet sln green-wave.sln add ./green-wave.Test/green-wave.Test.csproj
dotnet add ./green-wave.Test/green-wave.Test.csproj reference ./green-wave/green-wave.csproj

Build/Test the Solution

dotnet build
dotnet test
dotnet run -p ./green-wave/green-wave.csproj \
--urls=http://127.0.0.1:8080
curl -k http://localhost:8000/weatherforecast?location=detroit

Publish Artifacts

dotnet publish -c Release -o publish
- "green-wave.deps.json": Application runtime dependencies file...
- "green-wave.dll": This is the framework-dependent deployment version of the application, which we're going to use as entrypoint to our application
- "green-wave.exe": Executable version
- "green-wave.runtimeconfig.json": Application's runtime configuration file (DotNet version to use)

What’s next?

Thank You for Reading Me!

--

--

--

Is a Cloud-Native enthusiast with 12 plus years of experience. He’s continuously immersing himself in the latest technology trends & projects.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

<p> Hello World! </p>

How to run local SQLite commands in a Docker Container

Setting up CI/CD Pipeline for a Monolithic Service

To err is human, but how to show it?

INFT is coming! Announcement about our NFT

How to fit a Porsche Engine in a VW Beetle — Migrating Legacy Applications to the Cloud

GitHub Actions Security Best Practices [cheat sheet included]

AppSync: how to error on DynamoDB conditional check failures

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aymen Abdelwahed

Aymen Abdelwahed

Is a Cloud-Native enthusiast with 12 plus years of experience. He’s continuously immersing himself in the latest technology trends & projects.

More from Medium

How to use client-side load balancing in .Net 6

MongoDB C# Driver, clean and manageable database queries using dynamic predicates.

.NET 6 Deployment — Dynamic Variable for AppSettings on Linux environment

Docker Introduction and Architecture