Search code examples
c++azure-devopsazure-pipelinescicd

How can I run MSVC build tools (e.g. lib.exe) on an Azure Agent?


I need to combine several static libraries (built from C++ code) for windows on an Azure (Microsoft-hosted) build agent. Locally, I can do this with lib.exe (part of the MSVC build tools).

I'm trying to run lib.exe in a script task, but the executable is not found. I've thought about manually adding the path for MSVC in the script and try like this, but that seems like a very fragile solution.

Can anybody give me a hint as to how to achieve this?


Solution

  • Using the commands described in this workaround, I was able to get it up and running.

    I added this to the beginning of my script step (on windows agent):

    pushd "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
    for /f "delims=" %%x in ('.\vswhere.exe -latest -property InstallationPath') do set VSPATH=%%x
    popd
    call "%VSPATH%\VC\Auxiliary\Build\vcvarsall.bat" x64
    

    After this, I can call e.g. lib.exe. What's great about this is that it's not tied to a specific VS version/path.

    Thanks go out @Botje for posting the link in their comment above - much appreciated!