我已经密切关注了here,here和here设计指南,但我不断收到此PowerShell错误:
由于一个或多个缺少必需参数而无法处理命令:SourcePath FilePattern BuildRegex。
相关配置数据如下。
我已经检查并仔细检查以确保变量存在于我的GET_ACCOUNTS
文件中。我还查看了其他工作任务的配置(例如VSBuild),并且变量声明和PowerShell执行语法没有显着差异。
这里可能出现什么问题?这是一个非常简单的架构 - 没有什么可以打破的。但显然有些事情已经做到了。
来自task.json
:
task.json
来自"inputs": [
{
"name": "SourcePath",
"type": "filePath",
"label": "Source path",
"defaultValue": "",
"required": true,
"helpMarkDown": "Path in which to search for version files (like AssemblyInfo.* files). NOTE: this is case sensitive for non-Windows systems."
},
{
"name": "FilePattern",
"type": "string",
"label": "File pattern",
"defaultValue": "AssemblyInfo.*",
"required": true,
"helpMarkDown": "File filter to replace version info. The version number pattern should exist somewhere in the file(s). Supports minimatch. NOTE: this is casese sensitive for non-Windows systems."
},
{
"name": "BuildRegEx",
"type": "string",
"label": "Build RegEx pattern",
"defaultValue": "\\d+\\.\\d+\\.\\d+\\.\\d+",
"required": true,
"helpMarkDown": "Regular Expression to extract version from build number. This is also the default replace RegEx (unless otherwise specified in Advanced settings)."
},
{
"name": "BuildRegExIndex",
"type": "string",
"label": "Build RegEx group index",
"defaultValue": "0",
"required": false,
"helpMarkDown": "Index of the group in the Build RegEx that you want to use as the version number. Leave as 0 if you have no groups.",
"groupName": "advanced"
},
{
"name": "ReplaceRegEx",
"type": "string",
"label": "RegEx replace pattern",
"defaultValue": "",
"required": false,
"helpMarkDown": "RegEx to replace with in files. Leave blank to use the Build RegEx Pattern.",
"groupName": "advanced"
},
{
"name": "ReplacePrefix",
"type": "string",
"label": "Prefix for replacements",
"defaultValue": "",
"required": false,
"helpMarkDown": "Prefix for the RegEx result string.",
"groupName": "advanced"
},
{
"name": "ReplaceSuffix",
"type": "string",
"label": "Suffix for replacements",
"defaultValue": "",
"required": false,
"helpMarkDown": "Suffix for the RegEx result string.",
"groupName": "advanced"
},
{
"name": "FailIfNoMatchFound",
"type": "boolean",
"label": "Fail if no target match found",
"defaultValue": "false",
"required": false,
"helpMarkDown": "Fail the build if no match is found for the replace RegEx in the target file(s).",
"groupName": "advanced"
}
],
"execution": {
"PowerShell3": {
"target": "VersionAssembly.ps1"
}
}
:
VersionAssembly.ps1
答案 0 :(得分:5)
显然我没有足够密切关注......我错过了this page上的警告:
警告字
可以对任务进行版本控制,将此用于您的优势。所有构建定义都使用特定任务的最新可用版本,您无法从Web界面更改此行为,因此始终假设正在使用最新版本。
如果在更新任务时未更改任务的版本号,则之前使用过您的任务的构建代理将不会下载较新版本,因为版本号仍然相同。这意味着如果您更改任务的行为,则应始终更新版本号!
一旦我完全理顺了,一切都运转良好。
答案 1 :(得分:3)
可能接受参数部分输入的示例已过时。您现在需要使用PowerShell脚本中的Vsts-task-lib命令来获取输入参数。
[CmdletBinding()]
param()
$myParam = Get-VstsInput -Name myParam -Require