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

Compiling C# projects with VSCode on Ubuntu(在 Ubuntu 上使用 VSCode 编译 C# 项目)
本文介绍了在 Ubuntu 上使用 VSCode 编译 C# 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I set up VSCode on Ubuntu 14.04 according to the various tutorials available in the documentation - I tried as many as I could make sense of. The editor runs without issue and (after working through Mono version discrepancies) provides a superior coding experience as compared to most of the alternatives in my opinion.

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

My issue comes when trying to compile my C# project. This is functionality that I would have expected when completing the Getting Started guide. After hitting ctrl + shift + B I'm initially prompted to create a tasks.json file which looks to provide project specific configuration of shortkey actions. From comments in the initial tasks.json generated, it appears to be targeting Windows and refers to a tsc.exe program which is a TypeScript compiler.

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

I've spent a little time building projects with MonoDevelop on the same laptop but never had to setup the compilation step. Am I wrong in assuming this should be functionality available out of the box, or have I missed a step for properly handling C# projects?

推荐答案

昨晚浏览默认的 tasks.json 文件时,我一定是不耐烦了.有一个部分引用了 msbuild(朝向底部):

I must have been impatient when looking through the default tasks.json file last night. There is a section that refers to msbuild (towards the bottom):

// 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 成功编译项目.

Just comment out the rest of the file, uncomment the above JSON text, and change "command" from "msbuild" to "xbuild" (the Mono equivalent). Now hitting ctrl+shift+B successfully compiles the project.

希望这种对配置文件的手动修改在预览版结束后将不再那么必要或乏味.

Hopefully, this manual tinkering with configuration files will be less necessary or tedious once it comes out of preview.

编辑

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

Marking this as answer for now. Will update or accept a better answer should things change during the evolution of the product.

这篇关于在 Ubuntu 上使用 VSCode 编译 C# 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

quot;dotnet restorequot; fails with quot;SSL peer certificate or SSH remote key was not OKquot;(“dotnet 恢复因“SSL 对等证书或 SSH 远程密钥不正常而失败)
Accessing network path using C# from Ubuntu(在Ubuntu中使用C#访问网络路径)
How to setup virtual Gpio loopback(如何设置虚拟GPIO环回)
HttpWebRequest NameResolutionFailure exception in .NET (with Mono on Ubuntu)(.NET 中的 HttpWebRequest NameResolutionFailure 异常(在 Ubuntu 上使用 Mono))
Installing Mono 3.x in Ubuntu/Debian(在 Ubuntu/Debian 中安装 Mono 3.x)
Method #39;RouteCollection.get_AppendTrailingSlash#39; not found when using Razor Url helpers in ASP.NET MVC 5 Mono(在 ASP.NET MVC 5 Mono 中使用 Razor Url 帮助程序时找不到方法“RouteCollection.get_AppendTrailingSlash)