<分区>
我有一个批处理文件,它是一个函数库
:findmsbuild
if exist msbuildpath.txt (
for /f %%i in (msbuildpath.txt) do set MSBUILD="%%i\MSBuild.exe"
) else (
set VSWHERE="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
for /f "delims=" %%i in ('!VSWHERE! -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe') do set MSBUILD="%%i"
)
exit /b
还有 official documentation for call
说我应该能够直接调用另一个文件中的标签
call library.bat :findmsbuild
但实际情况是,解释器从第一行开始执行 library.bat。我究竟做错了什么?调用批处理文件大约是
setlocal enableextensions enabledelayedexpansion
cd "%~dp0"
call library.bat :findmsbuild
echo %MSBUILD%