Compile C # source files with a response file

xiaoxiao2021-03-06  23

Compile several CS source files in the command line, you may write:

Csc.exe /out :./bin/myassembly.dll / t: library / r: path1 / firstassemblydll, Path2 / Secondassemlbydll, etc src1.cs src2.cs ETC

If you continue to reference a new assembly or create a new source file, you will have to modify this line command, of course, you can also put this line command in a .bat file, so you only need to modify the .bat file to continue compiling. However, there is a method, which is more convenient, is to create a response file, the response file is a text file, you can write the compiler option, such as:

# 注,, myassembly.rsp #begin /out:/bin/myassembly.dll / target: library /reference:path1/firstassembly.dll, path2/secondassembly.dll kettc src1.cs src2.cs etc #end

Then I can build the source code like this: csc.exe @ myassembly.rsp

In this way, regardless of how the compiler option changes, the source file changes, I only need to modify the content of myassembly.RSP file, which is more convenient than before.

If you use EditPlus, you can add a user tool, the format is as follows (I am using the Chinese version Editplus):

Menu text: csc command: csc.exe parameter: @ $ (filename) Initial directory: $ (fileDir) Capture Output: Select

The content similar to $ (...) is generated by editplus. You can also create a template for a response file in EditPlus, so you only need to create a response file again, add the content similar to the above, then you can compile the user tools below the Tools menu. (Note that the response file is to be active), the results of the compile will be intercepted by EditPlus and output below, just like an IDE.

In short, use the response file, you can simplify the compile command, then match EditPlus, you can build a simple IDE, which is very convenient.

转载请注明原文地址:https://www.9cbs.com/read-39671.html

New Post(0)