【问题标题】:Visual Studio Team Services asp.net core build for IIS用于 IIS 的 Visual Studio Team Services asp.net 核心构建
【发布时间】:2016-12-14 18:48:04
【问题描述】:

我在使用 VSTS 构建过程为 IIS 构建和发布项目时遇到问题。问题是 web.config 没有被 publish-iis 命令更新,web.config 看起来像这样:

<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" forwardWindowsAuthToken="false" stdoutLogEnabled="false" />

我在我的 project.json 中使用 publish-iis 命令发布了 postpublish 部分,它可以在本地工作。在 VSTS 上,我使用预览版 .net 核心构建。我尝试使用 publish-iis 命令添加另一个构建步骤,但出现错误:

2016-12-14T18:40:57.7097698Z [command]C:\Program Files\dotnet\dotnet.exe publish-iis C:/a/1/s/uberappseu/project.json --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%
2016-12-14T18:40:57.8326697Z No executable found matching command "dotnet-publish-iis"

这是我的 project.json:

{
  "version": "1.1.0-*",

  // Used to store connection strings and other sensitive settings, so you don't have to check them into your source
  // control provider. Only use this in Development, it is not intended for Production use. See
  // http://docs.asp.net/en/latest/security/app-secrets.html

    "dependencies": {
        "Boilerplate.AspNetCore": "2.0.0",
        "Boilerplate.AspNetCore.TagHelpers": "2.0.0",
        "Microsoft.AspNetCore.CookiePolicy": "1.1.0",
        "Microsoft.AspNetCore.Diagnostics": "1.1.0",
        "Microsoft.AspNetCore.Mvc": "1.1.0",
        "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
        "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
        "Microsoft.AspNetCore.StaticFiles": "1.1.0",
        "Microsoft.Extensions.Configuration.Binder": "1.1.0",
        "Microsoft.Extensions.Configuration.CommandLine": "1.1.0",
        "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
        "Microsoft.Extensions.Configuration.Json": "1.1.0",
        "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0",
        "Microsoft.Extensions.Logging": "1.1.0",
        "Microsoft.Extensions.Logging.Console": "1.1.0",
        "Microsoft.Extensions.Logging.Debug": "1.1.0",
        "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
        "Microsoft.NETCore.App": "1.1.0",
        "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
        "Newtonsoft.Json": "9.0.1"
    },

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

  // Command line tools which can be run using 'dotnet [Tool Name]'.
    "tools": {
        "Microsoft.AspNetCore.Razor.Tools": "1.0.0",
        "Microsoft.Extensions.SecretManager.Tools": "1.0.0",
        "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0"
    },

  "buildOptions": {
    "compile": {
      // Ignore the following folders when looking for C# code to compile.
      "exclude": [
        "node_modules",
        "wwwroot"
      ]
    },
    // Use the new portable .pdb file format.
    "debugType": "portable",
    // Require the application to use a static Main method.
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      // Concurrent - Specifies whether the common language runtime runs garbage collection on a separate thread
      //              (See https://msdn.microsoft.com/en-us/library/yhwwzef8%28v=vs.110%29.aspx).
      "System.GC.Concurrent": true,
      // Server - Specifies whether the common language runtime runs server garbage collection.
      //          (See https://msdn.microsoft.com/en-us/library/ms229357%28v=vs.110%29.aspx).
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    // Include the following folders and files when publishing the project.
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "config.json",
      "web.config"
    ]
  },

  "scripts": {
    // Execute the following commands before publishing the project.
    "prepublish": [
      "npm install",
      "gulp build"
    ],
    // Execute the following commands after publishing the project.
    "postpublish": [
      "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
    ]
  }

}

更新: 以下是我的应用的构建日志:

http://pastebin.com/8CA0CruR

更新 2: 发布命令后,我在日志中找到了这些行:

2016-12-15T15:12:32.5732645Z   - Check application dependencies and target a framework version installed at:
2016-12-15T15:12:32.5732645Z       C:\Program Files\dotnet\shared\Microsoft.NETCore.App
2016-12-15T15:12:32.5732645Z   - The following versions are installed:
2016-12-15T15:12:32.5732645Z       1.0.0
2016-12-15T15:12:32.5732645Z       1.0.1
2016-12-15T15:12:32.5732645Z   - Alternatively, install the framework version '1.1.0'.

所以看起来 Microsoft.NETCore.App 1.1.0 在构建代理上不可用。


更新 3: 我已经准备了模拟这个问题的测试项目。我认为问题是由于构建服务器上没有 NetCore1.1 造成的。但是我使用来自 VSTS 的托管代理,根据它的文档,应该在那里安装 Net Core 框架 1.1 (https://www.visualstudio.com/en-us/docs/build/admin/agents/hosted-pool)。

日志:https://ufile.io/99b99 项目:https://ufile.io/c8af5

我认为结论是应该将其报告为错误并移回旧版本的 IIS 工具。

【问题讨论】:

  • 我无法重现该问题。您使用托管代理还是本地代理?如果您使用托管代理,如何检查 web.config 文件?如果您使用的是本地代理,如果您通过在构建代理机器上运行 dotnet publish 命令发布应用程序,结果会是什么?您检查了哪个 web.config 文件?它是否在已发布的文件夹中(例如 bin/release/publish)?
  • 另一方面,对于命令行构建步骤,使用 dotnet publish 代替(工具:C:\Program Files\dotnet\dotnet.exe,参数:publish --configuration $(BuildConfiguration)),它将在 project.json 的 postpublish 中调用该命令。
  • 我在部署到服务器后签入。如果我将 web.config 更改为使用 dotnet 并且 app.dll 站点可以工作。我使用托管代理。我做了一些测试。我已经删除了 "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0" 包,并且在构建日志中出现了找不到 publish-iis 命令的错误。当我恢复包时,错误消失了,但没有关于命令执行的信息。所以我认为它已执行但无法正常工作。我还尝试将所有工具更新为“1.1.0-preview4-final”版本。没有帮助。
  • 检查web.config的详细步骤是什么?您可以在此处提供详细步骤。
  • mywebsite.scm.azurewebsites.net/DebugConsole/?shell=powershell -> D:\home\site\wwwroot> -> web.config 进入站点时还有 IIS 错误 502.5

标签: c# asp.net-core azure-devops


【解决方案1】:

使用 Microsoft.AspNetCore.Server.IISIntegration.Tools 1.0.0-preview2-final 代替,它工作正常。 (高于这个版本有这个问题)

【讨论】:

    【解决方案2】:

    问题是您使用的工具版本不正确。如果您查看Microsoft.AspNetCore.Server.IISIntegration.Tools package on NuGet,您会发现“1.1.0”版本不存在。同样适用于其他工具。对于 1.1.0 运行时,您要使用的工具版本是“1.1.0-preview4-final”

    【讨论】:

    • 它确实有帮助 - 至少它没有尝试启动该过程。现在您将应用程序更新到 1.1.0,但您尝试运行它的机器没有 1.1 运行时。去那里:microsoft.com/net/download/core#/current 并下载并安装 1.1。确保选择当前而不是 LTS - 当前是 1.1
    猜你喜欢
    • 2013-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-26
    • 2016-11-17
    • 1970-01-01
    • 2016-10-22
    相关资源
    最近更新 更多