<>一:打开命令行

运行一下:
dotnet new --list

根据模板创建项目
dotnet new console -n helloword

那么看一下dotnet core 创建的解决方案helloword.csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> </PropertyGroup> </Project>
修改为
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework> <RuntimeIdentifier>win10-x64</
RuntimeIdentifier> </PropertyGroup> </Project>
执行命令生成exe文件
dotnet build
执行命令启动程序
dotnet run
改造控制台程序变成web执行
<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>
修改控制台程序
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();
} } }
继续启动程序

这样就实现了web启动

技术
©2020 ioDraw All rights reserved
46岁微软:从盖茨缔造帝国到纳德拉复兴第二章 初识C语言常量2021前端高频面试题(一定要看哦!!!)滤波器,窗函数以及切比雪夫逼近法新手快速了解冒泡排序、插入排序的详解pytorch训练过程中GPU利用率低Golang经典面试题初识Mongdb之数据查询篇(三)人类第一架火星直升机正在部署 择机在这颗异域星球首飞python判断两个列表(list)中的值是否相同([1,2,3]和[3,2,1])