■
Note
The options sent to the command-line compiler (as well as most other command-line tools) can be pre-
fixed with either a dash (
-?
) or a slash (
/?
).
To compile TestApp.cs into a console application named TestApp.exe, change to the directory
containing your source code file:
cd C:\CscExample
and enter the following command set (note that command-line flags must come before the name of
the input files, not after):
csc /target:exe TestApp.cs
Here I did not explicitly specify an /out flag, therefore the executable will be named TestApp.exe,
given that TestApp is the name of the input file. Also be aware that most of the C# compiler flags
support an abbreviated version, such as /t rather than /target (you can view all abbreviations by
entering csc -? at the command prompt).
csc /t:exe TestApp.cs
Furthermore, given that the /t:exe flag is the default output used by the C# compiler, you
could also compile TestApp.cs simply by typing
csc TestApp.cs
TestApp.exe can now be run from the command line as shown in Figure 2-2.
Figure 2-2. TestApp.exe in action
Do'stlaringiz bilan baham: |