在本地计算机上,我在打开 VS 2019 的 x64 native 工具命令提示符后执行 build.bat,然后执行 build.bat> 调用 msbuild.exe。
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"
build.bat
如何在 Azure DevOps 管道 CmdLine 任务中执行相同操作?
从 azure-pipelines.yml CmdLine 任务调用时,对 msbuild.exe 的 build.bat 调用失败。
是否有可靠的方法来定位并调用vcvars64.bat以便找到msbuild.exe?
- task: CmdLine@2
displayName: 'build.bat calls msbuild'
inputs:
script: |
build.bat
Azure 管道错误:
2022-05-06T15:42:53.3802703Z 'msbuild' is not recognized as an internal or external command,
2022-05-06T15:42:53.3803010Z operable program or batch file.
提前感谢您提供任何提示或指导。
最佳答案
从我的角度来看,使用批处理文件不符合 DevOps 理念。相反,您应该将批处理文件反编译为步骤,然后使用适当的 DevOps 步骤。例如,对于 msbuild,这是 https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/msbuild?view=azure-devops
但是如果您需要直接使用msbuild,那么您可以使用与本地环境中相同的路径,但是VS的路径将取决于您在管道中使用的版本(代理池)
关于Azure DevOps管道如何设置vcvars64.bat然后从批处理文件调用msbuild.exe?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72144855/