如何更改 Azure Devops 上的 VSBuild 代理位置?

How can I change the VSBuild agent location on Azure Devops?

我们有一个项目,我想在其中提交 PR,但几天前构建出错了。事实证明,在没有任何代码/管道更改的情况下,Azure Devops 构建出错并出现以下错误脚本。

我在网上找到了很多解决方案,主要是针对本地错误,但都没有解决我的问题。

我们在计算机上使用 VS2019(没有任何问题),带有 .Net Core 2.2 和 Angular 6.

日志:

 gyp verb using MSBuild: C:\Program Files (x86)\Microsoft Visual Studio19\Enterprise\MSBuild.0\Bin\MSBuild.exe
  gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio19\Enterprise\MSBuild.0\Bin\MSBuild.exe
  gyp info spawn args [
  gyp info spawn args   'build/binding.sln',
  gyp info spawn args   '/nologo',
  gyp info spawn args   '/p:Configuration=Release;Platform=x64'
  gyp info spawn args ]
  gyp ERR! UNCAUGHT EXCEPTION 
##[error]EXEC(0,0): Error : spawn C:\Program Files (x86)\Microsoft Visual Studio19\Enterprise\MSBuild.0\Bin\MSBuild.exe ENOENT
EXEC : gyp ERR! stack error : spawn C:\Program Files (x86)\Microsoft Visual Studio19\Enterprise\MSBuild.0\Bin\MSBuild.exe ENOENT [d:\a\s\Web\Web.csproj]
  gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
  gyp ERR! stack     at onErrorNT (internal/child_process.js:456:16)
  gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:80:21)
  gyp ERR! System Windows_NT 10.0.17763
  gyp ERR! command "C:\Program Files\nodejs\node.exe" "d:\a\1\s\Web\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
  gyp ERR! cwd d:\a\s\Web\ClientApp\node_modules\@angular-devkit\build-angular\node_modules\node-sass
  gyp ERR! node -v v12.13.1
  gyp ERR! node-gyp -v v3.8.0
  gyp ERR! This is a bug in `node-gyp`.
  gyp ERR! Try to update node-gyp and file an Issue if it does not help:
  gyp ERR!     <https://github.com/nodejs/node-gyp/issues>
##[error]EXEC(0,0): Error code: 7
EXEC : Build failed with error code: 7 [d:\a\s\Web\Web.csproj]

yml:

trigger:
- master

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:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'

我认为此时问题将出在 msbuild 版本上,但不知道(也找不到)如何在托管代理上解决该问题。

非常感谢。

一个临时解决方案是向管道添加一个新的节点任务,将节点版本设置为较旧的版本(例如,10.16.3 应该可以)