dotnet publish-iis 不起作用

dotnet publish-iis doesn't work

我有一个 ASP.NET 核心 RC2 项目,我正在尝试将它发布到 IIS,命令 dotnet publish-iis 总是给出:

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

是否有一个例子来说明这是如何工作的? 我如何传递参数?它永远行不通...

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

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

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

我在此 post on running Asp.NET Core apps with IIS

中更详细地描述了 publish-iis 工具

对于 ASP.NET 核心 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%"
  }

对我来说效果很好!