Leverage C# Response Files at the Command Line

Although I'd bet most of you make use of VS .NET as opposed to the raw command line complier, csc.exe can be quite useful in a number of circumstances. However, few of us enjoy typing lengthy command line flags such as:

 csc /r: MyAsm.dll;MyOtherAsm.dll /t: winexe /out: myApp.exe *.cs

To lessen your burden, the C# command line compiler supports the use of 'response files'. Simply put, response files are text files which contain all of the command line arguments you wish to feed into the compiler. By convention, these files end with a *.rsp file extension. Thus, assume you have a file named mySettings.rsp:

 # Response files support comments.
/r: MyAsm.dll
/r: MyOtherAsm.dll
/t: winexe
/out: myApp.exe *.cs

With this, you can simply specify the name of the response file to use for the current compilation (via the @ symbol):

 csc @mySettings.rsp

Tip from Andrew Troelsen

Posted by: Duncan Mackenzie, MSDN

This post applies to Visual C# .NET 2002/2003