【问题标题】:Unable to publish .NET Core app (unsupported runtime)无法发布 .NET Core 应用(不受支持的运行时)
【发布时间】:2016-09-05 12:04:52
【问题描述】:

我正在使用 .net core 构建一个 API,我在发布过程中遇到了这个问题:

The project being published does not support the runtime 'dnx-clr-win-x86.1.0.0-rc2-20221'

我看到了this github issuethis one,但我离解决方案还差得远。这是我的更新project.json文件:

  {
  "compilationOptions": {
    "debugType": "portable",
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "dependencies": {
    "AspNet.Security.OAuth.Validation": "1.0.0-alpha1-*",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Hosting": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.IISPlatformHandler": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-*",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-*",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-*",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-*",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-*",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-*",
    "OpenIddict.Core": "1.0.0-*",
    "OpenIddict.EF": "1.0.0-*"
  },

  "frameworks": {
    "net451": {
      "frameworkAssemblies": {
        "System.ComponentModel": { "type": "build" }
      }
    },

    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0-rc2-*"
        }
      },

      "imports": [
        "dnxcore50",
        "portable-net451+win8"
      ]
    }
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-rc2-*",
      "imports": "portable-net45+wp80+win8+wpa81+dnxcore50"
    }
  },

  "scripts": {
    "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
  },

  "exclude": [
    "wwwroot",
    "node_modules"
  ],

  "publishExclude": [
    "**.user",
    "**.vspscc"
  ]
}

我在某处读到这可能是由于我的依赖项的组织?

更新

这是我使用dotnet restore时遇到的错误:

Errors in c:\Users\Dude\Documents\my-api-v1\src\MyApi\obj\060296a3-1ddd-4410-9e77-9510cd667f39\bin\project.json
Microsoft.AspNetCore.Server.IISIntegration.Tools 1.0.0-rc2-20832 is not compatible with DNXCore,Version=v5.0.
Some packages are not compatible with DNXCore,Version=v5.0.
Microsoft.AspNetCore.Server.IISIntegration.Tools 1.0.0-rc2-20832 is not compatible with DNXCore,Version=v5.0 (win7-x64).
Some packages are not compatible with DNXCore,Version=v5.0 (win7-x64).

【问题讨论】:

  • 您用于发布项目的确切命令是什么?
  • no 命令,我目前正在使用 vs 2015 发布工具,我还没有为此切换到任何 CI。我应该发布我的发布配置文件设置吗?

标签: c# asp.net asp.net-core dnx dotnet-cli


【解决方案1】:

您引用的是与 VS RC1 工具不兼容的 ASP.NET Core RC2 包,因为它们都依赖于完全不同的堆栈(DNX 与 .NET CLI)。

相反,您应该考虑使用dotnet publish

我建议更新您的 project.json 文件以删除过时的 commands 部分并包含缺少的 tools/scripts

"tools": {
  "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
    "version": "1.0.0-rc2-*",
    "imports": "portable-net45+wp80+win8+wpa81+dnxcore50"
  }
},

"scripts": {
  "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
}

netstandardapp1.5 也应替换为新的netcoreapp1.0 TFM,并应在netcoreapp1.0/dependencies 下添加以下依赖项:

"Microsoft.NETCore.App": { "type": "platform", "version": "1.0.0-rc2-*" }

您可以查看https://github.com/openiddict/openiddict-core/blob/dev/samples/Mvc.Server/project.json 的工作示例。

【讨论】:

  • 谢谢,我现在收到您讨论的Microsoft.Dnx.Runtime.FileFormatException: unknown keyword platform 错误over here。有什么想法吗?
  • 这是预期的。停止使用 DNX/VS 并忽略它,它应该可以与 .NET CLI 一起使用。
  • 嘿,好吧。我现在正在使用 CLI,收到 Some packages are not compatible with DNXCore,Version=v5.0 (win7-x64) 错误。好郁闷……
  • 你在使用dnxcore50吗?你应该改用netcoreapp1.0
  • 只有在imports下才有dnxcore50,如示例所示。
猜你喜欢
  • 2018-11-17
  • 1970-01-01
  • 1970-01-01
  • 2021-04-29
  • 1970-01-01
  • 2019-08-26
  • 2020-09-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多