英文:
Azure DevOps 2019 - Adding Script leads to change of the building agent
问题
今天我不得不将我的构建代理从VS2019切换到VS2022,因为发现DevOps 2019的MSBuild任务版本与VS2022不兼容。
所以我找到了一个解决方法。这个解决方法是使用以下“script”而不是“MSBuild”任务。但是使用这个“script”时,我遇到了以下的问题:
- 如果我使用“MSBuild@1”任务,我的流水线会因为上述兼容性问题而崩溃。但是流水线使用了正确的构建代理。
- 如果我使用“Script”,流水线会崩溃,因为它使用了错误的构建代理。这个代理没有安装Unity,并且在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
在我的YAML文件开头,我当然设置了池和构建代理的名称:
- job: unity
pool:
name: 'My_Pool'
demand: Agent.name -equals My_Agent_Unity_1
我不明白为什么移除MSBuild
任务并添加script
会导致突然使用不同的构建代理。
英文:
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:
<br>
- If I use the
MSBuild@1
-task my pipeline crashes because of mentioned compatibility problem. But the pipeline uses the right building agent. - 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.
<br>
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:
<br>
- 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.
答案1
得分: 1
因为您在您的YAML中输入了错误的关键字“demand
”,应该是demands
。
- job: unity
pool:
name: 'My_Pool'
demands: 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.
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论