.netcore2.0 发布CentOS7
生活随笔
收集整理的這篇文章主要介紹了
.netcore2.0 发布CentOS7
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.一般在windows pc上使用vscode 開發好.netcore 程序如果需要發布到其他平臺需要注意一些事情
首先需要明白2個概念:FDD(Framework-dependent deployment)和?SCD (Self-contained deployment)
2.# FDD?Framework-dependent deployment. As the name implies, framework-dependent deployment (FDD) relies on the presence of a shared system-wide version of .NET Core on the target system. Because .NET Core is already present, your app is also portable between installations of .NET Core. Your app contains only its own code and any third-party dependencies that are outside of the .NET Core libraries. FDDs contain .dll files that can be launched by using the dotnet utility from the command line. For example, dotnet app.dll runs an application named app. 3.#? SCD? Self-contained deployment. Unlike FDD, a self-contained deployment (SCD) doesn't rely on the presence of shared components on the target system. All components, including both the .NET Core libraries and the .NET Core runtime, are included with the application and are isolated from other .NET Core applications. SCDs include an executable (such as app.exe on Windows platforms for an application named app), which is a renamed version of the platform-specific .NET Core host, and a .dll file (such as app.dll), which is the actual application.
參考:https://docs.microsoft.com/en-us/dotnet/core/deploying/deploy-with-cli 4.#?RIDs? Windows RIDs Windows 7 / Windows Server 2008 R2 win7-x64 win7-x86 Windows 8 / Windows Server 2012 win8-x64 win8-x86 win8-arm Windows 8.1 / Windows Server 2012 R2 win81-x64 win81-x86 win81-arm Windows 10 / Windows Server 2016 win10-x64 win10-x86 win10-arm win10-arm64 Linux RIDs Red Hat Enterprise Linux rhel.7-x64 Ubuntu ubuntu.14.04-x64 ubuntu.14.10-x64 ubuntu.15.04-x64 ubuntu.15.10-x64 ubuntu.16.04-x64 ubuntu.16.10-x64 CentOS centos.7-x64 Debian debian.8-x64 Fedora fedora.23-x64 fedora.24-x64 OpenSUSE opensuse.13.2-x64 opensuse.42.1-x64 Oracle Linux ol.7-x64 ol.7.0-x64 ol.7.1-x64 ol.7.2-x64 Currently supported Ubuntu derivatives linuxmint.17-x64 linuxmint.17.1-x64 linuxmint.17.2-x64 linuxmint.17.3-x64 linuxmint.18-x64 1 OS X RIDs osx.10.10-x64 osx.10.11-x64 osx.10.12-x64
參考:https://docs.microsoft.com/zh-cn/dotnet/core/rid-catalog 5.# 修改 .csproj 項目文件?
<RuntimeIdentifiers>win7-x64;centos.7-x64</RuntimeIdentifiers>
完整如下圖:
6.# 直接執行 build 如果依賴項目較多可能會等很久
先執行 dotnet restore 命令
這樣會下載安裝一些依賴項目等完成后
再執行 build 命令
測試下在 windows 下是 ok 的
最后執行publish 指令:
dotnet publish -c Release -r centos.7-x64最后會生成Release版本:
最后生成文件非常多:
下一步使用FTP工具上傳到 CentOS publish 目錄:
?
?最后一步使用 putty 命令執行就可以了
dotnet xxx.dll?
--------------------------------------------------------------------------------------------------------------
注意事項 以上是基于 FDD模式 (感覺4G技術 娃哈哈哈哈)
要提前手工安裝 .netcore 2.0 SDK?
參考命令如下:
# 解壓安裝文件 $ tar -xzf ~/dotnet/dotnet-dev-centos-x64.1.0.0-preview1-002702.tar.gz # 軟連接 ln -s /home/jake/leak/dotnet/dotnet /usr/local/bin # 刪除軟連接 rm -rf /usr/local/bin/dotnet # 查看版本 dotnet --version?
轉載于:https://www.cnblogs.com/welanshan/p/7410429.html
總結
以上是生活随笔為你收集整理的.netcore2.0 发布CentOS7的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: toLua关于委托没有注册的解决方案
- 下一篇: CentOS7服务去Nginx使用-安装