Using C # response files

Source: Internet
Author: User

While it is possible to experience its inherent advantages while working through the command line, no one can deny that typing dozens of compiler options can result in finger cramps and typos. To help mitigate both issues, the C # compiler supports the use of response files.

Note All command prompts allow you to traverse the previous command using the UP and DOWN ARROW keys.

Response files (which, by convention, *.RSP file extensions) contain all the options that you want to supply to csc.exe. After you create the file, you can specify its name as the only option for the C # compiler. For illustration purposes, the following provides a response file that will be used to generate MyCodeLibrary.dll (note that you can use the # symbol to specify a comment).

# MyCodeLibraryArgs.rsp
# These are the options used
# to compile MyCodeLibrary.dll
# Output target and name.
/t:library
/out:MyCodeLibrary.dll
# Location of C# files.
/recurse:*.cs
# Give me an XML doc.
/doc:myDoc.xml
# Give me a strong name as well.
/keyfile:C:\MyKeyPair\myKeypair.snk

Given the file, you can now specify MYCODELIBRARYARGS.RSP with the @ option:

csc @MyCodeLibraryArgs.rsp

If you prefer, you can specify multiple response files:

csc @MyCodeLibraryArgs.rsp @MoreArgs.rsp @EvenMoreArgs.rsp

Keep in mind that the response file is processed in the order in which it was encountered. Therefore, the settings in the previous file may be overridden by the settings in a later file.

Default response files and/noconfig options

Finally, keep in mind that there is a default response file-csc.rsp, which is automatically processed by csc.exe during each compilation. If you analyze the contents of the file (which is in the same folder as the csc.exe itself), you will only find a set of frequently referenced assemblies (System.Windows.Forms.dll, System.Data.dll, and so on).

In the rare occasions where you want to ban including csc.rsp, you can specify the/NOCONFIG flag:

csc /noconfig @MyCodeLibraryArgs.rsp

Note If you reference an assembly and do not actually use it, it will not be listed in the assembly manifest. Therefore, do not worry about code bloat because they do not exist at all.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.