CHAPTER 2 BUILDING C# APPLICATIONS
the name of the assembly would still be TestApp.exe (rather than MyCoolApp.exe), given the
/out:TestApp.exe flag listed in the TestApp.rsp response file. However, if you list flags after a response
file, the flag will override settings in the response file.
Note The effect of the /reference flag is cumulative. Regardless of where you specify external assemblies
(before, after, or within a response file), the end result is a summation of each reference assembly.
The Default Response File (csc.rsp)
The final point to be made regarding response files is that the C# compiler has an associated default
response file (csc.rsp), which is located in the same directory as csc.exe itself (which is by default
installed under C:\Windows\Microsoft.NET\Framework\, where is a given version of
the platform). If you were to open this file using Notepad, you will find that numerous .NET assemblies
have already been specified using the /r: flag, including various libraries for web development, LINQ
programming, data access, and other core libraries (beyond mscorlib.dll).
When you are building your C# programs using csc.exe, this response file will be automatically
referenced, even when you supply a custom *.rsp file. Given the presence of the default response file,
the current TestApp.exe application could be successfully compiled using the following command set (as
System.Windows.Forms.dll is referenced within csc.rsp):
csc /out:TestApp.exe *.cs
In the event that you wish to disable the automatic reading of csc.rsp, you can specify the /noconfig
option.
csc @TestApp.rsp /noconfig
Note If you reference assemblies (via the /r option) that you do not actually make use of, they are ignored by
the compiler. Therefore, you have no need to worry about “code bloat.” If you reference a library you do not
actually make use of, it is ignored by the compiler.
Obviously, the C# command-line compiler has many other options that can be used to control how
the resulting .NET assembly is to be generated. You’ll see other important features where necessary over
the course of this text; however, full details of these options can be found within the .NET Framework 4.5
SDK documentation.
Source Code The CscExample application can be found under the Chapter 2 subdirectory.
46