Visual Studio Team Services版本定义-重命名文件的任务?

问题描述:

如何在Visual Studio Team Services中的发布定义中重命名文件?是否有内置任务或市场任务可用,否则如何实现?

How can I rename a file in a release definition in Visual Studio Team services? Is there a built-in or marketplace task available or otherwise, how can this be achieved?

答案:

  1. 从市场添加内联PowerShell"任务
  2. 在文本区域中输入以下PowerShell代码

  1. Add the "Inline PowerShell" task from the marketplace
  2. Enter the following PowerShell code in the text area

Param
(
 [string]$pathToFileToRename
)

Rename-Item $pathToFileToRename NewName.txt

  • 例如,在参数文本框中输入任何必需的参数(您可以使用环境变量).

  • Enter any required arguments in the arguments text box (you can use environment variables), for example.

    pathToFileToRename $(System.DefaultWorkingDirectory)/somepath/CurrentName.txt
    

  • 使用运行命令行"任务或在PowerShell脚本中执行该任务,然后在您的发行版中调用该脚本.

    Use the Run Command Line task or do it in a PowerShell script and invoke the script in your release.