在Ubuntu上使用VSCode编译C#项目

M.B*_*ock 25 c# ubuntu mono visual-studio-code

我根据文档中提供的各种教程在Ubuntu 14.04上设置了VSCode - 我尽可能多地尝试了.编辑器运行没有问题,并且(在完成Mono版本差异之后)提供了与我认为的大多数替代方案相比的优越编码体验.

我的问题出现在尝试编译我的C#项目时.这是我在完成入门指南时所期望的功能.点击ctrl+ shift+后,B我最初提示创建一个tasks.json文件,该文件看起来提供了项目特定的快捷键操作配置.从最初tasks.json生成的注释中,它似乎是针对Windows并且指的tsc.exe是一个TypeScript编译器的程序.

我花了一点时间在同一台笔记本电脑上使用MonoDevelop构建项目,但从未设置过编译步骤.我错误地认为这应该是开箱即用的功能,还是我错过了正确处理C#项目的一步?

M.B*_*ock 17

昨晚查看默认tasks.json文件时,我一定很不耐烦.有一节引用msbuild(向下):

// Uncomment the section below to use msbuild and generate problems 
// for csc, cpp, tsc and vb. The configuration assumes that msbuild 
// is available on the path and a solution file exists in the  
// workspace folder root. 
/* 
{   
    "version": "0.1.0",
    "command": "msbuild",
    "args": [
        // Ask msbuild to generate full paths for file names.       
        "/property:GenerateFullPaths=true"  
    ],
    "taskSelector": "/t:",
    "showOutput": "silent",
    "tasks": [
        {
            "taskName": "build",
            // Show the output window only if unrecognized errors occur.            
            "showOutput": "silent",
            // Use the standard MS compiler pattern to detect errors, warnings          
            // and infos in the output.
            "problemMatcher": "$msCompile"
        }   
     ] 
 }
*/
Run Code Online (Sandbox Code Playgroud)

只需注释掉文件的其余部分,取消注释上面的JSON文本,并将"命令"从"msbuild"更改为"xbuild"(等效的Mono).现在点击ctrl+ shift+ B成功编译项目.

希望这个手册修改配置文件一旦出现预览就不那么必要或乏味了.

编辑

现在将此标记为答案.如果在产品发展过程中情况发生变化,将更新或接受更好的答案.