如何在mac os上执行.net核心控制台应用程序

Lui*_*cia 6 c# macos .net-core asp.net-core

我刚安装了Visual Studio for MAC,并在底部窗口(应用程序输出)按下播放时创建了hello world console应用程序,我可以看到hello world.

但是,如何从命令/终端线执行该应用程序?

如果我尝试./myapp.dll,即使在sudo su之后我也被拒绝了.

所以,不知道如何运行它

这是我的json

{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true
  },
  "dependencies": {},
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "version": "1.0.0"
        }
      }
    }
  },
  "runtimes": {
    "win10-x64": {},
    "osx.10.10-x64": {}
  }
}
Run Code Online (Sandbox Code Playgroud)

更新

我已经运行了dotnet restore和dotnetrun,首先我得到了这个错误:无法找到与其中一个目标运行时兼容的框架'.NETCoreApp,Version = v1.0'的运行时目标:'osx.10.12-x64'.可能的原因:

然后我像这样改变了我的project.json:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true
  },
  "dependencies": {},
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "version": "1.0.0"
        }
      }
    }
  },
  "runtimes": {
    "win10-x64": {},
    "osx.10.12-x64": {}
  }
}
Run Code Online (Sandbox Code Playgroud)

然后我得到了数百个这样的错误:System.Threading.Tasks 4.0.11为.NETCoreApp上的System.Threading.Tasks提供了一个编译时引用程序集,Version = v1.0,但是没有与之兼容的运行时程序集osx.10.12-64.System.Threading.Timer 4.0.1为.NETCoreApp上的System.Threading.Timer提供了编译时引用程序集,Version = v1.0,但没有与osx.10.12-x64兼容的运行时程序集.

刚刚列出了几个J.

我想OSX的运行时不正确,但我应该设置它吗?

vcs*_*nes 10

你需要运行它dotnet,如:

dotnet myapp.dll
Run Code Online (Sandbox Code Playgroud)

据我所知,该工具还不支持Ready to Run(本机)二进制文件.

然后我得到数百个这样的错误:System.Threading.Tasks 4.0.11提供了一个编译时引用

您的project.json缺少框架的平台类型.它应该如下所示:

"netcoreapp1.0": {
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)