1

我正在尝试创建概念证明,将 ASP.NET Web 应用程序(.NET Framework,而不是 .NET Core)部署到运行 IIS 的本地 Windows 服务器。

我使用基于 YAML 的构建管道和使用经典 GUI 的发布管道让它工作。为了部署到本地服务器,我创建了一个部署组并将一个自托管代理部署到目标服务器。工作正常。

我的下一步是尝试创建一个基于 YAML 的多阶段管道,将构建管道转换为构建阶段并编写一个全新的部署阶段。据我了解,YAML 多级管道不支持部署组,而是我必须创建一个具有虚拟机资源的环境。我在目标服务器上创建了代理,并将自己注册为环境下的资源,因此设置看起来不错。在这种情况下,环境被命名为“Dev”。

我尝试运行管道,它似乎工作正常,成功完成。日志显示部署阶段下载了在构建阶段创建的工件,并且 IIS Web App Manage 和 IIS Web App Deploy 步骤运行良好。但是,目标服务器上的 Web 应用程序未更新。代表目标服务器的 Dev 环境下的资源也显示“Never deploy”为最新作业,表明自托管代理从未拉下发布。

我假设由于日志显示没有错误,部署作业实际上是在 Microsoft 托管的代理而不是自托管代理上运行的。鉴于开发环境以自托管代理作为其唯一资源存在,我看不出哪里出错了。关于我哪里出错的任何提示或建议?

这是整个 YAML 文件:

trigger:
- '*'

stages:
- stage: 'Build'
  displayName: 'Build the web application'
  jobs:
  - job: 'Build'
    displayName: 'Build job'
    pool:
      vmImage: 'windows-latest'

    variables:
      solution: '**/*.sln'
      buildPlatform: 'Any CPU'
      buildConfiguration: 'Release'

    steps:
    - task: NuGetToolInstaller@1

    - task: NuGetCommand@2
      inputs:
        restoreSolution: '$(solution)'

    - task: VSBuild@1
      inputs:
        solution: '$(solution)'
        msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:TransformWebConfigEnabled=false /p:PackageLocation="$(build.artifactStagingDirectory)"'
        platform: '$(buildPlatform)'
        configuration: '$(buildConfiguration)'

    - task: VSTest@2
      inputs:
        platform: '$(buildPlatform)'
        configuration: '$(buildConfiguration)'

    - task: PublishBuildArtifacts@1
      inputs:
        PathtoPublish: '$(Build.ArtifactStagingDirectory)'
        ArtifactName: 'drop'
        publishLocation: 'Container'

- stage: 'Deploy'
  displayName: 'Deploy the web application'
  dependsOn: Build
  jobs:
  - deployment: 'DeployToDev'
    displayName: 'Deploy the web application to dev environment'
    pool:
      vmImage: 'windows-latest'
    variables:
      Parameters.IISDeploymentType: 'IISWebsite'
      Parameters.ActionIISWebsite: 'CreateOrUpdateWebsite'
      Parameters.WebsiteName: 'Default Web Site'
      Parameters.WebsitePhysicalPath: '%SystemDrive%\inetpub\wwwroot\AspNetDemo'
      Parameters.AddBinding: false
      Parameters.VirtualPathForApplication: '/AspNetDemo'
      Parameters.AppPoolName: ''
      Parameters.VirtualApplication: 'AspNetDemo'
      Parameters.Package: '$(Pipeline.Workspace)\drop\*.zip'
      Parameters.RemoveAdditionalFilesFlag: true
      Parameters.TakeAppOfflineFlag: true
      Parameters.XmlTransformation: true
      Parameters.XmlVariableSubstitution: true
    environment: Dev
    strategy:
      runOnce:
        deploy:
          steps:
          - download: current
            artifact: drop

          - task: IISWebAppManagementOnMachineGroup@0
            displayName: 'IIS Web App Manage'
            inputs:
              IISDeploymentType: '$(Parameters.IISDeploymentType)'
              ActionIISWebsite: '$(Parameters.ActionIISWebsite)'
              WebsiteName: '$(Parameters.WebsiteName)'
              WebsitePhysicalPath: '$(Parameters.WebsitePhysicalPath)'
              AddBinding: $(Parameters.AddBinding)
              ParentWebsiteNameForVD: '$(Parameters.WebsiteName)'
              VirtualPathForVD: '$(Parameters.VirtualPathForApplication)'
              ParentWebsiteNameForApplication: '$(Parameters.WebsiteName)'
              VirtualPathForApplication: '$(Parameters.VirtualPathForApplication)'
              AppPoolName: '$(Parameters.AppPoolName)'

          - task: IISWebAppDeploymentOnMachineGroup@0
            displayName: 'IIS Web App Deploy'
            inputs:
              WebSiteName: '$(Parameters.WebsiteName)'
              VirtualApplication: '$(Parameters.VirtualApplication)'
              Package: '$(Parameters.Package)'
              RemoveAdditionalFilesFlag: $(Parameters.RemoveAdditionalFilesFlag)
              TakeAppOfflineFlag: $(Parameters.TakeAppOfflineFlag)
              XmlTransformation: $(Parameters.XmlTransformation)
              XmlVariableSubstitution: $(Parameters.XmlVariableSubstitution)

