How do you compile a console application with VS Code (Windows platform)?

22,318

This is not as simple as it should be, but the way to do this is through the command palette (F1 key) and type run task, it should look like this:

F1 Command Palette Run Task

After you click this you will probably get an error in which you do not have a task runner created, you can either press the button or go back to the command palette and edit task runners.

What this will do is create a .vscode directory with a tasks.json file in it, you can either rummage through and uncomment the msbuild section or simply paste this as an override:

{   
    "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"
        }   
     ] 
 }

Once you've done that you can edit to your build specifications and either the command palette or CTRL+SHIFT+B will run the builder. Here is the link information for the Tasks: Tasks in visual Studio Code

Share:
22,318
v1n1akabozo
Author by

v1n1akabozo

Updated on February 26, 2020

Comments

  • v1n1akabozo
    v1n1akabozo about 4 years

    The question is pretty straightforward. Using VS Code (not visual studio), I've been able to run it using the dnx run command but how am i supposed to ask for anyone to install it in order to run the application?

    In other words, is it possible to generate an executable from VS code?

    Update 1:

    The selected answer is almost complete. I had to download the Microsoft Build Tools in order to use msbuild, and also had to create a .csproj file, which wasn't provided by the Yeoman generator i used to create the project.