openalm / Extension-UtilitiesPack

Release Management utility tasks
Other
34 stars 38 forks source link

Incorrect file being used for tempFile contents in tokenize.ps1 #28

Closed MarcelMichau closed 8 years ago

MarcelMichau commented 8 years ago

I was having an issue where the destination file wasn't being tokenized at all, and looking at the tokenize.ps1 script I noticed that the script used the destination file's contents to iterate over, searching for matches. However, it is the source file which contains the tokens. Changing the Copy-Item step to Copy-Item -Force $SourcePath $tempFile allowed the destination file to be transformed correctly.

If the source file contains the tokens, i.e "__VariableName__", then it would make sense to copy the contents of the source file into the temp file, instead of the destination file, as done at Copy-Item -Force $DestinationPath $tempFile.

Am I perhaps not using the task as intended? Any help would be appreciated.

uwe-baumann commented 8 years ago

Hello Marcel, I ran into the same problem, and without having read your post, came to the same conclusion by debugging the Tokenize.ps1 script. I exactly changed the same line, and it works now. IMHO this is a major bug. Specifying the Destination file will not work in any case.

harshil93 commented 8 years ago

If you go over the task documentation, it is clearly mentioned that the tokens are expected in the source file. If destination file is specified, the source file is not modified instead a destination file is created which has source file with tokens replaced.

For eg. you have a file config.example.conf which you specify as a source file and has tokens. You want a config.conf file created which has tokens replaced, then you will specify config.conf as destination file.

Let me know if any help is required. Otherwise I will close the issue.

uwe-baumann commented 8 years ago

Hello Harshil, as Marcel and I said, we used the Tokenzier exactly like you described it, and we also read the docs, but it simply does not work. If a destination file and source file are specified, nothing is replaced in the destination file. This is obvious form the source code that gets downloaded into the Agent folder which imho contains a bug - also see the comment by Marcel and me above. Please confirm that the published version of Tokenizer behaves like you claim it does. Thanks! Uwe

harshil93 commented 8 years ago

@uwe-bauman I went through the code and got your point. You and @MarcelMichau are right.

The task isn't working as intended. The intended fix is to replace line Copy-Item -Force $DestinationPath $tempFile with Copy-Item -Force $SourcePath $tempFile

If anyone of you is willing to create a pull request, then do so right away. I will merge it asap. Otherwise I will fix it later in the day.

anangaur commented 8 years ago

This has been now fixed with https://github.com/openalm/Extension-UtilitiesPack/commit/55a0ec939efb448d0bc07bdb57bab5f275e55aa3