【问题标题】:dotnet publish-iis doesn't workdotnet 发布-iis 不起作用
【发布时间】:2016-05-19 23:06:11
【问题描述】:

我有一个 ASP.NET Core RC2 项目,我正在尝试将它发布到 IIS 并且命令 dotnet publish-iis ALWAYS 给出:

Asp.Net Core IIS Publisher
Usage: dotnet publish-iis [arguments] [options]
Arguments:
  <PROJECT>  The path to the project (project folder or project.json) being published. If empty the current directory is used.
Options:
  -h|--help                   Show help information
  --publish-folder|-p         The path to the publish output folder
  -f|--framework <FRAMEWORK>  Target framework of application being published

有没有例子说明这是如何工作的? 如何传递参数?它永远不会工作......

【问题讨论】:

    标签: iis asp.net-core publish


    【解决方案1】:

    --publish-folder--framework 参数是必需的。如果您不提供这些参数,该工具将显示使用情况。

    话虽如此,实际上并不希望自己运行此工具。 publish-iis 所做的只是调整已发布应用程序的 web.config 文件(如果不存在,则创建一个新的 web.config 文件),以便 IIS/IISExpress 可以找到要启动的应用程序。换句话说,您必须先发布您的应用程序,然后 publish-iis 只是稍微调整一下。因此,预期的用途是进行配置,使其作为发布后脚本运行:

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

    我在post on running Asp.NET Core apps with IIS 中更详细地描述了publish-iis 工具

    【讨论】:

    • 但这不会在 wwwroot 中生成web.config。这是预期的吗?我认为 web.config 在项目根目录和 wwwroot 中都是必需的。
    • 这是预期的 (github.com/aspnet/Announcements/issues/173)。 web.config 文件的默认位置现在是您的 approot 而不是 wwwroot。另外,为什么有 2 个 web.config 文件会有用?
    • 这个名字一点也不令人困惑。顺便说一句,写得很棒。 aspnet 文档很棒,但是这部分在文档中尤其没有意义。
    【解决方案2】:

    适用于 ASP.NET Core 1.1。 project.json 中的关键部分是:

      "tools": {
        "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final"
      },
    
      "scripts": {
        "postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
      }
    

    对我来说很棒!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-01
      • 1970-01-01
      • 2015-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多