Where is the tasks.json file in vscode?

前端 未结 4 1042
我在风中等你
我在风中等你 2020-12-14 08:27

I just start to use vscode in linux. I know that the build configuration are set in tasks.json. But where does this file locate?

I tried <

相关标签:
4条回答
  • 2020-12-14 09:01

    2019 Version

    New tasks version 2.0.0

    Here's how to do it step by step


    I compiled this from the documentation:

    First i tried ⬆︎ ⌘ B ... This didn't work for me (I was following a YouTube tutorial... a bit outdated it seems).

    After looking at the documetation i found that you have to initialize your typescript folder. To do so:

    tsc --init - this will generate a file called tsconfig.json

    The documentation said to run code . after you ran tsc --init. Mine worked without is as well as with it. Feel free to play with it and see what it changes cause i honestly don't know.

    After that, move your mouse up to the toolbar (global Terminal menu.)... underneath the Terminal tab, click on the Configure Default Build Task...

    then click on tsc: build and that will generate your tasks.json

    Note that mine generated without the "version": "2.0.0" line... so if yours did the same that means your hardware is too old and you have to upgrade.... i'm kidding! ... Just add "version": "2.0.0", right above "tasks": [, and then you should be fine.

    0 讨论(0)
  • 2020-12-14 09:04

    You have to create it manually. Current version of VS Code only creates launch.json automatically. The auto detect claims made in docs also don't work (for me at least).

    Here is a sample file you can create in .vscode/tasks.json that defines gulpjs tasks:

    {
        "version":"0.1.0",
        "command": "./node_modules/.bin/gulp",
        "isShellCommand": true,
        "tasks":[
            {
                "taskName": "test",
                "isTestCommand": true,
                "problemMatcher": "$gulp-tsc",
                "showOutput": "always"
            }
        ]
    }
    
    0 讨论(0)
  • 2020-12-14 09:15
    1. Open a folder with vscode
    2. Hit F1
    3. Select "Tasks: Configure Task Runner"
    4. Hit Enter and vscode will create a sample task.json for you
    0 讨论(0)
  • 2020-12-14 09:26

    DANGER! All of this has changed. Current Microsoft docs on this topic are NOT consistent. Note the version warning at the top of this:

    https://code.visualstudio.com/docs/editor/tasks

    Note the conflicts between this:

    https://docs.microsoft.com/en-us/visualstudio/ide/customize-build-and-debug-tasks-in-visual-studio?view=vs-2017

    and this:

    https://code.visualstudio.com/docs/languages/cpp

    I cannot get a straight answer on what works now (12MAR2019) to save my life, but I can tell you that none of the permutations I've tried, namely:

    {., .vs, .vscode} / { tasks.json, tasks.vs.json}

    are working for me. It really drives me crazy that they changed this crap without updating ALL of the pertinent documentation, and the backward-compatibility "support" is just making things MUCH WORSE.

    0 讨论(0)
提交回复
热议问题