我試圖在Visual Studio代碼中設置一個構建任務來調用PowerShell中編寫的現有構建腳本。 這是我如何設置我的生成任務我如何配置任務以調用vscode中的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
嘗試改變:「-ExecutionPolicy無限制」到「設置ExecutionPolicy -ExecutionPolicy無限制」 – seN
它似乎這條道路將不得不改變: - 文件$ {CWD} \源\部署\ build.ps1;不知道「-File」是否是正確的命令tbh。 – seN
它沒有幫助,這些是參數powershell命令(https://technet.microsoft.com/en-us/library/hh847736.aspx) 和我測試它在命令行,它的工作原理 –