(Part 1) before discussing the compiler switch, I would like to discuss the response file. A response file is a text file that contains a set of compiler command line switches, when you execute csc.exe, the compiler opens the response file and uses each line of the switch, just as the switch is passed to the command line of csc.exe. you can specify the name of the response file in the command line to run this file on the compiler. For example, you may have the following response file: myproject. RSP, which contains the following text:
/Out: myproject.exe
/Target: winexe
To allow csc.exe to use this setting, you can call it as follows:
Csc.exe @ myproject. RSP codefile1.cs codefile2.cs
This tells the compiler the name of the output file and the type of the object to be created. As you can see, the response file is very convenient, because you do not need to manually express the required command line switch every time you compile your project.
C # The Compiler supports multiple response files. In addition to the files explicitly specified in the command line, the compiler automatically searches for CSC. RSP response file. when you run csc.exe, it looks for a local CSC in the current directory. RSP file-you should put any project-related settings in this file. the compiler will also find this file in the csc.exe file to serve as the global CSC. RSP file. put the settings you want for all projects in this file, the compiler gathers and uses the settings in all these response files. if there is a conflict between the local and global response files, the settings in the local file will overwrite the settings in the global file. Similarly, any settings passed to the command line explicitly overwrite the settings in the local response file.
When you install. NET framework, it will be in % SystemRoot % \ Microsoft. net \ framework \ VX. x. directory X (X. x. X is the one you installed.. NET Framework Version) install a default global CSC. RSP file. in version 2.0, this file contains the following switches:
# This file contains command-line options that the C #
# Command line compiler (CSC) will process as Part
# Of every compilation, unless the "/noconfig" option
# Is specified.
# Reference the common framework Libraries
/R: accessibility. dll
/R: Microsoft. VSA. dll
/R: system. configuration. dll
/R: system. configuration. Install. dll
/R: system. Data. dll
/R: system. Data. oracleclient. dll
/R: system. Data. SQLXML. dll
/R: system. Deployment. dll
/R: system. Design. dll
/R: system. directoryservices. dll
/R: system. dll
/R: system. Drawing. Design. dll
/R: system. Drawing. dll
/R: system. javasiseservices. dll
/R: system. Management. dll
/R: system. messaging. dll
/R: system. runtime. remoting. dll
/R: system. runtime. serialization. formatters. Soap. dll
/R: system. Security. dll
/R: system. serviceprocess. dll
/R: system. Transactions. dll
/R: system. Web. dll
/R: system. Web. Mobile. dll
/R: system. Web. regularexpressions. dll
/R: system. Web. Services. dll
/R: system. Windows. Forms. dll
/R: system. xml. dll
Because the global CSC. RSP file references all the listedProgramYou do not need to explicitly reference these sets in the C # Compiler/reference switch. This response file is very convenient for developers, it allows developers to use the types and namespaces defined in various Microsoft-released assemblies, rather than specifying the/reference compiler switch when compiling each program.
Referencing all these program Assembly slows down the compiler, but if yourSource codeNo reference to any type or member of the definition in these assemblies does not affect the generated Assembly file, and does not affect the run-time execution performance.
Note: When you use the/reference compiler to reference a dataset, you can specify the full path pointing to a specific file. However, if you do not specify a path, the compiler will search for the Assembly file in the following places (in the list order ):
1. working directory
2. The directory contains the csc.exe file. mscorlib. dll is always in this directory. This path looks like: % systemmroot % \ Microsoft. NET \ framework \ v2.0.50727
3. Use the/lib compiler to switch any directory specified
4. Any directory created using lib Environment Variables
Of course, if you want to make your life easier, you are welcome to add your switch to this global CSC. RSP file, but this makes it difficult to copy the Build Environment on different machines: You must remember to update CSC in the same way on each build machine. RSP file. you can also specify the/noconfig command line switch to tell the compiler to ignore local and global CSC. RSP file.