Sublime Text C# 編譯(csharp.sublime-build)

來源:互聯網
上載者:User

標籤:檔案   添加   ros   sage   var   reg   獲得   adk   tool   

製作:

1. 配置環境變數PATH

C# 7.0C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\BinC:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\RoslynC# 6.0C:\Program Files (x86)\MSBuild\14.0\BinC# 5.0C:\Windows\Microsoft.NET\Framework\v4.0.30319可根據註冊表獲得:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild

2. 添加CSharp Build配置

在Sublime Text中點擊菜單: Tools -> Build System -> New Build System...

粘貼:

{    "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}"            }        ]}

儲存為:csharp.sublime-build

 

使用:

編輯一個cs檔案,儲存。比如test.cs:

 1 using System; 2 using System.ComponentModel; 3 using System.Windows.Forms; 4 using System.Reflection; 5 using System.Runtime.CompilerServices; 6  7 static class Program { 8     [STAThread] 9     public static void Main(params string[] args){10         Test();11         //Console.Write("\nPress any key to EXIT...");12         //Console.ReadKey(true);13     }14 15     static void Test() {16        var s = "?";17        MessageBox.Show(s);18     }19 }

按Ctrl+Shift+B,選擇編譯的類型。上面的例子選擇 Build & Run (Form) ,就能看見結果。

按Ctrl+B,是按上次的編譯類型進行編譯。

Sublime Text C# 編譯(csharp.sublime-build)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.