[英]Deploying .net Core web app to ubuntu linux
I had an app I was developing in asp.net 4.5 and I wanted to move it to asp.net core and run on linux server (ubuntu). 我有一个我在asp.net 4.5中开发的应用程序,我想将其移至asp.net核心并在linux服务器(ubuntu)上运行。
I've been having a number of challanges and unfortunately current documentation is not helpful. 我遇到了很多挑战,但是不幸的是,当前文档没有帮助。
so... 所以...
How should I package the app? 我应该如何打包应用程序?
The tech docs suggest building with the following command 技术文档建议使用以下命令进行构建
dnu publish --runtime dnx-coreclr-linux-x64.1.0.0-rc1-update1
dnu发布-运行时dnx-coreclr-linux-x64.1.0.0-rc1-update1
However I tried this on my local machine and it didn't have option to deploy linux version. 但是,我在本地计算机上尝试了此操作,但没有选择部署Linux版本。 When I run on server it comes up with a number of problems (covered later).
当我在服务器上运行时,会遇到很多问题(稍后会介绍)。 So should I do this on server or get working on local machine.
因此,我应该在服务器上执行此操作还是在本地计算机上工作。
NB: I read in another stack overflow question that as long as its coreclr it doesn't matter whether its win or linux? 注意:我在另一个堆栈溢出问题中读到,只要它的coreclr不管它的胜利还是Linux都没有关系?
I imagine after this is answered more questions will emerge..I've had so many issues with Core I'm wondering whether anybody has actually manged to deploy on app to Linux environment! 我想答案回答之后,还会出现更多问题。我在Core上遇到了很多问题,我想知道是否有人真的愿意将应用程序部署到Linux环境!
Any help would be greatly appreciated! 任何帮助将不胜感激!
Update 更新
To provide further information current runtimes on local machine are... 为了提供更多信息,本地计算机上的当前运行时是...
Active Version Runtime Architecture Location Alias 活动版本运行时体系结构位置别名
------ ------- ------- ------------ -------- ----- ------ ------- ------- ------------ -------- -----
1.0.0-beta5 clr x64 C:\\Users\\Alex.dnx\\runtimes 1.0.0-beta5 clr x64 C:\\ Users \\ Alex.dnx \\ runtimes
1.0.0-beta5 clr x86 C:\\Users\\Alex.dnx\\runtimes 1.0.0-beta5 clr x86 C:\\ Users \\ Alex.dnx \\ runtimes
1.0.0-beta5 coreclr x64 C:\\Users\\Alex.dnx\\runtimes 1.0.0-beta5 coreclr x64 C:\\ Users \\ Alex.dnx \\ runtimes
1.0.0-beta5 coreclr x86 C:\\Users\\Alex.dnx\\runtimes 1.0.0-beta5 coreclr x86 C:\\ Users \\ Alex.dnx \\ runtimes
1.0.0-rc1-update1 clr x64 C:\\Users\\Alex.dnx\\runtimes 1.0.0-rc1-update1 clr x64 C:\\ Users \\ Alex.dnx \\ runtimes
1.0.0-rc1-update1 clr x86 C:\\Users\\Alex.dnx\\runtimes 1.0.0-rc1-update1 clr x86 C:\\ Users \\ Alex.dnx \\ runtimes
1.0.0-rc1-update1 coreclr x64 C:\\Users\\Alex.dnx\\runtimes 1.0.0-rc1-update1 coreclr x64 C:\\ Users \\ Alex.dnx \\ runtimes
1.0.0-rc1-update1 coreclr x86 C:\\Users\\Alex.dnx\\runtimes 1.0.0-rc1-update1 coreclr x86 C:\\ Users \\ Alex.dnx \\ runtimes
* 1.0.0-rc1-update2 clr x86 C:\\Users\\Alex.dnx\\runtimes default 1.0.0-rc1-update2 coreclr x86 C:\\Users\\Alex.dnx\\runtimes * 1.0.0-rc1-update2 clr x86 C:\\ Users \\ Alex.dnx \\ runtimes默认1.0.0-rc1-update2 coreclr x86 C:\\ Users \\ Alex.dnx \\ runtimes
I want to compile it as coreclr linux....however when I run the dnu publish command above it says runtime doesn't exist even though I update coreclr from nuget? 我想将其编译为coreclr linux。...但是,当我在上面运行dnu publish命令时,即使我从nuget更新coreclr,运行时也不存在?
Do I need to specify an OS (linux or windows) when I build it or will a single published app run on both if its coreclr? 构建它时是否需要指定一个操作系统(Linux或Windows),或者如果一个发布的应用程序的coreclr可以在两个操作系统上运行?
This runs fine when imported into Azure but doesn't work when deployed to linux 将其导入Azure时运行良好,但部署到linux时不起作用
OK, here's how to: 确定,方法如下:
Once you can publish it from Visual Studio, close Visual Studio and do the following 一旦可以从Visual Studio中发布它,请关闭Visual Studio并执行以下操作
open cmd.exe (Windows-Key + R) 打开cmd.exe(Windows键+ R)
cd "directory of your .sln file" cd“ .sln文件的目录”
dotnet restore -r ubuntu.16.04-x64 dotnet恢复-r ubuntu.16.04-x64
dotnet build -r ubuntu.16.04-x64 dotnet build -r ubuntu.16.04-x64
dotnet publish -f netcoreapp1.1 -c Release -r ubuntu.16.04-x64 dotnet发布-f netcoreapp1.1 -c版本-r ubuntu.16.04-x64
Your application should now be in folder bin/publish 您的应用程序现在应该在文件夹bin / publish中
A list of RIDs (-r) can be obtained here and here . RID(-r)的列表可在此处和此处获得。
If you want to develop on Linux, run 如果要在Linux上进行开发,请运行
apt-get install dotnet-dev-1.0.1
and the dotnet-utility should run on Linux. 并且dotnet-utility应该在Linux上运行。
Note that if you get 请注意,如果您得到
C:\\Program Files\\dotnet\\sdk\\1.0.0\\Microsoft.Common.CurrentVersion.targets(2865,5): error MSB3554: Cannot write to the output file "C:\\path\\to\\your\\project\\obj\\Debug\\netcoreapp1.1\\YOUR_APP.Properties.Resources.resources".
C:\\ Program Files \\ dotnet \\ sdk \\ 1.0.0 \\ Microsoft.Common.CurrentVersion.targets(2865,5):错误MSB3554:无法写入输出文件“ C:\\ path \\ to \\ your \\ project \\ obj \\调试\\ netcoreapp1.1 \\ YOUR_APP.Properties.Resources.resources”。 Positive number required.
需要正数。
Build FAILED.
建立失败。
when you run the build or publish command, just run the command again. 当您运行build或publish命令时,只需再次运行该命令即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.