|
|
|
|
|||||||||||||
Click here to return to my article index
Command Line Compiling in .NETA command line compiler is something that many of today's Microsoft centric developers have never had to deal with. Many of us have only developed Windows applications with Visual Basic. It is not possible to compile a Visual Basic 6 (and lowe) application/component using the command line - you are restricted to the IDE. Well, the .NET Framework has changed all of that. We now have a command line compiler for both C# (csc.exe), VB.NET (vbc.exe), and most likely any new language that is ported to .NET. The idea of compiling an application at the command line is something that many developers detest. However, there developers among us that relish in the quick and powerful capabilities of a command line compiler. This article will give examples of how to use the VB.NET compiler but many of the terms/ideas can be applied to the C# compiler as well.
Typically, we will use the command line compiler to create an assembly (definition below).
The library assembly is an assembly without a main entry point (ie there is no main or winmain function). Library
assemblies are used when developing ASP.NET pages with code behind files. There was a question on one of the lists
at http://aspalliance.com/lists recently that read something like, "How do I
compile the .vb file for one of the quickstart samples?". So, here is an example that demonstrates how to compile a
.vb code behind file. vbc /t:library /out:bin/myLibraryAssembly.dll myCodeBehindFile.vbLet's dissect this command line: 'vbc' is the name of the VB.NET compiler executable '/t:library' tells the compiler we want a library assembly '/out:bin/myLibraryAssembly.dll' tells the compiler we want the library in a .dll called myLibraryAssembly.dll and to place the dll in the bin folder 'myCodeBehindFile.vb' is the code behind file that we want compiled What if we wanted to create an single file (executable) assembly from a VB.NET code module? Well, we could create a single file assembly (or multiple file assembly). The syntax for creating a single file assembly isn't that much different from the syntax to create a library assembly. When creating a single file assembly, we can decide the name of the executable or we can use the compiler default (same name as the code module). Here is an example that specifies the name of the executable: vbc /out:mySingleFileAssembly.exe myCodeBehindFile.vbNotice we didn't include the '/t:library' switch because we are creating a single file (executable) assembly - not a library assembly. Also, a single file assembly must have an entry point. If you want to use the default assembly name then simply remove the '/out:mySingleFileAssembly.exe' switch. Well, I hope this article has given you a jumpstart into the world of command line compiling in .NET. For more information on Assemblies check out Remas article Using .NET Components in ASP.NET". Click here to return to my article index | |||||||||||||||
| Copyright © 2000-2003 ASPAlliance.com Page Rendered at
2/9/2010 2:25:03 PM |
|||||||||||||||