zoukankan      html  css  js  c++  java
  • Sublime Text C# 编译(csharp.sublime-build)

    制作:

    1. 配置环境变量PATH

    C# 7.0
    C:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuild15.0Bin
    C:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuild15.0BinRoslyn
    C# 6.0
    C:Program Files (x86)MSBuild14.0Bin
    C# 5.0
    C:WindowsMicrosoft.NETFrameworkv4.0.30319
    可根据注册表获得:HKEY_LOCAL_MACHINESOFTWAREMicrosoftMSBuild

    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("
    Press 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,是按上次的编译类型进行编译。

  • 相关阅读:
    SQLServer 高可用、高性能和高保护延伸
    SQLServer 通过DMV实现低影响的自动监控和历史场景追溯
    查找表包含的页和页所在的表
    出身在二三线城市软件工作者的悲哀
    SQL语句实现取消自增列属性
    基于Apache(without ssl)的svn环境搭建
    sqlite3 命令行操作
    HTML常用特殊符号集
    IOS项目目录结构和开发流程
    Mac OSX 快捷键&命令行
  • 原文地址:https://www.cnblogs.com/Bob-wei/p/7371416.html
Copyright © 2011-2022 走看看