2016-08-14 66 views
8

我紧紧跟随的设计指导中发现hereherehere,但我不断收到此错误的PowerShell:TFS 2015.3自定义生成步骤不发送变量脚本

Cannot process command because of one or more missing mandatory parameters: 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 
) 
+0

@ScottLangham:你碰到了哪个版本?请参阅[任务版本](https://docs.microsoft.com/en-us/vsts/build-release/concepts/process/tasks#task-versions)中的特定文档,其中声明:“*当新的未成年人版本发布时(例如1.2到1.3),你的构建版本或发布版本将自动使用新版本,但是如果发布了新的主版本(例如2.0),你的构建版本或版本将继续使用你的主版本指定直到您编辑定义并手动更改为新的主要版本。*“ – eggyal

+0

我在版本中尝试了次要和补丁字段。 –

+0

@ScottLangham - 我已经将自定义任务设置为暂时的一方,但是如果我继续努力并为此找到解决方法,我会将其发送给您。 – InteXX

回答

5

显然我没有密切关注不够......我错过this page警告:

Words of warning

Tasks can be versioned, use this to your advantage. All build definitions use the latest available version of a specific task, you can’t change this behavior from the web interface, so always assume the latest version is being used.

If you don’t change the version number of your task when updating it, the build agents that have previously used your task will not download the newer version because the version number is still the same. This means that if you change the behavior of your task, you should always update the version number!

一旦我把这一切理顺了,一切运转良好。

2

可能在param部分接受输入的示例已过时。看来您现在需要使用PowerShell脚本中的Vsts-task-lib命令来获取输入参数。

[CmdletBinding()] 
param() 

$myParam = Get-VstsInput -Name myParam -Require 
相关问题