powershell - TFS 2015.3定制构建步骤未将变量发送到脚本

标签 powershell tfs tfsbuild tfs-2015

我一直严格遵循发现hereherehere的设计指南,但是我不断收到此PowerShell错误:

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
)

最佳答案

显然,我的关注程度不够……我错过了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!


一旦我弄清了一切,一切就很好了。

关于powershell - TFS 2015.3定制构建步骤未将变量发送到脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38939210/

相关文章:

mysql - Powershell 调用-MySQL

tfs - 删除 TFS 项目而不使用资源

powershell - TFS 发布管理工件变量不可用

tfs - 没有为项目TFS2012设置OutputPath属性

.net - TFS 构建 : include branch name in "build number" field of assemblies

git - Powershell 动态 <tab> 补全

c# - PowerShell:.NET 程序集的 Import-Module 或 Add-Type?

用于将 VolumeID 与 DriveLetter 进行比较的 Powershell 脚本

c# - 如何从排除的更改中删除项目

asp.net-core - 使用托管生成代理从 Visual Studio Team Services 发布 ASP.NET 5 RC1 项目时出错