Manually compiling the CS file with the CSC command line

Source: Internet
Author: User

In general, when you are learning C #, write your code in Notepad and then use the command line to execute the CSC command line to compile the CS file. There are two methods of

1: Configure the environment once and for all

generally in C:\Windows\Microsoft.NET\Framework\v4.0.30319;

Right-click on "Computer"--"properties"--"Advanced system Settings"--"Environment variables"-"System variables" to find the variable path
Add paths to Path: c:/windows/microsoft.net/framework/v4.0.30319/.

Note: Please check the character before configuration, if there is a semicolon, if not add, why do not elaborate, I believe all understand.

Then run the command Csc/t:exe/out:e:\secondtext directly. EXE E:first.cs

2: CSC is executed every time

Start-run-type cmd, paste the above path past, and at the end add "\CSC", as follows:

At this point we can already type "-?" To verify that it works correctly, if the parameter hint list is displayed successfully, the csc.exe file path will need to be repositioned if it fails. Such as:

3. Operation Csc.exe need to enter the necessary parameters, the specific parameters can refer to other information, here only a few of the parameters required in this example

/target:library can be abbreviated as/t:library Build Library

/out:< file name > This file name contains a path that represents the library file name and path to be generated, such as/out:d:\test\a.dll. This means that the compiled A.dll will be generated under the d:\test\ path. Note: If there is no write path, only the class library name, such as/out:a.dll, is written. Then the A.dll file will be generated to the command line at the beginning of the character's letter, such as A.dll will be generated to the G packing directory.

4. After specifying the build path of the class library, we will further specify the source file, which is to tell CSC to compile those files. So how to tell? Very simple, continue typing the source file path in. For example, your. cs file path is as follows: F:\csctest\programm.cs. Then the effect will be as follows:

Note: There are spaces in front of F

This will allow you to compile the Programm.cs file into the D:\test\a.dll file.

If you want to compile all CS files in the specified directory into the A.dll file, then change the Programm.cs to *.cs.

You can now implement manual compilation.

C:\>c:\windows\microsoft.net\framework\v4.0.30319\csc/t:exe/out:e:\secondtext.exe E:first.cs

Manually compiling the CS file with the CSC command line

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.