[英]Batch “input line is too long” while calling csc.exe from bat script
我的代码试图让 csc.exe 引用 /DLLs 目录中的 all.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 无法处理那么多字符,最后一行会给我一个“输入行太长”错误。 您对此问题有任何解决方法/解决方案吗?
正如评论中提到的,您应该使用链接到.rsp
文件的 @compiler 选项,您可以在其中存储编译器选项,包括引用。
该文件看起来像csc.rsp
(与csc.exe
位于同一文件夹中),它是每个编译的一部分,除非指定了-noconfig 编译器选项。
示例references.rsp
:
-r:Microsoft.CSharp.dll
-r:System.Core.dll
-r:System.dll
-r:System.Windows.Forms.Dll
您可以在批处理文件中以编程方式创建文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.