如何为 Sublime 3 创建一个构建系统来编译当前的 cs 文件?(C#)

Cur*_*lop 2 c# sublimetext3

例如,如果我在 sublime 中的当前文件是 foo.cs,我希望它运行“csc /out:foo.exe foo.cs”。我不想运行完整的 msbuild。

Cur*_*lop 5

在 Sublime 中,在以下文本中选择菜单 Tools > Build System > New Build System Paste。将其另存为“C#.sublime-build”。

{
    "cmd": ["cmd", "/c", "del", "${file/\\.cs/\\.exe/}", "2>NUL", "&&", "csc", "/nologo", "/out:${file/\\.cs/\\.exe/}", "$file"],
    "file_regex": "^(...*?)[(]([0-9]*),([0-9]*)[)]",
    "variants": [
        { "name": "Run", "cmd": ["cmd", "/c", "start", "cmd", "/c", "${file/\\.cs/\\.exe/}"] }
    ],
}
Run Code Online (Sandbox Code Playgroud)

或者当你输入 ctrl-b 时,这条替代线会构建并运行它:

"cmd": ["cmd", "/c", "del ${file/\\.cs/\\.exe/} 2>NUL && csc /nologo /out:${file/\\.cs/\\.exe/} $file && start cmd /c ${file/\\.cs/\\.exe/}"],
Run Code Online (Sandbox Code Playgroud)