Compiling Multiple Files C#

General questions about using TextPad

Moderators: AmigoJack, helios, bbadmin, Bob Hansen, MudGuard

Post Reply
gderreck
Posts: 1
Joined: Sat Oct 20, 2007 5:40 am

Compiling Multiple Files C#

Post by gderreck »

Greetings
I am new to TextPad, programming and to this forum. I would first like to compliment the developer for creating what I have been looking in an editor when I don't need to use Visual Studio. The program is fast, reasonably easy to configure, and has most of the options I am looking for.

Questions:
-I have set up a compiler for C#. Fair enough. How do I go about setting up to compile multiple files into an executable. I am obviously missing something. I suspect it is something simple a newbie would overlook. :?:

-Now that I have abused your good nature, would you give me a quick run through on setting up a debugger either the VS or .NET debugger would be fine.

Thank you in advance for your help. I would like to work through these issues before I purchase the product, given that Helios does not offer refunds. :?

Thanks again and have a good day. :D
shaqmeister
Posts: 18
Joined: Sun Feb 15, 2009 12:50 pm

Re: Compiling Multiple Files C#

Post by shaqmeister »

Questions:
-I have set up a compiler for C#. Fair enough. How do I go about setting up to compile multiple files into an executable. I am obviously missing something. I suspect it is something simple a newbie would overlook.
Hi

I don't know if this is still relevant or whether you are still looking to set up TextPad to build C# assemblies from multiple files, but it might still be helpful to post some pointers just in case anyone else is thinking about doing the same.

If you have set up your compiler - Csc.exe for C# .NET - then you already have the tool setting to achieve what you want. I'm assuming your tool settings are something like: (see correction in next post.)

Code: Select all

Command: C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe
Parameters: $File
Initial Folder: $FileDir
The next step, instead of providing it with a single *.cs file for compilation, is to put together what is known as a "response file" which provides the information the compiler needs about which files to include in the build, the name of the assembly, any library (*.dll) files to reference, etc.

Obviously the level of information you put into a response file depends on the needs of what you are building, but suppose you have only a couple of files - File1.cs and File1.cs - and you want to build them into an assembly called MultipleFiles.exe, then you could put together a response file as:

Code: Select all

# Response file to build MultipleFiles.exe

/out:MultipleFiles.exe

File1.cs
File2.cs
Save this with a .rsp extension, and send this to your compiler using the tool you have set up already in TextPad, just as you did with individual .cs code files.

There are many other options that can be set when your needs become greater in terms of what you want to build, and how you want the compiler to process your code. For example:

Code: Select all

#Response file referencing library code in the build

# the assembly that will be built
/out:MultipleFilesUsingLibraryCode.exe

# use optimization
/o

# build with full debug info
/debug:full

# set the compiler warning level to 4
/w:4

# include these files in the build
File1.cs
File2.cs

# and reference these libraries
/reference:Library1.dll,Library2.dll
A good guide to the available commands can be found at http://www.devhood.com/tutorials/tutori ... ial_id=110 and the very brief faq at http://en.csharp-online.net/CSharp_FAQ: ... ponse_file illustrates some of the 'abbreviated' commands that can be used (such as /r: for /reference:).

