I have created a new VM in Linux and wanted to run my first .Net 8 project. So for that first I have installed Visual Studio Code and installed C# Dev Kit
C# Dev Kit helps you manage your code with a solution explorer and test your code with integrated unit test discovery and execution, elevating your C# development experience wherever you like to develop (Windows, macOS, Linux, and even in a Codespace).
However, after installing the C# Dev Kit, I was asked to install the .Net SDK. I have tried to install it using the dotnet-install.sh but it did not succeed. So I tried the suggested command using Snap as shown below
sudo snap install dotnet-sdk --classic
This has installed dotnet-sdk 8 in my Linux system. We can check that using the command dotnet --version which gives the version as 8.0.202 for me.
After that, I tried searching for a project template .Net Core Web API with Angular. But from .Net 8 they have discontinued that template. The next option for us is to create a separate .Net Core Web API project and a separate Angular project. This is a better option because we will have the total separation; thus, there is no proxy involved and we can separately host them.
So then I created the .Net Web API project using the command `dotnet new webapi`.
Once done I can see some files created for me. Next, I tried to run ` dotnet build ` and it worked perfectly. After that I tried to run the project using the command `dotnet run` but it failed, without giving any expectations.
So to fix that I have to add inside PropertyGroup in the .csproj file.
<UseAppHost>false</useAppHost>
The `UseAppHost` property controls whether or not a native executable is created for deployment. A native executable is required for self-contained deployments. A framework-dependent executable is created by default. Set the `UseAppHost` property to `false` to disable the generation of the executable.
After this when I ran the command `dotnet run` I could see that the project was running and view the result in the endpoint http://localhost:5230/weatherforecast.
In this way, I start my first project of .Net 8 in Linux Machine using Visual Studio Code.
No comments:
Post a Comment