Skip to content
This repository has been archived by the owner on Mar 10, 2024. It is now read-only.

Feature Request - rename files after replace of token #114

Closed
ckrueger1979 opened this issue Aug 15, 2019 · 4 comments
Closed

Feature Request - rename files after replace of token #114

ckrueger1979 opened this issue Aug 15, 2019 · 4 comments

Comments

@ckrueger1979
Copy link

Hi,

I've a proposal, add an option for automatically rename the file after replacing the token.

We are doing the following, in our source code repo there are 2 files checked in:
server.config
server.config.token

The server.config contains the values for the local development (contains no tokens).
The server.config.token file contains tokens for the different stages.
After the tokens are replaced the server.config.token file is "renamed" to server.config.
(it's no rename but a replace)

We are running this file after tokenization but it would be nice if that's an option directly in the extension.

-----RenameTokenFiles.ps1------
param (
[Parameter(
   Position=0,
   Mandatory=$true,
   ValueFromPipeline=$false
)][string]$path
)

$files=get-childitem $path\*.token -recurse
foreach ($file in $files)
{
  copy $file.Fullname ($file.Fullname -replace '\.token$','') -force -verbose
}
-----RenameTokenFiles.ps1------
@jonmartin136
Copy link

If your .config are XML based then why not have tokens in XDT transform files? You'd use the Replace Token task to update the XDT transform files and then use the XDT Transform task (https://github.com/qetza/vsts-xdttransform-task) to update your .config files. Loads of ways to do this as well: single generic transform files and/or env-specific transform file for when an env is needing further changes compared to others.

@qetza
Copy link
Owner

qetza commented Aug 16, 2019

Hi @ckruegerkpmg,

As @jonmartin136 said if you are using xml files you could use the xdt transform task to inject tokens in your server.config and then replace token in this file.

But as this is not the first time i hear this request i will add it to the backlog so that it will be possible to define an output file using the syntax:
folder\server.config.token => folder\server.config

or with wildcard:
**\*.config.token => *.config (the * in the output will be replaced by the value of the * in the input)

@qetza
Copy link
Owner

qetza commented Nov 24, 2019

Hi,
I'm pleased to announce that this feature was just released in v3.3.0 :)

@ckrueger1979
Copy link
Author

Thank you very much!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants