.NET CLI在Linux上发布后如何运行应用程序 [英] .NET CLI how to run app after publish on Linux

查看:71
本文介绍了.NET CLI在Linux上发布后如何运行应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了大约4个小时进行调查,但仍然找不到运行已发布应用程序的方法( dotnet publish

I spent ~4 hours investigation and still can't find out how to run published application ( dotnet publish )

现在我可以将源下载到我的远程计算机上,然后调用 dotnet构建 dotnet运行-然后是我的应用按预期运行。但是我只想将DLL(或* .so?)发布到我的VPS中,而无需源文件。

Now I can download sources to my remote machine, then call dotnet build and dotnet run - then my app runs as intended. But I want to publish just DLL's (or *.so ?) to my VPS without source files.

官方文档怎么说?要在project.json中定义命令

What official docs says? To define command in project.json

"commands": {
    "web": "Microsoft.AspNet.Server.Kestrel --server.urls http://unix:/var/aspnet/HelloMVC/kestrel.sock",
}

但这是过时的,不是吗?

But it is obsolette, isn't it?

默认样本如何?

在默认VS2015样本解决方案中,它们使用publish-iis,Full .NET框架和IIS服务器,但与在Linux上部署无关。

In default VS2015 sample solution they use publish-iis, Full .NET framework and IIS server, but there is nothing about deployment on linux.

postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]






这是我的dotnet信息


Here is my dotnet info

.NET Command Line Tools (1.0.0-preview1-002702)

Product Information:
 Version:     1.0.0-preview1-002702
 Commit Sha:  6cde21225e

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.10586
 OS Platform: Windows
 RID:         win10-x64

.NET Core RC2

.NET Core RC2

推荐答案

执行以下步骤(从RC2便携式应用程序开始;正常操作):

Do the following steps (starting from a RC2 portable application; the normal one):


  1. 从所有依赖项中删除 type: platform注释(因此它实际上是自包含的,不再依赖于已安装的.NET Core平台)。

  2. 将节点运行时添加到project.json(这样NuGet能够提取必要的平台零件)

  1. Remove the "type": "platform" annotation from all your dependencies (so it is actuall self-contained and no longer rely on a installed .NET Core platform).
  2. Add a node runtimes to your project.json (so NuGet is able to pull the necessary platform parts to your local machine)

示例:

"runtimes": {
  "osx.10.11-x64": { },
  "win10-x64": { },
  "ubuntu.14.04-x64": { }
}


  • dotnet恢复(确保新的运行时在本地可用。

  • dotnet restore (to make sure the new runtimes are locally available).

    我按照.NET Core文档

    这篇关于.NET CLI在Linux上发布后如何运行应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