27

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.

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.

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?

10
  • might be a wild guess here but what about v8dotnet project and trying to bind that as the TS compiler ? Commented Apr 29, 2015 at 23:10
  • @Pogrindis - While VSCode seems to think I'm trying to build a TypeScript project, I'm actually trying to build a C# project. Are you suggesting that v8dotnet is required to build C# projects? Commented Apr 29, 2015 at 23:12
  • ahh sorry, I thought you were working with some c# server side but with typescript front end.. Im even more confused now! Commented Apr 29, 2015 at 23:13
  • 3
    Upvoted for alerting me to the existence of a Microsoft supported Linux C# IDE Commented Apr 29, 2015 at 23:18
  • 3
    I just got it working on my Mac. Perhaps the same settings will do on your system. I wrote it down on my blog: Compile a Visual Studio solution in Visual Studio Code on OSX Commented Apr 30, 2015 at 13:18

1 Answer 1

18

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

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.

EDIT

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

Sign up to request clarification or add additional context in comments.

2 Comments

or hopefully this manual tinkering will still be around but not be the default mode of interaction would be my vote
For anyone reading this today, the JSON is identical; the key part, mentioned in this answer, is to change command from msbuild to xbuild.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.