Visual Studio Team Services用于IIS的asp.net核心版本

时间:2021-05-21 03:36:34

I've problem with building and publishing project for IIS with VSTS build process. The problem is that web.config isn't updated by publish-iis command and web.config looks like this:

我在使用VSTS构建过程构建和发布IIS项目时遇到了问题。问题是publish.config命令没有更新web.config,web.config如下所示:

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

I've postpublish section with publish-iis command in my project.json and it works localy. On VSTS I use preview .net core build. I've tried adding another build step with publish-iis command but i get an error:

我在我的project.json中使用publish-iis命令发布了post部分,并且它可以在localy中运行。在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"

Here is my project.json:

这是我的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%"
    ]
  }

}

UPDATE: Here are build logs for my app:

更新:这是我的应用程序的构建日志:

http://pastebin.com/8CA0CruR

UPDATE 2: I've found thease lines in log after publish command:

更新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'.

So it looks like Microsoft.NETCore.App 1.1.0 is not available on build agent.

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


UPDATE 3: I've prepared the test project which simulates this issue. I think the problem is caused by absence of NetCore1.1 on build server. However I use Hosted Agent from VSTS and according to it's documentation the Net Core framework 1.1 should be installed there (https://www.visualstudio.com/en-us/docs/build/admin/agents/hosted-pool).

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

Logs: https://ufile.io/99b99 Project: https://ufile.io/c8af5

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

I think that conclusion is that is should report it as a bug and move back to older version of IIS tools.

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

2 个解决方案

#1


1  

Using Microsoft.AspNetCore.Server.IISIntegration.Tools 1.0.0-preview2-final instead, it is working fine. (Higher than this version have that issue)

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

#2


0  

The problem is that the version of tools you are using is incorrect. If you look at the Microsoft.AspNetCore.Server.IISIntegration.Tools package on NuGet you will see that the "1.1.0" version does not exist. Same applies to other tools. For 1.1.0 runtime the version for tools you want to use is "1.1.0-preview4-final"

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

#1


1  

Using Microsoft.AspNetCore.Server.IISIntegration.Tools 1.0.0-preview2-final instead, it is working fine. (Higher than this version have that issue)

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

#2


0  

The problem is that the version of tools you are using is incorrect. If you look at the Microsoft.AspNetCore.Server.IISIntegration.Tools package on NuGet you will see that the "1.1.0" version does not exist. Same applies to other tools. For 1.1.0 runtime the version for tools you want to use is "1.1.0-preview4-final"

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