Visual studio post 构建事件命令行 "for" 语法

Visual studio post build event command line "for" syntax

Solution1 : { Project1 (windows 表格), Project2 (class 图书馆) }

正在尝试将编译 Project1 后获得的所有 .dll 从默认目录(与 .exe 相同)复制到 /lib 子文件夹。

if not exist Lib mkdir Lib
for %i in (*.dll) move /Y "$(TargetDir)%i" "$(TargetDir)Lib\%i"

我对 for %i in (*.dll) 语法有疑问。正确的做法是什么?

注意:这不会出错(但只会复制 1 个 .dll,而不是全部):

if not exist Lib mkdir Lib
move /Y "$(TargetDir)first.dll" "$(TargetDir)Lib\first.dll"

你快到了。您应该使用双百分比 %%do:

for %%i in (*.dll) do move /Y "$(TargetDir)%%i" "$(TargetDir)Lib\%%i"