Home > Mobile >  Azure DevOps 2019 - Adding Script leads to change of the building agent
Azure DevOps 2019 - Adding Script leads to change of the building agent

Time:01-11

I have a local building agent for a Unity|HoloLens-Project. Today I had to switch from VS2019 to VS2022 on my building agent and I came across the issue, that the MSBuild-Task-Version of DevOps 2019 is not compatible with VS2022.

So I found a workaround. That workaround is to use the following script instead of the MSBuild task. But using that script I ran into the following misbehavior:

  1. If I use the MSBuild@1-task my pipeline crashes because of mentioned compatibility problem. But the pipeline uses the right building agent.
  2. If I use the Script the pipeline crashes because it uses the wrong building agent. That agent has no unity installed and is not mentioned in the YAML.

Yaml:
  - task: MSBuild@1
    displayName: 'Build Appx Package - MSBuild@1'
    inputs:
      solution: '$(Build.BinariesDirectory)$(unity.outputPath)/*.sln'
      msbuildVersion: 'latest'
      platform: 'ARM64'
      configuration: 'Release'
      msbuildArguments: '/p:AppxBundle=Always /p:AppxPackageDir=$(Build.ArtifactStagingDirectory)/AppPackages'
  # ----- or ------
  - script: |
      @echo off
      setlocal enabledelayedexpansion
      for /f "usebackq tokens=*" %%i in (`"!ProgramFiles(x86)!\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe`) do (set msbuild_exe=%%i)
      "!msbuild_exe!" "$(Build.BinariesDirectory)$(unity.outputPath)/*.sln" /p:Configuration=Release /p:Platform="ARM64" /p:AppxBundle=Always /p:AppxPackageDir=$(Build.ArtifactStagingDirectory)/AppPackages /t:rebuild

At the beginng of my YAML I set of course the pool and the name of the building agent:

- job: unity
  pool:
    name: 'My_Pool'
    demand: Agent.name -equals My_Agent_Unity_1

I don't understand how removing the MSBuild task and adding the script can cause a different building agent to suddenly be taken.

CodePudding user response:

I don't understand how removing the MSBuild task and adding the script can cause a different building agent to suddenly be taken.

Because you entered the wrong keyword "demand" in your YAML. It should be demands.

- job: unity
  pool:
    name: 'My_Pool'
    demands: Agent.name -equals My_Agent_Unity_1

Please see Manually entered demands and pool definition for details.

  • Related