以下是部署阶段的原始日志文件:

2020-06-15T12:15:56.9858347Z ##[section]Starting: Deploy the web application to dev environment
2020-06-15T12:15:57.1573499Z ##[section]Starting: Initialize job
2020-06-15T12:15:57.1574831Z Agent name: 'Hosted Agent'
2020-06-15T12:15:57.1575185Z Agent machine name: 'WIN-5Q96T5JR7AD'
2020-06-15T12:15:57.1575401Z Current agent version: '2.170.1'
2020-06-15T12:15:57.1593854Z Current image version: '20200531.1'
2020-06-15T12:15:57.1601179Z Agent running as: 'VssAdministrator'
2020-06-15T12:15:57.1656829Z Prepare build directory.
2020-06-15T12:15:57.2207188Z Set build variables.
2020-06-15T12:15:57.2242403Z Download all required tasks.
2020-06-15T12:15:57.2403517Z Downloading task: DownloadBuildArtifacts (0.167.2)
2020-06-15T12:15:58.7871306Z Downloading task: IISWebAppManagementOnMachineGroup (0.5.15)
2020-06-15T12:15:58.8604155Z Downloading task: IISWebAppDeploymentOnMachineGroup (0.156.13)
2020-06-15T12:16:00.2584106Z Checking job knob settings.
2020-06-15T12:16:00.2595245Z    Knob: AgentToolsDirectory = C:/hostedtoolcache/windows Source: ${AGENT_TOOLSDIRECTORY} 
2020-06-15T12:16:00.2596590Z    Knob: AgentPerflog = c:\agents\perflog Source: ${VSTS_AGENT_PERFLOG} 
2020-06-15T12:16:00.2597479Z Finished checking job knob settings.
2020-06-15T12:16:00.2963001Z Start tracking orphan processes.
2020-06-15T12:16:00.3045878Z ##[section]Finishing: Initialize job
2020-06-15T12:16:00.3715796Z ##[section]Starting: Download
2020-06-15T12:16:00.4732035Z ==============================================================================
2020-06-15T12:16:00.4732834Z Task         : Download build artifacts
2020-06-15T12:16:00.4733443Z Description  : Download files that were saved as artifacts of a completed build
2020-06-15T12:16:00.4733725Z Version      : 0.167.2
2020-06-15T12:16:00.4734218Z Author       : Microsoft Corporation
2020-06-15T12:16:00.4734834Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/download-build-artifacts
2020-06-15T12:16:00.4735229Z ==============================================================================
2020-06-15T12:16:02.4240789Z Downloading artifacts for build: 206
2020-06-15T12:16:02.4263144Z Downloading items from container resource #/7981806/drop
2020-06-15T12:16:02.4263938Z Downloading artifact drop from: https://dev.azure.com/SimonE0675//_apis/resources/Containers/7981806?itemPath=drop&isShallow=true&api-version=4.1-preview.4
2020-06-15T12:16:02.4268251Z Downloading drop/AspNetDemo.deploy-readme.txt to d:\a\1\drop\AspNetDemo.deploy-readme.txt
2020-06-15T12:16:02.8224843Z Downloading drop/AspNetDemo.deploy.cmd to d:\a\1\drop\AspNetDemo.deploy.cmd
2020-06-15T12:16:02.8547084Z Downloading drop/AspNetDemo.SetParameters.xml to d:\a\1\drop\AspNetDemo.SetParameters.xml
2020-06-15T12:16:03.4437009Z Downloading drop/AspNetDemo.SourceManifest.xml to d:\a\1\drop\AspNetDemo.SourceManifest.xml
2020-06-15T12:16:03.4495772Z Downloading drop/AspNetDemo.zip to d:\a\1\drop\AspNetDemo.zip
2020-06-15T12:16:03.4516280Z Downloaded drop/AspNetDemo.deploy-readme.txt to d:\a\1\drop\AspNetDemo.deploy-readme.txt
2020-06-15T12:16:03.4523121Z Downloaded drop/AspNetDemo.SetParameters.xml to d:\a\1\drop\AspNetDemo.SetParameters.xml
2020-06-15T12:16:03.4525288Z Downloaded drop/AspNetDemo.deploy.cmd to d:\a\1\drop\AspNetDemo.deploy.cmd
2020-06-15T12:16:03.4561228Z Downloaded drop/AspNetDemo.SourceManifest.xml to d:\a\1\drop\AspNetDemo.SourceManifest.xml
2020-06-15T12:16:03.8676511Z Downloaded drop/AspNetDemo.zip to d:\a\1\drop\AspNetDemo.zip
2020-06-15T12:16:04.8013454Z Total Files: 5, Processed: 5, Skipped: 0, Failed: 0, Download time: 3.039 secs, Download size: 5.572MB
2020-06-15T12:16:05.3818312Z Successfully downloaded artifacts to d:\a\1/
2020-06-15T12:16:05.3852498Z ##[section]Finishing: Download
2020-06-15T12:16:05.3893746Z ##[section]Starting: IIS Web App Manage
2020-06-15T12:16:05.4111059Z ==============================================================================
2020-06-15T12:16:05.4111422Z Task         : IIS web app manage
2020-06-15T12:16:05.4111762Z Description  : Create or update websites, web apps, virtual directories, or application pools
2020-06-15T12:16:05.4114396Z Version      : 0.5.15
2020-06-15T12:16:05.4114757Z Author       : Microsoft Corporation
2020-06-15T12:16:05.4115193Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/iis-web-app-management-on-machine-group
2020-06-15T12:16:05.4115883Z ==============================================================================
2020-06-15T12:16:09.1901004Z ##[command]"C:\windows\system32\inetsrv\appcmd.exe"  list site /name:"Default Web Site"
2020-06-15T12:16:09.7275643Z 
2020-06-15T12:16:09.7277066Z 
2020-06-15T12:16:09.7282874Z     Directory: C:\inetpub\wwwroot
2020-06-15T12:16:09.7285603Z 
2020-06-15T12:16:09.7286457Z 
2020-06-15T12:16:09.7305926Z Mode                LastWriteTime         Length Name                                                                  
2020-06-15T12:16:09.7323105Z ----                -------------         ------ ----                                                                  
2020-06-15T12:16:09.7339223Z d-----        6/15/2020  12:16 PM                AspNetDemo                                                            
2020-06-15T12:16:09.7532322Z ##[command]"C:\windows\system32\inetsrv\appcmd.exe"  set site /site.name:"Default Web Site" -[path='/'].[path='/'].physicalPath:"%SystemDrive%\inetpub\wwwroot\AspNetDemo" -[path='/'].[path='/'].userName: -[path='/'].[path='/'].password:
2020-06-15T12:16:10.4767779Z SITE object "Default Web Site" changed
2020-06-15T12:16:10.5022726Z 
2020-06-15T12:16:10.5069765Z 
2020-06-15T12:16:10.5329739Z ##[section]Finishing: IIS Web App Manage
2020-06-15T12:16:10.5548276Z ##[section]Starting: IIS Web App Deploy
2020-06-15T12:16:10.5701088Z ==============================================================================
2020-06-15T12:16:10.5701408Z Task         : IIS web app deploy
2020-06-15T12:16:10.5701716Z Description  : Deploy a website or web application using Web Deploy
2020-06-15T12:16:10.5701975Z Version      : 0.156.13
2020-06-15T12:16:10.5702225Z Author       : Microsoft Corporation
2020-06-15T12:16:10.5702612Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/iis-web-app-deployment-on-machine-group
2020-06-15T12:16:10.5703027Z ==============================================================================
2020-06-15T12:16:12.0232544Z ConnectionString attributes in Web.config is parameterized by default. Note that the transformation has no effect on connectionString attributes as the value is overridden during deployment by 'Parameters.xml or 'SetParameters.xml' files. You can disable the auto-parameterization by setting /p:AutoParameterizationWebConfigConnectionStrings=False during MSBuild package generation.
2020-06-15T12:16:12.0631887Z [command]d:\a\_tasks\IISWebAppDeploymentOnMachineGroup_1b467810-6725-4b6d-accd-886174c09bba\0.156.13\ctt\ctt.exe s:d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\Web.config t:d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\Web.Release.config d:d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\Web.config pw i verbose
2020-06-15T12:16:12.4770510Z Start tranformation to 'd:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\Web.config'.
2020-06-15T12:16:12.4771847Z Source file: 'd:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\Web.config'.
2020-06-15T12:16:12.4773080Z Transform  file: 'd:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\Web.Release.config'.
2020-06-15T12:16:12.4774325Z Transformation task is using encoding 'System.Text.UTF8Encoding'. Change encoding in source file, or use the 'encoding' parameter if you want to change encoding.
2020-06-15T12:16:12.4775273Z Executing RemoveAttributes (transform line 18, 18)
2020-06-15T12:16:12.4776821Z on /configuration/system.web/compilation
2020-06-15T12:16:12.4777702Z Applying to 'compilation' element (no source line info)
2020-06-15T12:16:12.4778465Z Removed 'debug' attribute
2020-06-15T12:16:12.4778827Z Removed 1 attributes
2020-06-15T12:16:12.4779125Z Done executing RemoveAttributes
2020-06-15T12:16:12.4779863Z XML Transformations applied successfully
2020-06-15T12:16:12.5028504Z Initiated variable substitution in config file : d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\Web.Debug.config
2020-06-15T12:16:12.5104251Z Skipped Updating file: d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\Web.Debug.config
2020-06-15T12:16:12.5105110Z Initiated variable substitution in config file : d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\Web.Dev.config
2020-06-15T12:16:12.5138107Z Processing substitution for xml node : appSettings
2020-06-15T12:16:12.5157111Z Skipped Updating file: d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\Web.Dev.config
2020-06-15T12:16:12.5158089Z Initiated variable substitution in config file : d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\Web.Release.config
2020-06-15T12:16:12.5177323Z Skipped Updating file: d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\Web.Release.config
2020-06-15T12:16:12.5187991Z Initiated variable substitution in config file : d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\Web.Test.config
2020-06-15T12:16:12.5191087Z Processing substitution for xml node : appSettings
2020-06-15T12:16:12.5192067Z Skipped Updating file: d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\Web.Test.config
2020-06-15T12:16:12.5192706Z Initiated variable substitution in config file : d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\Web.config
2020-06-15T12:16:12.5208981Z Processing substitution for xml node : appSettings
2020-06-15T12:16:12.5221909Z Skipped Updating file: d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\Web.config
2020-06-15T12:16:12.5223143Z Initiated variable substitution in config file : d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\bin\Web.Debug.config
2020-06-15T12:16:12.5226584Z Skipped Updating file: d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\bin\Web.Debug.config
2020-06-15T12:16:12.5227609Z Initiated variable substitution in config file : d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\bin\Web.Dev.config
2020-06-15T12:16:12.5233500Z Processing substitution for xml node : appSettings
2020-06-15T12:16:12.5238472Z Skipped Updating file: d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\bin\Web.Dev.config
2020-06-15T12:16:12.5240963Z Initiated variable substitution in config file : d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\bin\Web.Release.config
2020-06-15T12:16:12.5247520Z Skipped Updating file: d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\bin\Web.Release.config
2020-06-15T12:16:12.5255360Z Initiated variable substitution in config file : d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\bin\Web.Test.config
2020-06-15T12:16:12.5285847Z Processing substitution for xml node : appSettings
2020-06-15T12:16:12.5289812Z Skipped Updating file: d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\bin\Web.Test.config
2020-06-15T12:16:12.5293438Z Initiated variable substitution in config file : d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\bin\roslyn\VBCSCompiler.exe.config
2020-06-15T12:16:12.5327539Z Processing substitution for xml node : appSettings
2020-06-15T12:16:12.5335594Z Skipped Updating file: d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\bin\roslyn\VBCSCompiler.exe.config
2020-06-15T12:16:12.5338157Z Initiated variable substitution in config file : d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\bin\roslyn\csc.exe.config
2020-06-15T12:16:12.5371336Z Skipped Updating file: d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\bin\roslyn\csc.exe.config
2020-06-15T12:16:12.5371992Z Initiated variable substitution in config file : d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\bin\roslyn\vbc.exe.config
2020-06-15T12:16:12.5389975Z Skipped Updating file: d:\a\_temp\temp_web_package_9405406238180971\Content\d_C\a\1\s\AspNetDemo\obj\Release\Package\PackageTmp\bin\roslyn\vbc.exe.config
2020-06-15T12:16:12.5390858Z XML variable substitution applied successfully.
2020-06-15T12:16:13.6524609Z [command]"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:package='d:\a\1\s\temp_web_package_590126440620167.zip' -dest:auto -setParam:name='IIS Web Application Name',value='Default Web Site/AspNetDemo' -enableRule:AppOffline
2020-06-15T12:16:16.1656560Z Info: Adding sitemanifest (sitemanifest).
2020-06-15T12:16:16.3688794Z Info: Creating application (Default Web Site/AspNetDemo)
2020-06-15T12:16:16.3855513Z Info: Adding virtual path (Default Web Site/AspNetDemo)
2020-06-15T12:16:16.4371591Z Info: Adding directory (Default Web Site/AspNetDemo).
2020-06-15T12:16:16.4845399Z Info: Adding directory (Default Web Site/AspNetDemo\bin).
2020-06-15T12:16:16.4883541Z Info: Adding file (Default Web Site/AspNetDemo\bin\Demo2.dll).
2020-06-15T12:16:16.5070593Z Info: Adding file (Default Web Site/AspNetDemo\bin\Demo2.pdb).
2020-06-15T12:16:16.5080200Z Info: Adding file (Default Web Site/AspNetDemo\bin\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll).
2020-06-15T12:16:16.5098373Z Info: Adding directory (Default Web Site/AspNetDemo\bin\roslyn).
2020-06-15T12:16:16.5109779Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\csc.exe).
2020-06-15T12:16:16.5130856Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\csc.exe.config).
2020-06-15T12:16:16.5139616Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\csc.rsp).
2020-06-15T12:16:16.5148847Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\csi.exe).
2020-06-15T12:16:16.5156562Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\csi.rsp).
2020-06-15T12:16:16.5168651Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\Microsoft.Build.Tasks.CodeAnalysis.dll).
2020-06-15T12:16:16.5229952Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\Microsoft.CodeAnalysis.CSharp.dll).
2020-06-15T12:16:16.5971326Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\Microsoft.CodeAnalysis.CSharp.Scripting.dll).
2020-06-15T12:16:16.6103919Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\Microsoft.CodeAnalysis.dll).
2020-06-15T12:16:16.6490047Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\Microsoft.CodeAnalysis.Scripting.dll).
2020-06-15T12:16:16.6641545Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\Microsoft.CodeAnalysis.VisualBasic.dll).
2020-06-15T12:16:16.7788705Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\Microsoft.CSharp.Core.targets).
2020-06-15T12:16:16.7866312Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\Microsoft.DiaSymReader.Native.amd64.dll).
2020-06-15T12:16:16.8908394Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\Microsoft.DiaSymReader.Native.x86.dll).
2020-06-15T12:16:16.9128717Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\Microsoft.VisualBasic.Core.targets).
2020-06-15T12:16:16.9136216Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\System.AppContext.dll).
2020-06-15T12:16:17.0293466Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\System.Collections.Immutable.dll).
2020-06-15T12:16:17.0358896Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\System.Diagnostics.StackTrace.dll).
2020-06-15T12:16:17.0397999Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\System.IO.FileSystem.dll).
2020-06-15T12:16:17.0408374Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\System.IO.FileSystem.Primitives.dll).
2020-06-15T12:16:17.0429135Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\System.Reflection.Metadata.dll).
2020-06-15T12:16:17.0508174Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\vbc.exe).
2020-06-15T12:16:17.0524962Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\vbc.exe.config).
2020-06-15T12:16:17.0537599Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\vbc.rsp).
2020-06-15T12:16:17.0544089Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\VBCSCompiler.exe).
2020-06-15T12:16:17.0567886Z Info: Adding file (Default Web Site/AspNetDemo\bin\roslyn\VBCSCompiler.exe.config).
2020-06-15T12:16:17.0587023Z Info: Adding file (Default Web Site/AspNetDemo\bin\Web.Debug.config).
2020-06-15T12:16:17.0657739Z Info: Adding file (Default Web Site/AspNetDemo\bin\Web.Dev.config).
2020-06-15T12:16:17.0696168Z Info: Adding file (Default Web Site/AspNetDemo\bin\Web.Release.config).
2020-06-15T12:16:17.0704103Z Info: Adding file (Default Web Site/AspNetDemo\bin\Web.Test.config).
2020-06-15T12:16:17.0711307Z Info: Adding file (Default Web Site/AspNetDemo\Default.aspx).
2020-06-15T12:16:17.0718585Z Info: Adding file (Default Web Site/AspNetDemo\Web.config).
2020-06-15T12:16:17.0737537Z Info: Adding file (Default Web Site/AspNetDemo\Web.Debug.config).
2020-06-15T12:16:17.0914599Z Info: Adding file (Default Web Site/AspNetDemo\Web.Dev.config).
2020-06-15T12:16:17.0921332Z Info: Adding file (Default Web Site/AspNetDemo\Web.Release.config).
2020-06-15T12:16:17.0928434Z Info: Adding file (Default Web Site/AspNetDemo\Web.Test.config).
2020-06-15T12:16:17.0948303Z Info: Adding ACLs for path (Default Web Site/AspNetDemo)
2020-06-15T12:16:17.1479606Z Info: Adding ACLs for path (Default Web Site/AspNetDemo)
2020-06-15T12:16:17.4606954Z Total changes: 47 (46 added, 0 deleted, 1 updated, 0 parameters changed, 14818941 bytes copied)
2020-06-15T12:16:18.3963762Z ##[section]Finishing: IIS Web App Deploy
2020-06-15T12:16:18.4137177Z ##[section]Starting: Finalize Job
2020-06-15T12:16:18.4180998Z Cleaning up task key
2020-06-15T12:16:18.4182925Z Start cleaning up orphan processes.
2020-06-15T12:16:18.4271669Z ##[section]Finishing: Finalize Job
2020-06-15T12:16:18.4320625Z ##[section]Finishing: Deploy the web application to dev environment

