'Azure DevOps pipeline how set vcvars64.bat then call msbuild.exe from batch file?
On a local machine, I execute my build.bat after opening a x64 Native Tools Command Prompt for VS 2019, then build.bat calls msbuild.exe.
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"
build.bat
How can I do same in an Azure DevOps pipeline CmdLine task?
The build.bat call to msbuild.exe fails when called from azure-pipelines.yml CmdLine task.
Is there a reliable method to locate and call vcvars64.bat so that msbuild.exe can be found?
- task: CmdLine@2
displayName: 'build.bat calls msbuild'
inputs:
script: |
build.bat
Azure pipeline error:
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.
Thanks in advance for any tips or direction.
Solution 1:[1]
From my point of view, using batch file is out of DevOps philosophy. Instead, you should decompile your batch file to steps and then use appropriate DevOps step. for example, in case of msbuild this is https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/msbuild?view=azure-devops
But if you need to use msbuild directly, then you can use paths same like in your local env, but path to VS will depends on what version (agent pool) you using in your pipeline
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | FreemanRU |