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.