1、cd web项目根目录
2、生成依赖:dotnet restore
2、生成项目:dotnet build
3、运行项目:dotnet run,浏览器打开项目网址
4、发布项目
# 发布Release配置,包括 .net core 运行时,分别发布到 linux 和 windows
dotnet publish -c Release --self-contained -r linux-x64
dotnet publish -c Release --self-contained -r win-x64
# 发布Release配置,包括 .net core 运行时,指定目标框架 netcoreapp2.2
dotnet publish -c Release -f netcoreapp2.2 --self-contained -r linux-x64
dotnet publish -c Release -f netcoreapp2.2 --self-contained -r win-x64
# 发布Release配置,不包括 .net core 运行时
dotnet publish -c Release --self-contained false -r linux-x64
dotnet publish -c Release --self-contained false -r win-x64
# 发布Release配置,不包括 .net core 运行时,指定输出目录
dotnet publish -c Release --self-contained false -r linux-x64 -o C:\Here\Spany\publish\linux-x64
dotnet publish -c Release --self-contained false -r win-x64 -o C:\Here\Spany\publish\win-x64
VS2019打开项目加载失败:无法找到 .NET Core SDK
执行build.cmd看到如下报错信息
A compatible installed .NET Core SDK for global.json version [2.2.607] from [C:\
Users\Administrator\Desktop\ID4\IdentityServer4\global.json] was not found
Install the [2.2.607] .NET Core SDK or update [C:\Users\Administrator\Desktop\ID
4\IdentityServer4\global.json] with an installed .NET Core SDK:
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.505 [C:\Program Files\dotnet\sdk]
2.1.602 [C:\Program Files\dotnet\sdk]
2.1.607 [C:\Program Files\dotnet\sdk]
2.2.202 [C:\Program Files\dotnet\sdk]
3.0.100 [C:\Program Files\dotnet\sdk]
3.1.101 [C:\Program Files\dotnet\sdk]
找到解决方案根目录下 global.json文件,内容如下:
{
"sdk": {
"version": "3.1.301"
}
}
将版本号改成电脑中已经安装的sdk版本
*
*