Friday, December 30, 2011

Let the Adventures Begin!

Comment: This is a post i am porting from another blog! An old note.

Hello and Welcome to the  .NET Shelf of Adventures.

This will be a collection of articles, stories and experiments in .NET. Hope you enjoy reading these as much as i enjoy writing these.

Without much Ado, let us go on our first adventure.

Adventure #1: Explore C# Compiler Options

.NET Framework SDK ships with a lot of tools and compilers for languages. C# is one of the .NET programming languages. I shall go ahead and see what the C# compiler has to offer me.

Let me bring up Visual Studio Command Prompt. It's easier to work with this command prompt, than the standard cmd prompt, as all environment variables in the Visual Studio Command Prompt are already setup.

By the way, this is year 2010, and although everybody is eagerly waiting for VS2010 and all it's awesome features, i shall be happy with the 2008 version of Visual Studio for all my experiments will be on this version.
I shall be working on different Windows versions(XP, Vista, May be Win 7) although it should not be an  issue.

Let me open up the Visual Studio Command prompt.

Start>All Programs>Microsoft Visual Studio 2008> Visual Studio Tools> Visual Studio Command Prompt



Here, i issue this command csc /?



Notes:
  • Visual Studio has a command prompt tool that makes my life easier as all the .NET Framework environment variables are already set here. 
  • csc.exe is the C# compiler.
  • csc.exe /? emits out a lot of options, switches that i can use.
  • I can capture the switch options by issuing such a command csc /? >> cscoptions.txt 
The following is the list of options that I can see when I invoke the csc help.

Microsoft (R) Visual C# 2008 Compiler version 3.5.30729.1
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.

                        Visual C# 2008 Compiler Options

                        - OUTPUT FILES -
/out:                    Specify output file name (default: base name of file with main class or first file)
/target:exe                    Build a console executable (default) (Short form: /t:exe)
/target:winexe                 Build a Windows executable (Short form: /t:winexe)
/target:library                Build a library (Short form: /t:library)
/target:module                 Build a module that can be added to another assembly (Short form: /t:module)
/delaysign[+|-]                Delay-sign the assembly using only the public portion of the strong name key
/doc:                    XML Documentation file to generate
/keyfile:                Specify a strong name key file
/keycontainer:         Specify a strong name key container
/platform:             Limit which platforms this code can run on: x86, Itanium, x64, or anycpu. The default is anycpu.

                        - INPUT FILES -
/recurse:            Include all files in the current directory and subdirectories according to the wildcard specifications
/reference:=      Reference metadata from the specified assembly file using the given alias (Short form: /r)
/reference:         Reference metadata from the specified assembly files (Short form: /r)
/addmodule:         Link the specified modules into this assembly

                        - RESOURCES -
/win32res:               Specify a Win32 resource file (.res)
/win32icon:              Use this icon for the output
/win32manifest:          Specify a Win32 manifest file (.xml)
/nowin32manifest               Do not include the default Win32 manifest
/resource:            Embed the specified resource (Short form: /res)
/linkresource:        Link the specified resource to this assembly (Short form: /linkres)
                               Where the resinfo format is [,[,public|private]]

                        - CODE GENERATION -
/debug[+|-]                    Emit debugging information
/debug:{full|pdbonly}          Specify debugging type ('full' is default, and enables attaching a debugger to a running program)
/optimize[+|-]                 Enable optimizations (Short form: /o)

                        - ERRORS AND WARNINGS -
/warnaserror[+|-]              Report all warnings as errors
/warnaserror[+|-]:  Report specific warnings as errors
/warn:                      Set warning level (0-4) (Short form: /w)
/nowarn:            Disable specific warning messages

                        - LANGUAGE -
/checked[+|-]                  Generate overflow checks
/unsafe[+|-]                   Allow 'unsafe' code
/define:          Define conditional compilation symbol(s) (Short form: /d)
/langversion:          Specify language version mode: ISO-1, ISO-2, or Default

                        - MISCELLANEOUS -
@                        Read response file for more options
/help                          Display this usage message (Short form: /?)
/nologo                        Suppress compiler copyright message
/noconfig                      Do not auto include CSC.RSP file

                        - ADVANCED -
/baseaddress:

         Base address for the library to be built
/bugreport:              Create a 'Bug Report' file
/codepage:                  Specify the codepage to use when opening source files
/utf8output                    Output compiler messages in UTF-8 encoding
/main:                   Specify the type that contains the entry point (ignore all other possible entry points) (Short form: /m)
/fullpaths                     Compiler generates fully qualified paths
/filealign:                 Specify the alignment used for output file sections
/pdb:                    Specify debug information file name (default: output file name with .pdb extension)
/nostdlib[+|-]                 Do not reference standard library (mscorlib.dll)
/lib:               Specify additional directories to search in for references
/errorreport:          Specify how to handle internal compiler errors: prompt, send, queue, or none. The default is queue.
/moduleassemblyname:   Name of the assembly which this module will be a part of


Wow! So many options. Interesting stuff yeah?
Adventure: Explore the C# compiler options was fascinating, at least for me.
Cool guys, Adios! until our next adventure.

No comments:

Post a Comment