Search code examples
visual-studio-code7zipvscode-tasks

can i save from delete double quotes at vscode task.json?


Problem

I want to compress project files with ziplist.txt . but then need double quotes in the 7zip command. like this , "\"@ziplist.txt\"". as a result, double quotes are deleted. so tell me what to do if you know how to.

Vscode Task Settings

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "compress",
            "type": "shell",
            "command": "7z",
            "args": [
                "a",
                "./release.zip",
                "\"@ziplist.txt\""
            ],
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

Error messages


ParserError: 
Line |
   1 |  7z a ./release.zip @ziplist.txt
     |                                    ~~~~~~~~
     | The splatting operator '@' cannot be used to reference variables in an expression. '@ziplist' can be used only as an argument to a command. To
     | reference variables in an expression using '$ziplist'.

The terminal process "C:\Program Files\PowerShell\7\pwsh.exe -Command 7z a ./release.zip "@ziplist.txt"" terminated with exit code: 1.

Solution

  • Changed the double quotes used inside to single quotes. This will work.

    It's all. Thanks.

    tasks.json

    {
        // See https://go.microsoft.com/fwlink/?LinkId=733558
        // for the documentation about the tasks.json format
        "version": "2.0.0",
        "tasks": [
            {
                "label": "compress",
                "type": "shell",
                "command": "7z",
                "args": [
                    "a",
                    "./release.zip",
                    "'@ziplist.txt'"
                ],
                "problemMatcher": [],
                "group": {
                    "kind": "build",
                    "isDefault": true
                }
            }
        ]
    }