<> One : Open command line
Run it :
dotnet new --list
Create project from template
dotnet new console -n helloword
So take a look dotnet core Solutions created helloword.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> </PropertyGroup> </Project>
Revised as
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> <RuntimeIdentifier>win10-x64</
RuntimeIdentifier> </PropertyGroup> </Project>
Execute command generation exe file
dotnet build
Start program execution command
dotnet run
Transform the console program into web implement
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> <RuntimeIdentifier>win10-x64</
RuntimeIdentifier> </PropertyGroup> <ItemGroup> <FrameworkReference Include=
"Microsoft.AspNetCore.App"/> </ItemGroup> </Project>
Modify console program
using Microsoft.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft
.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions
.Hosting; using System; namespace helloword { class Program { static void Main(
string[] args) { WebHost.CreateDefaultBuilder().UseKestrel().Configure(app =>
app.Run( context => context.Response.WriteAsync("hello word!") )).Build().Run();
} } }
Continue to start the program
And that's it web start-up
Technology
Daily Recommendation