You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

批处理文件链式调用lessc执行成功后无法返回控制权求助

解决批处理链式执行lessc后无法收回控制权的问题

你的问题出在两个关键细节上:

  1. 第一个目录切换命令末尾缺失闭合双引号,会导致路径解析错误:
    原代码:cd "%hostingDir%\MVC\wwwroot
    修正后:cd "%hostingDir%\MVC\wwwroot"

  2. 链式调用中的第二个lessc没有加call指令。因为lessc本质是批处理脚本(.cmd/.bat),直接运行会接管当前批处理的执行上下文,执行完后直接退出,不会回到原脚本继续执行后续的cd %hostingDir%和PAUSE。

修改后的完整批处理代码:

set hostingDir=%cd%
cd "%hostingDir%\MVC\wwwroot"
call webpack --config webpack.config.js --stats=summary

cd "%hostingDir%\MVC\wwwroot\styles"

REM Compile LESS files
call "E:\Node\lessc" --glob --source-map --clean-css "style.less" "style.min.css"^
&& call "E:\Node\lessc" --glob --source-map --clean-css "style-below.less" "style-below.min.css"
 
REM 现在能执行到这里了
cd %hostingDir%

PAUSE

内容的提问来源于stack exchange,提问作者rory

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 04:16:01