13

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?

Answer:

  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
    
  3. Enter any required arguments in the arguments text box (you can use environment variables), for example.

    pathToFileToRename $(System.DefaultWorkingDirectory)/somepath/CurrentName.txt
    
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Dan Cook
  • 1,935
  • 7
  • 26
  • 50
  • 3
    I think part 3 of the answer should have the parameter names prefixed with a hyphen. So it should be `-pathToFileToRename $(...` etc. – oatsoda Nov 21 '17 at 13:51

1 Answers1

11

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

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120