2010. 3. 8. 22:57

명령어상에서 JScript 코드 컴파일하기 - jsc

최근에 .js 파일을 명령어상에서 컴파일하여 exe 를 생성할 수 있다는 사실을 알았다. 정말 멋지군. MS 에서 임의로 링크를 없앨 수 있어 원본 내용을 복사해 두었다. 물론 마지막에는 원본 링크가 있다.

JScript 8.0

How to: Compile JScript Code from the Command Line 

To produce an executable JScript program, you must use the command-line compiler, jsc.exe. There are several ways to start the compiler.

If Visual Studio is installed, you can use the Visual Studio Command Prompt to access the compiler from any directory on your machine. The Visual Studio Command Prompt is in the Visual Studio Tools program folder within the Microsoft Visual Studio program group.

As an alternative, you can start the compiler from a Windows command prompt, which is the typical procedure if Visual Studio is not installed.

The Windows Command Prompt

To start the compiler from a Windows command prompt, you must run the application from within its directory or type the fully qualified path to the executable at the command prompt. To override this default behavior, you must modify the PATH environment variable, which enables you to run the compiler from any directory by simply typing the compiler name.

To modify the PATH Environment Variable

  1. Use the Windows Search feature to find jsc.exe on your local drive. The exact name of the directory where jsc.exe is located depends on the name and location of the Windows directory and the version of the .NET Framework installed. If you have more than one version of the .NET Framework installed, you must determine which version to use (typically the latest version).

    For example, the compiler may be located in C:\WINNT\Microsoft.NET\Framework\v1.0.2914.

  2. Right-click the My Computer icon on your Desktop (Windows 2000), and select Properties from the shortcut menu.

  3. Select the Advanced tab and click the Environment Variables button.

  4. In the System variables pane, select "Path" from the list and click Edit.

  5. In the Edit System Variable dialog box, move the cursor to the end of the string in the Variable Value field and type a semicolon (;) followed by the full directory name found in Step 1.

    Continuing with the example in Step 1, you would type:

    ;C:\WINNT\Microsoft.NET\Framework\v1.0.2914

  6. Click OK to confirm your edits and close the dialog boxes.

After you change the PATH environment variable, you can run the JScript compiler at the Windows command prompt from any directory on the machine.

Using the Compiler

The command-line compiler has some built-in help. A help screen is displayed by using the /help or /? command-line option or by using the compiler without any options. For example:

jsc /help

There are two ways to use JScript. You can write programs to be compiled from the command line, or you can write programs to be run in ASP.NET.

To compile using jsc

  • At the command prompt, type jsc file.js

    The command compiles the program named file.js to produce the executable file named file.exe.

To produce a .dll file using jsc

  • At the command prompt, type jsc /target:library file.js

    The command compiles the program named file.js with the /target:library option to produce the library file named file.dll.

To produce an executable with a different name using jsc

  • At the command prompt, type jsc /out:newname.exe file.js

    The command compiles the program named file.js with the /out: option to produce the executable named newname.exe.

To compile with debugging information using jsc

  • At the command prompt, type jsc /debug file.js

    The command compiles the program named file.js with the /debug option to produce the executable named file.exe and a file named file.pdb that contains debugging information.

There are many more command-line options available for the JScript command-line compiler. For more information, see JScript Compiler Options.


원본 링크 : http://msdn.microsoft.com/en-us/library/7435xtz6%28VS.80%29.aspx