【发布时间】:2019-11-14 14:50:50
【问题描述】:
我的代码试图让 csc.exe 引用 /DLLs 目录中的所有 .dll 文件。
@echo on
setlocal enableextensions enabledelayedexpansion
del Assembly.dll
cd DLLs
set "imports="
for /r %%i in ("*.dll") do set "imports=!imports!,%%i"
set "imports=%imports:~1%"
cd ..
csc.exe -nostdlib -target:library -out:Assembly.dll Loader.cs MainScript.cs -r:%imports%
但是,如果目录中的 .dll 太多,由于 cmd.exe 无法处理那么多字符,最后一行会给我一个“输入行太长”错误。您对此问题有任何解决方法/解决方案吗?
【问题讨论】:
-
请尝试命令
csc.exe /?看看@<file>是否可行。 docs.microsoft.com/en-us/dotnet/csharp/language-reference/… -
我没有看到
-r的 csc 参数 -
您的
for in do可以简化为:for /r %%i in ("*.dll") do set "imports=imports,%%i",除非您只是简单地写错了。如果减少它,则不需要延迟扩展。使用此代码或您的代码,我得到了相同的结果。 -
@somebadhat:
set "imports=imports,%%i"和set "imports=!imports!,%%i"是一个巨大的区别。 -
@somebadhat -r 是-reference 的简写形式。
标签: windows batch-file dll cmd csc