我正在尝试在visual studio代码中设置构建任务来调用用PowerShell编写的现有构建脚本。 以下是我如何设置构建任务
{
"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
}
]
}
但这是我运行任务时的输出
。 :文件 C:\ Users \用户chkeita \文档\ WindowsPowerShell \ Microsoft.PowerShell_profile.ps1 无法加载,因为在此系统上禁用了运行脚本。 有关更多信息,请参阅about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170。在行:1 char:3 +。 “C:\用户\ chkeita \文件\ WindowsPowerShell \ Microsoft.PowerShell_ ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ + CategoryInfo:SecurityError:(:) [],PSSecurityException + FullyQualifiedErrorId:UnauthorizedAccess -File:术语“-File”未被识别为cmdlet,函数,脚本文件或可操作程序的名称。检查拼写 名称,或者如果包含路径,请验证路径是否正确 再试一次。在行:1个字符:1 + -File f:\ Dev \ spf3 / source / deployment / build.ps1 -NoProfile -executionpo ... + ~~~~~ + CategoryInfo:ObjectNotFound:( - File:String)[],CommandNotFoundException + FullyQualifiedErrorId:CommandNotFoundException
我尝试重新排序参数并将它们合并到一个字符串中而没有任何成功
我缺少什么? 有没有更好的方法在vscode中执行此操作
答案 0 :(得分:8)
这是工作版。有关更多详细信息,请参阅github discussion
{
"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
}
]
}