2017-02-23 46 views
0

所以我想建立一个自包含的.NetCore应用程序,只是一个简单的默认你好世界之一。麻烦建设自包含.NetCore应用程序

我跟着Scott Hanselman's示例了解如何在Google搜索答案后创建应用程序。

所以我在我的project.json

{ 
    "version": "1.0.0-*", 
    "buildOptions": { 
    "debugType": "portable", 
    "emitEntryPoint": true 
    }, 
    "dependencies": {}, 
    "frameworks": { 
    "netcoreapp1.1": { 
     "dependencies": { 
     "Microsoft.NETCore.App": { 
      //"type": "platform", 
      "version": "1.1.0" 
     } 
     }, 
     "imports": "dnxcore50", 
     "runtimes": { 
     "win10-x64": {}, 
     "osx.10.10-x64": {}, 
     "ubuntu.14.04-x64": {} 
     } 
    } 
    } 
} 

正如你可以看到我已经注释掉型线,并增加运行时间为每个平台的代码。

但我不断收到此错误:

Can not find runtime target for framework '.NETCoreApp,Version=v1.1' compatible with one of the targe 
t runtimes: 'osx.10.10-x64'. Possible causes: 
1. The project has not been restored or restore failed - run `dotnet restore` 
2. The project does not list one of 'osx.10.10-x64' in the 'runtimes' section. 
3. You may be trying to publish a library, which is not supported. Use `dotnet pack` to distribute li 
braries. 

现在我在Mac上运行这一点,但在Ubuntu上发生同样的错误,但然后报告它涉及到Ubuntu的错误。

我的dotNet版本是1.0.0 = - preview2-1-003177

我有点卡住,似乎一切都指向它应该工作的事实,它可能是我俯瞰明显的事情。

任何帮助表示赞赏。

回答

1

我认为你需要你的JSON的结构变更为:

{ 
    "version": "1.0.0-*", 
    "buildOptions": { 
     "debugType": "portable", 
     "emitEntryPoint": true 
    }, 
    "dependencies": {}, 
    "frameworks": { 
     "netcoreapp1.1": { 
      "dependencies": { 
       "Microsoft.NETCore.App": { 
        "version": "1.1.0" 
       } 
      } 
     } 
    }, 
    "runtimes": { 
     "win10-x64": {}, 
     "osx.10.10-x64": {}, 
     "ubuntu.14.04-x64": {} 
    } 
} 

大不同的是,runtimes不在framework部分。

在更改project.json之后,一定要运行dotnet restore --no-cache

你可以找到自我的更多信息包含在此page以及与此优异answer

+0

真棒该诀窍部署(SCD):-) –