Tasks are only available on a workspace folder?
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.