【发布时间】:2016-12-20 17:19:39
【问题描述】:
我已密切遵循 here、here 和 here 的设计指南,但我不断收到此 PowerShell 错误:
由于缺少一个或多个强制参数,无法处理命令:SourcePath FilePattern BuildRegex。
相关配置数据如下。
我已经检查并再次检查以确保变量存在于我的task.json 文件中。我还查看了其他工作任务的配置(例如 VSBuild),变量声明和 PowerShell 执行语法没有显着差异。
这里可能出了什么问题?这是一个非常简单的架构——没有什么可破坏的。但很明显,某些事情已经做到了这一点。
来自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:
[CmdletBinding()]
param(
[string][Parameter(Mandatory=$True)][ValidateNotNullOrEmpty()] $SourcePath,
[string][Parameter(Mandatory=$True)][ValidateNotNullOrEmpty()] $FilePattern,
[string][Parameter(Mandatory=$True)][ValidateNotNullOrEmpty()] $BuildRegex,
[string]$BuildRegexIndex,
[string]$ReplaceRegex,
[string]$ReplacePrefix,
[string]$ReplaceSuffix,
[string]$FailIfNoMatchFound,
[string]$BuildNumber = $ENV:BUILD_BUILDNUMBER
)
【问题讨论】:
-
@ScottLangham:你对这个版本做了什么改动?请参阅Task versions 上的特定文档,其中指出:“当发布新的次要版本(例如,1.2 到 1.3)时,您的构建或发布将自动使用新版本。但是,如果新的主要版本已发布(例如 2.0),您的构建或发布将继续使用您指定的主要版本,直到您编辑定义并手动更改为新的主要版本。"
-
我尝试了版本中的次要和补丁字段。
-
@ScottLangham — 我暂时将自定义任务放在一边,但如果我继续努力并找到解决方法,我会将其发送给您。
-
@InteXX 非常感谢您的帮助,不过我现在很好.. 我发布的答案对我有用。
-
@ScottLangham — 这看起来像是一种新语法。我必须牢记这一点。
标签: powershell tfs tfsbuild tfs-2015