.Net Core 如何在 Windows Server 2012 R2 Standard 环境中安装部署

一、服务器信息
系统:Windows Server 2012 R2 Standard
内存:32G
系统类型:64位

二、 安装步骤
a. 服务的发布
选中项目,右键点击发布后,配置如下
.Net Core 如何在 Windows Server 2012 R2 Standard 环境中安装部署

点击发布,然后再发布的时候会检查是否有编译错误,如果没有问题,会在控制台中输出如下:
.Net Core 如何在 Windows Server 2012 R2 Standard 环境中安装部署

打开发布的文件夹,并复制到服务器上
服务器需要安装好IIS(不会的百度)
.Net Core 服务与.Net Framework的服务 在IIS上如何挂载,模式时一样的。唯一的区别就是.Net Core的应用程序池必须是无托管代码
.Net Core 如何在 Windows Server 2012 R2 Standard 环境中安装部署

然后浏览器输入http://localhost:8001/(以实际添加网站的端口号为主)则出现页面,至此整个发布完成了。
.Net Core 如何在 Windows Server 2012 R2 Standard 环境中安装部署

b. 服务器插件安装
dotnet-hosting-3.1.1-win.exe
dotnet-runtime-3.1.1-win-x64.exe
Microsoft Visual C++ 2015 Redistributable (x64) - 14.0.23026
以上三个插件都需要安装成功才行,可以在服务器上打开cmd命令,执行 dotnet --info,如图,代表已成功安装
.Net Core 如何在 Windows Server 2012 R2 Standard 环境中安装部署

三、注意事项
在windows操作系统上部署.Net Core接口或者网页时,需要注意一点:
dotnet-hosting-3.1.1-win.exe、
dotnet-runtime-3.1.1-win-x64.exe
这两个版本一定要一致。

  1. 安装Microsoft Visual C++ Redistributable 2015(VC14),但下载安装时报错“安装失败……0x80240017 - 未指定的错误”。
    解决办法:安装完以下插件后Microsoft Visual C++ Redistributable 2015才能安装成功
    clearcompressionflag.exe  
    Windows8.1-KB2919442-x64.msu       
    Windows8.1-KB2919355-x64.msu(忘记是否有安装了) 
    Windows8.1-KB2932046-x64.msu        
    Windows8.1-KB2934018-x64.msu        
    Windows8.1-KB2937592-x64.msu        
    Windows8.1-KB2938439-x64.msu        
    Windows8.1-KB2959977-x64.msu

2.在发布.Net Core 程序时,出现如下问题: It was not possible to find any compatible framework version The specified framework ‘Microsoft.NETCore.App’, version ‘2.1.1’ was not found. - Check application dependencies and target a framework version installed at: - Alternatively, install the framework version ‘2.1.1’.
**解决办法:**安装的.net core SDK的安装包的版本与程序中的.net core版本不兼容,两者版本需要保持一致