How to set up a task to call powershell script in vscode

I am trying to set up an assembly task in visual studio code to invoke an existing script assembly written in powershell. This is how I created my build task

{
    "version": "0.1.0",
    "command": "powershell",
    "isShellCommand": true,
    "args": [   
        "-File ${cwd}/source/deployment/build.ps1",
        "-NoProfile",
        "-ExecutionPolicy Unrestricted"
    ],
    "taskSelector": "-task ",
    "showOutput": "always",
    "tasks": [
        {
            "taskName": "build",
            "showOutput": "always",
            "isBuildCommand": true
        }
    ]
}

but here is the conclusion when I run the task

.: File C: \ Users \ chkeita \ Documents \ WindowsPowerShell \ Microsoft.PowerShell_profile.ps1 cannot be loaded, because running scripts are disabled on this system. For more information, see About_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170. : 1 char: 3+. "C:\Users\chkeita\Documents\WindowsPowerShell\Microsoft.PowerShell_... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~     + CategoryInfo: SecurityError: (:) [], PSSecurityException     + FullyQualifiedErrorId: UnauthorizedAccess -File: " -File" , , script . , , , . : 1 char: 1 + -File f:\Dev\spf3/source/deployment/build.ps1 -NoProfile -executionpo... + ~~~~~     + CategoryInfo: ObjectNotFound: (-File: String) [], CommandNotFoundException     + FullyQualifiedErrorId: CommandNotFoundException

-

? vscode

+4
1

. . github .

{
    "version": "0.1.0",
    "command": "powershell",
    "args": [   
        "-ExecutionPolicy",
        "Unrestricted",
        "-NoProfile",
        "-File",
        "${cwd}/source/deployment/build.ps1"       
    ],
    "taskSelector": "-task ",
    "showOutput": "always",
    "tasks": [
        {
            "taskName": "build",
            "showOutput": "always",
            "isBuildCommand": true
        }
    ]
}
+7

All Articles