在Ubuntu上运行独立的ASP .NET Core应用程序 [英] Running a self-contained ASP .NET Core application on Ubuntu

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

问题描述

我已经发布了一个ASP .NET Core应用程序,作为针对Ubuntu的自包含应用程序.该发布似乎工作正常.我已将文件复制到一台漂亮的Ubuntu机器上.现在,如何运行我的应用程序?

I've published an ASP .NET Core application as a self-contained application targeting Ubuntu. The publish seems to work fine. I've copied the files to a pretty vanilla Ubuntu machine. Now, how do I run my application?

我的理解是,因为它是一个独立的.NET Core应用程序,所以我 无需下载并安装.NET Core.我的应用程序应包含所需的一切.

My understanding is that because it is a self-contained .NET Core application I do not need to download and install .NET Core anything. My application should contain everything it needs.

所有教程似乎都说我应该打电话给dotnet run.但是,"dotnet"命令行不存在(是否应该发布到自包含文件夹中?)因此,如果我调用它,则会得到找不到命令".我当然可以下载.NET Core,但这不违背整个独立概念吗?

All tutorials seem to say I should call dotnet run. However, the "dotnet" command line doesn't exist (is it supposed to be published into the self-contained folder??) So if I call it, I get "command not found". Of course I could download .NET Core, but doesn't that go against the whole self-contained concept?

以下是我要复制的文件的示例:

Here is a sample of the files I'm copying over:

我是Linux新手,请原谅.

推荐答案

答案

现在,如何运行我的应用程序?我的理解是,因为它是一个独立的.NET Core应用程序,所以我无需下载和安装.NET Core.我的应用程序应包含所需的一切.

Now, how do I run my application? My understanding is that because it is a self-contained .NET Core application I DO NOT need to download and install .NET Core anything. My app should contain everything it needs.

您是正确的.运行可执行文件.

You are correct. Run the executable.

创建独立的应用程序时,发布输出包含启动应用程序所需的完整文件集(包括您的应用程序文件和所有.NET Core文件)."其中包括可执行文件.

When you create a self-contained app, the publish output "contains the complete set of files (both your app files and all .NET Core files) needed to launch your app." That includes the executable.

这是dotnet publish -c release -r ubuntu.14.04-x64的输出,用于简单的自包含应用程序.将发布目录复制到Ubuntu并运行可执行文件.

Here is the output of dotnet publish -c release -r ubuntu.14.04-x64 for a simple self-contained application. Copy the publish directory to Ubuntu and run the executable.

C:\ MyApp \ bin \ release \ netcoreapp1.0 \ ubuntu.14.04-x64 \ publish \

C:\MyApp\bin\release\netcoreapp1.0\ubuntu.14.04-x64\publish\

...

libsos.so
libsosplugin.so
libuv.so
Microsoft.CodeAnalysis.CSharp.dll
Microsoft.CodeAnalysis.dll
Microsoft.CodeAnalysis.VisualBasic.dll
Microsoft.CSharp.dll
Microsoft.VisualBasic.dll
Microsoft.Win32.Primitives.dll
Microsoft.Win32.Registry.dll
mscorlib.dll
mscorlib.ni.dll
MyApp                        <------- On Ubuntu, run this executable
MyApp.deps.json                       and you will see Hello World!
MyApp.dll
MyApp.pdb
MyApp.runtimeconfig.json
sosdocsunix.txt
System.AppContext.dll
System.Buffers.dll
System.Collections.Concurrent.dll
System.Collections.dll

...

C:\ MyApp \ project.json

C:\MyApp\project.json

{
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true
  },
  "dependencies": {},
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": "1.0.1"
      }
    }
  },
  "runtimes": {
    "ubuntu.14.04-x64" : {},
    "win10-x64" : {}
  }
}

C:\ MyApp \ Program.cs

C:\MyApp\Program.cs

public class Program
{
    public static void Main(string[] args)
    {
        System.Console.WriteLine("Hello World!");
    }
}

另请参见

本文档区分了框架依赖型和框架依赖型.独立的部署.

See Also

This document differentiates between framework-dependent and self-contained deployments.

这篇关于在Ubuntu上运行独立的ASP .NET Core应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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