Tasks are only available on a workspace folder?
Asked Answered
A

2

15

Can't find an simple, basic solution anywhere for this problem so I figured it was worth posting it here.

When I go to run my code as a task, I get the following message: "Tasks are only available on a workspace folder" - I can't find a solution anywhere and I'm a beginner at Visual Studio Code so I might need the answer / solution explaining in more simpler terms.

VSC Version = 1.17.0

Arvy answered 7/10, 2017 at 9:14 Comment(5)
Please display your code. You have to display some efforts.Hustings
Hi; it was a simple print("Hello World") to test it and then I receive the error message about Tasks being only available on a work space folder, it happens regardless of the programming language in use.Arvy
you need to open the folder containing the file you need to run as a project folder in vscodeDanndanna
@suraj Thank you for your help! Your answer appears to have worked for me, much appreciated! : )Arvy
great.. added an answerDanndanna
D
14

Visual Studio Code treats the folder containing your program file as a workspace folder.

Your tasks created will be contained in a file tasks.json within a hidden folder .vscode inside your project or workspace folder.

So instead of opening the file directly to create a task, you need to open the folder as a project.

Danndanna answered 7/10, 2017 at 12:21 Comment(2)
What does task actually mean in VSCode?Oarlock
@Jos this should get you started. Older docs hereDanndanna
S
-1

The "Workspace launch configuration" section of VSCode mentions:

With multi-root workspaces, VS Code searches across all folders for launch.json debug configuration files and displays them with the folder name as a suffix.
Additionally VS Code will also display launch configurations defined in the workspace configuration file.

Example of settings: vscode-tslint/vscode-tslint.code-workspace


As an alternative, you can have User level tasks to share them across projects since VSCode 1.42 (Jan. 2020).

But regarding workspace tasks, since VSCode 1.57 (May 2021), said tasks will have to be "trusted" by anyone opening the same workspace, assuming you have versioned and pushed the .vscode folder.

Safe code browsing

It's great that there is so much source code available on public repositories and file shares. No matter the coding task or problem, there is probably already a good solution available somewhere.

However, using open-source code and tools does have risks and you can leave yourself open to malicious code execution and exploits.

Workspace Trust provides an extra layer of security when working with unfamiliar code by preventing automatic code execution when a workspace is open in Restricted Mode.

https://static.mcmap.net/file/mcmap/ZG-AbGLDKwftXV-pWS2nZ7-ocVI0bRywWRfQcFyQcC2jaRA/media/microsoft/vscode-docs/vnext/release-notes/images/1_57/workspace-trust-editor.png

Slew answered 6/6, 2021 at 6:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.