Building a .NET Core app via command line, so that it works on a machine without .NET Core installed

爷,独闯天下 提交于 2019-11-29 02:53:34

Problem solved!
I posted it on the issue tracker of the .NET Core command line tools, and it turned out that it was a bug in dotnet publish - it didn't bundle the C++ runtime, which is needed to execute the compiled app on a machine without .NET Core installed.

  • The temporary solution was to install the C++ runtime.

  • The "real" solution was made in a pull request three days ago, which is included in the latest installer now.
    With this version, dotnet publish does bundle the C++ runtime, so the result will work on a machine without .NET Core.

For dnu:

There's an option for dnu publish called --runtime that specifies the runtime to include when publishing. You would use the full runtime name with the command, e.g.:

dnu publish --runtime dnx-clr-win-x86.1.0.0-rc1

For dotnet:

You don't need to specify the runtime or framework versions -- by default, dotnet publish will use the framework from project.json and the current runtime flavor. However, the documentation states that:

dotnet-publish command also requires certain dependencies in the project.json to work. Namely the Microsoft.NETCore.Runtime package must be referenced as a dependency in order for the command to copy the runtime files as well as the application's files to the published location.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!