If you wanted to be even more adventurous, it is even possible to set up TextPad to send Visual Studio project files (*.csproj, *.vbproj) to MSBuild.exe (instead of Csc, for C#) and have your projects reference other projects and build your .exe and .dlls all in the same run, and all manner of wonderful things!

Hope this helps.
shaqmeister
Posts: 18
Joined: Sun Feb 15, 2009 12:50 pm

Re: Compiling Multiple Files C#

Post by shaqmeister »

shaqmeister wrote:

Code: Select all

Command: C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe
Parameters: $File
Initial Folder: $FileDir
.
Correction!
Actually, this won't quite work, since in order for Csc to know the distinction between a code file (*.cs) and a response file (*.rsp), the filename needs to be sent to the compiler prefixed with '@'. Thus, the correct usage is:

Code: Select all

Command: C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe
Parameters: @$FileName
Initial Folder: $FileDir
Also, it's worth pointing out that something similar can be achieved for anyone wanting to use TextPad to program in Visual Basic .NET, with a similar tool set up to use Vbc instead of Csc.

Code: Select all

Command: C:\Windows\Microsoft.NET\Framework\v3.5\vbc.exe
Parameters: @$FileName
Initial Folder: $FileDir
In either case, for a quick 'reference' of allowable commands that can be included in a response file, use TextPad's 'Run ...' command with:

Code: Select all

Command: C:\Windows\Microsoft.NET\Framework\v3.5\vbc.exe
Parameters: /?
Initial Folder:
Capture Output: selected
and a list of commands will be returned to the Tool Output window. (Replace vbc.exe with csc.exe in the command to get the reference for Csc, which does appear to have some slight differences.) You should then get something like the following, which is the output for the Visual Basic .NET compiler:

Code: Select all

Microsoft (R) Visual Basic Compiler version 9.0.30729.1
Copyright (c) Microsoft Corporation.  All rights reserved.

                  Visual Basic Compiler Options

                                  - OUTPUT FILE -
/out:<file>                       Specifies the output file name.
/target:exe                       Create a console application (default). (Short form: /t)
/target:winexe                    Create a Windows application.
/target:library                   Create a library assembly.
/target:module                    Create a module that can be added to an assembly.
/doc[+|-]                         Generates XML documentation file.
/doc:<file>                       Generates XML documentation file to <file>.

                                  - INPUT FILES -
/addmodule:<file_list>            Reference metadata from the specified modules.
/recurse:<wildcard>               Include all files in the current directory and subdirectories according to the wildcard specifications.
/reference:<file_list>            Reference metadata from the specified assembly. (Short form: /r)

                                  - RESOURCES -
/linkresource:<resinfo>           Links the specified file as an external assembly resource. resinfo:<file>[,<name>[,public|private]] (Short form: /linkres)
/nowin32manifest                  The default manifest should not be embedded in the manifest section of the output PE.
/resource:<resinfo>               Adds the specified file as an embedded assembly resource. resinfo:<file>[,<name>[,public|private]] (Short form: /res)
/win32icon:<file>                 Specifies a Win32 icon file (.ico) for the default Win32 resources.
/win32manifest:<file>             The provided file is embedded in the manifest section of the output PE.
/win32resource:<file>             Specifies a Win32 resource file (.res).

                                  - CODE GENERATION -
/optimize[+|-]                    Enable optimizations.
/removeintchecks[+|-]             Remove integer checks. Default off.
/debug[+|-]                       Emit debugging information.
/debug:full                       Emit full debugging information (default).
/debug:pdbonly                    Emit PDB file only.

                                  - ERRORS AND WARNINGS -
/nowarn                           Disable all warnings.
/nowarn:<number_list>             Disable a list of individual warnings.
/warnaserror[+|-]                 Treat all warnings as errors.
/warnaserror[+|-]:<number_list>   Treat a list of warnings as errors.

                                  - LANGUAGE -
/define:<symbol_list>             Declare global conditional compilation symbol(s). symbol_list:name=value,... (Short form: /d)
/imports:<import_list>            Declare global Imports for namespaces in referenced metadata files. import_list:namespace,...
/optionexplicit[+|-]              Require explicit declaration of variables.
/optioninfer[+|-]                 Allow type inference of variables.
/rootnamespace:<string>           Specifies the root Namespace for all type declarations.
/optionstrict[+|-]                Enforce strict language semantics.
/optionstrict:custom              Warn when strict language semantics are not respected.
/optioncompare:binary             Specifies binary-style string comparisons. This is the default.
/optioncompare:text               Specifies text-style string comparisons.

                                  - MISCELLANEOUS -
/help                             Display this usage message. (Short form: /?)
/noconfig                         Do not auto-include VBC.RSP file.
/nologo                           Do not display compiler copyright banner.
/quiet                            Quiet output mode.
/verbose                          Display verbose messages.

                                  - ADVANCED -
/baseaddress:<number>             The base address for a library or module (hex).
/bugreport:<file>                 Create bug report file.
/codepage:<number>                Specifies the codepage to use when opening source files.
/delaysign[+|-]                   Delay-sign the assembly using only the public portion of the strong name key.
/errorreport:<string>             Specifies how to handle internal compiler errors; must be prompt, send, none, or queue (default).
/filealign:<number>               Specify the alignment used for output file sections.
/keycontainer:<string>            Specifies a strong name key container.
/keyfile:<file>                   Specifies a strong name key file.
/libpath:<path_list>              List of directories to search for metadata references. (Semi-colon delimited.)
/main:<class>                     Specifies the Class or Module that contains Sub Main. It can also be a Class that inherits from System.Windows.Forms.Form. (Short form: /m)
/moduleassemblyname:<string>      Name of the assembly which this module will be a part of.
/netcf                            Target the .NET Compact Framework.
/nostdlib                         Do not reference standard libraries (system.dll and VBC.RSP file).
/platform:<string>                Limit which platforms this code can run on; must be x86, x64, Itanium or anycpu (default).
/sdkpath:<path>                   Location of the .NET Framework SDK directory (mscorlib.dll).
/utf8output[+|-]                  Emit compiler output in UTF8 character encoding.
@<file>                           Insert command-line settings from a text file.
/vbruntime[+|-]                   Compile with/without the default Visual Basic runtime.
/vbruntime:<file>                 Compile with the alternate Visual Basic runtime in <file>.
Post Reply