7/31/2019 Building C# Applications VTU Syllabus Unit 2
1/14
The Role of the Command LineComplier (csc.exe)
csc.exe is a stand alone compiler for C#
Why learn about csc.exe
To cope with situations where VS.Net is notavailable
To know what takes place behind the scenes
More comfortable manipulating command line
tools
7/31/2019 Building C# Applications VTU Syllabus Unit 2
2/14
7/31/2019 Building C# Applications VTU Syllabus Unit 2
3/14
Building C# Applications usingcsc.exe
7/31/2019 Building C# Applications VTU Syllabus Unit 2
4/14
Building C# Applications usingcsc.exe
Create a small class called TestApp with a mainmethod
Save the file as TestApp.cs
Type
Now you have a file called TestApp.exe
that can be run from anywhere
7/31/2019 Building C# Applications VTU Syllabus Unit 2
5/14
Referencing External Assemblies External assemblies can be referenced with the
using keyword
For example add a MessageBox to the currentapplication
To do this you add usingSystem.Windows.Forms
To inform the C# compiler about this externalassembly you use the /reference flag
To reference multiple external assemblies use thefollowing syntax
7/31/2019 Building C# Applications VTU Syllabus Unit 2
6/14
Compiling Multiple Source Files
Most applications have more than oneclass
If you were to add another class calledHelloMessage.cs then you have to list
each *.cs file separately
7/31/2019 Building C# Applications VTU Syllabus Unit 2
7/14
csc.exe Response Files
Response files are used instead ofmanually specifying all the flags duringcompilation
E.g.
7/31/2019 Building C# Applications VTU Syllabus Unit 2
8/14
csc.exe Response Files
The application can be built usingResponse files have the .rsp extension
Multiple rsp files can also be specified
Any flags specified at the command line can beoverridden by the option given in the response file
The c# compiler has a default rsp file called csc.rspthat is automatically referenced
If you wish to exclude the default csc.rsp you canspecify it using the /noconfig option
7/31/2019 Building C# Applications VTU Syllabus Unit 2
9/14
Generating Bug Reports
C# compiler has a flag called /bugreport
It is populated with various statistics regardingyour current build including errors
If you specify /bugreport you will be prompted toenter corrective action if an error is encountered.
In the example given below the bugreport isstored in bugs.txt
7/31/2019 Building C# Applications VTU Syllabus Unit 2
10/14
More C# compiler options
7/31/2019 Building C# Applications VTU Syllabus Unit 2
11/14
More C# Compiler Options
7/31/2019 Building C# Applications VTU Syllabus Unit 2
12/14
More C# compiler options
7/31/2019 Building C# Applications VTU Syllabus Unit 2
13/14
Command LineDebugger(cordbg.exe)
Provides number of options to run .NETAssemblies under debug mode
cordbg -?
7/31/2019 Building C# Applications VTU Syllabus Unit 2
14/14
Steps for Debugging at Command Line
Generate symbolic debugging symbols
usingA file called testapp.pdb is created
A pdb file is required so that the C# source
code can be viewed during the debuggingsession
Once pdb file is generated start a debugsession using
To end a debugging session type exit