Reputation: 7329
For example, if my current file in sublime is foo.cs, I want it to run "csc /out:foo.exe foo.cs". I don't want to run a full msbuild.
Upvotes: 1
Views: 6974
Reputation: 1
just use this and your OK
{
"cmd": ["csc", "/out:$file_base_name.exe", "$file_name"],
"selector": "source.cs",
"shell": true,
"working_dir": "${file_path}",
"variants": [
{
"cmd": ["cmd", "/c", "csc", "/out:$file_base_name.exe", "$file_name", "&&", "start", "cmd", "/k", "$file_base_name.exe"],
"name": "Build and Run",
"shell": true,
"working_dir": "${file_path}"
}
]
}
Upvotes: 0
Reputation: 1
The below C#.sublime-build compiles and runs any c# program in a new pop-up console. But it only applies for windows users. Other os users may change the "cmd" key's value a little bit in the following C#.sublime-build to make their custom C#.sublime-build system. Hope, it will be helpful:
{
"cmd": ["csc", "$file_name", "&&", "start","cmd", "/k", "$file_base_name.exe"],
"file_regex": "^(...?):([0-9]):?([0-9]*)",
"working_dir": "$file_path",
"selector": "source.cs",
"shell": true,
"quiet": true
}
Upvotes: 0
Reputation: 1
You can create a new Build System with the following configurations.
{
"cmd":["csc","$file"],
"selector":"source.cs",
"variants" :
[
{
"cmd" : "$file_base_name.exe",
"name" : "run",
"shell" : true,
}
]
}
Upvotes: 0
Reputation: 7329
In Sublime, choose menu Tools > Build System > New Build System Paste in the following text. Save it as "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/}"] }
],
}
Or this alternative line builds and runs it all when you put ctrl-b:
"cmd": ["cmd", "/c", "del ${file/\\.cs/\\.exe/} 2>NUL && csc /nologo /out:${file/\\.cs/\\.exe/} $file && start cmd /c ${file/\\.cs/\\.exe/}"],
Upvotes: 6