Sublime Text C # compilation (Csharp.sublime-build)

Source: Internet
Author: User
Tags sublime text

Making:

1. Configure the environment variable path

7.0 C:\Program Files (x86) \microsoft Visual Studio\ \enterprise\msbuild\15.0\binc:\program Files (x86) \microsoft Visual Studio\2017 \enterprise\msbuild\15.06.0C:\Program Files (x86) \msbuild\14.0 5.0 C:\Windows\Microsoft.NET\Framework\v4.   0.30319 available According to the registry: Hkey_local_machine\software\microsoft\msbuild

2. Add CSharp Build Configuration

In sublime text, click menu: Tools--build system--New build system ...

Paste:

{    "Shell_cmd":"csc.exe/utf8output/unsafe/out:\ "${file_path}/${file_base_name}.exe\" \ "${file}\"",    "File_regex":"^(.. [^:]*]:([0-9]+):? ([0-9]+)?:? (.*)$",    "Working_dir":"${file_path}",    "selector":"Source.cs",    //" encoding": "cp936",    "variants":        [            {                "name":"Build & Run",                "Shell_cmd":"csc.exe/utf8output/unsafe/out:\ "${file_path}/${file_base_name}.exe\" \ "${file}\" && start \ "${file_ Base_name}.exe\ "/d \" ${file_path}\ "\" ${file_base_name}.exe\ "",                "Working_dir":"${file_path}"            },            {                "name":"Run",                "Shell_cmd":"start \ "${file_base_name}.exe\"/d \ "${file_path}\" \ "${file_base_name}.exe\"",                "Working_dir":"${file_path}"            },            {                "name":"Build (Form)",                "Shell_cmd":"Csc.exe/utf8output/unsafe/t:winexe/r:system.windows.forms.dll; System.drawing.dll/out:\ "${file_path}/${file_base_name}.exe\" \ "${file}\"",                "Working_dir":"${file_path}"            },            {                "name":"Build & Run (Form)",                "Shell_cmd":"Csc.exe/utf8output/unsafe/t:winexe/r:system.windows.forms.dll; System.drawing.dll/out:\ "${file_path}/${file_base_name}.exe\" \ "${file}\" && start \ "${file_base_name}.exe \ "/d \" ${file_path}\ "\" ${file_base_name}.exe\ "",                "Working_dir":"${file_path}"            },            {                "name":"Run (Form)",                "Shell_cmd":"start \ "${file_base_name}.exe\"/d \ "${file_path}\" \ "${file_base_name}.exe\"",                "Working_dir":"${file_path}"            }        ]}

Save As: Csharp.sublime-build

Use:

Edit a CS file and save it. such as Test.cs:

1 usingSystem;2 usingSystem.ComponentModel;3 usingSystem.Windows.Forms;4 usingSystem.Reflection;5 usingSystem.Runtime.CompilerServices;6 7 Static classProgram {8 [STAThread]9      Public Static voidMain (params string[] args) {Ten Test (); One         //Console.Write ("\npress any key to EXIT ..."); A         //Console.readkey (true); -     } -  the     Static voidTest () { -        vars ="?"; - MessageBox.Show (s); -     } +}

Press Ctrl+shift+b to select the type of compilation. The above example chooses Build & Run (Form) to see the results.

Press Ctrl+b to compile according to the last compilation type.

Sublime Text C # compilation (Csharp.sublime-build)

Related Article

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.