26

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

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

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

4

1 回答 1

18

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"
        }   
     ] 
 }
*/

只需注释掉文件的其余部分,取消注释上面的 JSON 文本,然后将“command”从“msbuild”更改为“xbuild”(相当于 Mono)。现在点击ctrl++shift成功B编译项目。

希望一旦退出预览版,手动修改配置文件的必要性或繁琐性将降低。

编辑

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

于 2015-04-30T00:30:24.290 回答