Linux and WSL
Linux is popular operating system that runs millions of server, desktop and mobile devices. As a windows operating system user, if you liked to use any linux based operating system, you had to setup a dual bootup in your machine or use VM or buy separate device with linux OS.But, windows has a special feature Windows Subsystem for Linux ( WSL), which allows you to run a GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup. After you enable WSL you can, install Ubuntu 20.04.2 LTS from the microsoft store.
Visual Studio Code (VsCode) and WSL extension
Visual Studio Code is a lightweight but powerful source code editor which runs on your desktop and is available for Windows, macOS and Linux. Running Visual Studio Code on Windows
After you open a VSCode, Go to Extensions tab in left tab, and install Remote - WSL from microsoft, Remote - WSL - Visual Studio Marketplace
Reopen your VSCode, and allow Remote - WSL to connect with Ubuntu 20.04.2 remote. Open "New Terminal" to open linux terminal.
Install .Net 5 in Ubuntu
Follow this intruction for complete guidance, Install .NET on Ubuntu - .NET | Microsoft Docs
You need to install .NET SDK to be able to build and run the .net project. Run following command in the terminal,
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
and,
sudo apt-get update; \
sudo apt-get install -y apt-transport-https && \
sudo apt-get update && \
sudo apt-get install -y dotnet-sdk-5.0
You can validate the .net installed in your ubuntu by running,
dotnet --version
Create Asp.net Core 5 Web Api Project
After you have installed .Net SDK, you can use .Net CLI out of the box. You can run,
dotnet new webapi -o YourDotNetApi
You can go inside a YourDotNetApi directory, and run,
dotnet run
which will run your sample web api project in localhost 5001 port
Comments
Post a Comment