Installation of the C # compiler and CLI

Source: Internet
Author: User
Tags net command

In order to compile and run the C # program, you need to install the compiler and CLI (Common language framework) platform for the corresponding version of the code.

(Part of the content from the "C # essence")

For the mainstream CLI platform (Microsoft. NET), there are two kinds of installation scenarios:

1. Minimum installation: Download the installation. NET Framwork2.0 or later release packages.

2. Install the visual Studio IDE for a feature-rich IDE (including IntelliSense, support for project files, and so on).

In order to compile using the command line, either visual Studio or only the runtime is installed, you must set the PATH environment variable to contain the C # compiler csc.exe.

For Microsoft. NET to set the compiler path:

1. If the Visual Studio IDE is already installed on the current computer, select Start, All Programs, Microsoft Visual Studio. NET, Visual Studio Tools, Visual Studio command Prompt, which opens a command window that puts the compiler csc.exe in the path for easy execution in any directory.

After execution, you will get the. dll file that corresponds to the animal class file.

2. If the visual Studio IDE is not installed. You need to display a reference to the full compiler path name. The location of the compiler is%windir%\microsoft .net\framwork\< version >. Where%windir% points to a special environment variable under the native Windows installation directory,< version > refers to the. NET framwork version number that is installed on the current computer (eg. v2.0.50727, v3.5). Each time the compiler csc.exe is invoked, the command is used first: set Path=%windir%\microsoft .net\framwork\< version > Add the compiler location to the path. Then use csc.exe to compile the specified file.

3. You can add a compiler path to the system environment variable to avoid providing a full path each time you call csc.exe

(1) Configuring the command-line compiler

environment variable, advanced system settings, properties, computer, and so on double-click the path variable in system variables to include the compiler path at the end of the current variable value (the path variable values are separated by semicolons).

(Note the path and version number, go to install the directory yourself to view.) Take my installation path as an example) in the path variable to add; C:\Windows\Microsoft.NET\Framwork64\v3.5

If the configuration is successful, CMD enters the command line window input: csc.exe/? The list of options supported by the C # compiler is displayed ():

(2) Configure additional. NET command-line tools:

Add a command-line tool path to the path variable in (1), (for example);D: \microsoft Visual Studio 2013\sdk\v3.5\bin

If the configuration is successful, in the Command Line window, enter: Gacutil/? View the various options for the GAC tool Gacutil.exe.

After completing the path configuration,-open cmd and go to the directory where the source file is located-enter command: Csc/target:library Animal.cs to get the compiled file Animal.dll ()

Where/target:library specifies that the file is compiled into a single file *.dll assembly. See MSDN for additional output options, using the compiler to reference external assemblies, and more.

Installation of the C # compiler and CLI

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.