我注意到日志中靠近顶部的那一行,上面写着Agent machine name: 'WIN-5Q96T5JR7AD'。这不是运行自托管代理的本地服务器的名称,因此我认为它必须是 Microsoft 托管的代理。

4

2 回答 2

1

环境是资源的集合,可以由管道中的部署作为目标。环境可以包括 Kubernetes 集群、Azure Web 应用程序、虚拟机、数据库。

换句话说,需要告诉管道你要部署到哪个资源。在您的情况下应该是虚拟机。(既然您提到您创建了一个具有虚拟机资源的环境。)

在管道 YAML 中引用环境和 VM 资源的示例。.

jobs:  
- deployment: VMDeploy
  displayName: web
  environment:
    name:  VMenv
    resourceType: VirtualMachine
    tags: web1
  strategy:

更多细节请参考我们的官方教程--环境-虚拟机资源

在您的情况下,您只需指定一个环境,部署作业用于针对整个环境。

并且您已指定pool: vmImage: 'windows-latest',因此部署作业最终以包含 windows 最新 vmImage 的主机代理池为目标,而不是您创建的 VM 资源。

这就是为什么部署作业实际上是在 Microsoft 托管代理而不是自托管代理上运行的。

于 2020-06-17T05:41:46.717 回答
0

通过反复试验,我找到了一个修复方法:在 Deploy 阶段,指定环境的 resourceType。

在部署阶段,环境信息是:

environment: Dev

现在变成:

environment:
  name: Dev
  resourceType: VirtualMachine

我不知道为什么需要指定 resourceType,或者这是否是一个杂乱无章的问题,并且有一种更优雅的方法来解决这个问题。但是,该管道现在始终如一地工作。

于 2020-06-16T23:19:09.467 回答