Click here to Skip to main content
15,881,092 members
Articles / Programming Languages / Visual Basic
Article

.NET Command Line Tools

Rate me:
Please Sign up or sign in to vote.
1.04/5 (8 votes)
1 Mar 20076 min read 37.9K   340   13  
Various Command Line Tools Available under .NET Development Environment

Introduction

This will help us understand how we can make use of the command line tools which are available with Microsoft Visual Studio.NET.

Background

When I first started Development Under .NET Environment, I used to stuck with some problems like creating Strong Named Key pair file, at the time of installation and registering the Assembly, I was wondering where it was possible to access .NET Functionality from Other languages like C,C++, VB6 or not, etc, and When I found such tools which facilitates the above mentioned tasks plus some other tasks, yes, I was amazed, and since then I have been using those tools which made my difficult task simple. As a Developer we always keep on exploring and keep on stretching the limits of any programming languages. That's why I have decided to write about how we can make use of the command line tools which are already there to make out job simple.

(Note: Even though the command line tools help is available online, I have decided to write it in single document, to facilitate the job of getting all information needed under one roof)

Here we go….

1) Compiler Tools :

a. Visual Basic Compiler : (vbc.exe) – If anyone wish to compile his or her Visual Basic.NET Code, he/she needs to use this tools, the various command line options available with this tool are as follows.

/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>.

There are other options which are available and use. To view all the options available, type following command on the command prompt.

C:\>vbc > vbc.txt

This will help you to accumulate all the command line parameter switches in text

File.

b. C# Compiler: (csc.exe): If anyone wish to compile his or her Visual Basic.NET Code, he/she needs to use this tools, the various command line options available with this tool are as follows.

/out:<file> 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:<file> XML Documentation file to generate

/keyfile:<file> Specify a strong name key file

/keycontainer:<string> Specify a strong name key container

/platform:<string> Limit which platforms this code can run on: x86, Itanium, x64, or anycpu. The default is anycpu.

There are other options which are available and use. To view all the options available, type following command on the command prompt.

C:\>cbc > cbc.txt

This will help you to accumulate all the command line parameter switches in text

File.

2) To Create Install Windows Service : (InstallUtil.exe) – If you have developed Windows Service and You wish to install it on the System Where you are going to deploy your application. You definitely first need to install it properly. To Install Windows Service type following on the command prompt.

C:\InstallUtil <servicename>.exe

At some point you might also want to Uninstall the service manually (normally development process), In that case you can uninstall it using following command

C:\InstallUtil /u <servicename>.exe

3) To Register Assembly in GAC: (regasm.exe) – In .NET based development we time to time develop and deploy various types of assemblies, It includes, public, private assemblies. Public assemblies are those assemblies which are installed in Global Assembly Cache (GAC) and are available for other applications installed on that System. To install and register any assembly (public), either you can directly drag and drop that assembly in to assembly cache, or use following command line option

C:\regasm <assembly name>

4) To Register Services: (regsvcs.exe) – This can be use to Load and register an assembly, generates and registers, installs a type library into a specified COM+ Application. To do this type following command

C:\regsvcs <assemblyfile.dll>

5) Type Library Importer: (TlbImp.exe) - The Type Library Importer converts the type definitions found within a COM type library into equivalent definitions in a common language runtime assembly. The output of Tlbimp.exe is a binary file (an assembly) that contains runtime metadata for the types defined within the original type library. Use import assembly, type following command.

C:\TlbImp tlbfile

Here tlbfile is the any COM Type Library file.

6) Type Library Exporter: (Tlbexp.exe) – The Type Library exporter generates a type library that describes the types defined in common language runtime. To generate the type library type following command.

C:\Tlbexp <assemblyname>

7) Strong Name Tool: (sn.exe) – In .NET environment based development, distributing an assembly, and installing it and registering it on the client' system is very important. For an assembly to be a public assembly, it should be installed and correctly registered in Machine wide Code Cache, that's Global Assembly Cache or simply GAC. For this Assembly must be signed with a Strong Name. For this purpose we can use Strong Name tool (sn.exe). To Sign an assembly with Strong Name type following on the command Line.

C:\sn –k <keyfilename>.snk

This will generate key pair file with an extension .snk

8) Certificate Creation Tool: (makecert.exe) – The Certificate Creation tool generates X.509 certificates for testing purposes only. It creates a public and private key pair for digital signatures and stores it in a certificate file. This tool also associates the key pair with a specified publisher's name and creates an X.509 certificate that binds a user-specified name to the public part of the key pair. To create a test certificate type following command on the command line

C:\makrcert [options] outputcertificatefile

The sample certificate will be created with and extension (.CER)

[For all above tools mentioned here, there are many command line switches available for use. Optional parameters are stored in text file with the same name as that of the tool name and attached with this article for your reference. Alternatively, one can view the various options by c:\[toolname] /? From the command line. I have simply diverted the console output into a text file for ease of reading]

[Other tools which are not included in this article will be covered in next part of the same article.]

Please if you have any suggestions, I would be glad to hear it from you.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --