gpt4 book ai didi

visual-studio-code - 我如何配置任务以在 vscode 中调用 powershell 脚本

转载 作者:行者123 更新时间:2023-12-04 14:25:31 29 4
gpt4 key购买 nike

我正在尝试在 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
}
]
}

但这里是我运行任务时的输出

. : File C:\Users\chkeita\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3 + . 'C:\Users\chkeita\Documents\WindowsPowerShell\Microsoft.PowerShell_ ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess -File : The term '-File' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + -File f:\Dev\spf3/source/deployment/build.ps1 -NoProfile -executionpo ... + ~~~~~ + CategoryInfo : ObjectNotFound: (-File:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException



我尝试重新排序参数并将它们合并到一个字符串中,但没有成功

我错过了什么?
在 vscode 中是否有更好的方法来做到这一点

最佳答案

这是工作版本。见 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
}
]
}

关于visual-studio-code - 我如何配置任务以在 vscode 中调用 powershell 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35645842/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com