I trying to do a batch script to found in my system the MSBuild.exe
to build my project using the command line.
I found the paths using the command:
where /R "C:\Program Files\Microsoft Visual Studio" MSBuild.exe
This command return a list of paths:
C:\>where /R "C:\Program Files\Microsoft Visual Studio" MSBuild.exe
C:\Program Files\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe
C:\Program Files\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\amd64\MSBuild.exe
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\MSBuild.exe
I need to get these list of paths, set a variable and run a command line to get the version of the file founded.
I tried:
for %%G in (where /R "C:\Program Files\Microsoft Visual Studio" MSBuild.exe) do (
set TEMP_MSBUILDER %%~G
%TEMP_MSBUILDER% --version
)
I think that my problem is in the for loop. Have another way to find the file on system and set the founded path on variable?