【问题标题】:ASP.NET Core build on different platformsASP.NET Core 在不同平台上构建
【发布时间】:2016-11-08 14:47:04
【问题描述】:

我创建了一个简单的 ASP.NET Core 应用程序,我想在 Windows 10 上为 Windows 10 和 CentOS 7 构建它。所以我的 project.json 文件中有这个:

"runtimes": {
    "win10-x64": { },
    "centos.7-x64": { },
    "win81-x64":  { }
  },

没有“win81-x64”我得到一个错误:

找不到与以下目标运行时之一兼容的框架“.NETCoreApp,Version=v1.0”的运行时目标:“win81-x64、win8-x64、win7-x64”

dotnet build 命令之后我看到了这个:

将编译项目 ListService (.NETCoreApp,Version=v1.0),因为缺少预期的输出 Compiling ListService for .NETCoreApp,Version=v1.0

编译成功。 0 个警告 0 个错误

经过时间 00:00:14.3853704

并且命令dotnet --info 显示:

产品信息: 版本:1.0.0-preview2-003131 提交 SHA-1 哈希:635cf40e58

运行时环境: 操作系统名称:Windows 操作系统版本:6.3.9600 操作系统平台:Windows RID:win81-x64

我错过了什么吗? dotnet publish -r foo-version 也没有帮助。

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.1"
    },
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Routing": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "runtimes": {
    "win10-x64": { },
    "centos.7-x64": { },
    "win81-x64":  { }
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },

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

【问题讨论】:

  • 您是否尝试使用“win10-x64”:{}?
  • 是的,如您所见,“win10-x64”在我的 project.json 文件中
  • 哦,是的,对不起。把所有的project.json
  • 好的,我编辑了问题:)
  • 尝试编辑 "Microsoft.NETCore.App": { "version": "1.0.1" } 到 "Microsoft.NETCore.App": { "version": "1.0.1","类型”:“平台”}

标签: asp.net asp.net-core


【解决方案1】:

好的,现在它可以工作了。 我所做的是:

  1. 我从project.json 文件中删除了"type":"platform"

  2. 我在项目文件夹的 cmd 中运行命令 dotnet build -r centos.7-x64

现在我明白了

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-09
    • 1970-01-01
    • 1970-01-01
    • 2021-01-25
    • 2013-11-03
    • 2018-05-31
    • 1970-01-01
    • 2014-04-28
    相关资源
    最近更新 更多