Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All RegEx Find & Replace tasks in pipelines fail. The reason is that "A parameter cannot be found that matches parameter name 'NoNewLine'." #27

Closed
Flow013 opened this issue Dec 13, 2019 · 23 comments

Comments

@Flow013
Copy link

Flow013 commented Dec 13, 2019

Image removed

@diegofrafer
Copy link

diegofrafer commented Dec 13, 2019

I have the same issue.

image

@Rahkola
Copy link

Rahkola commented Dec 13, 2019

I can confirm our dev team experiencing the same issue. For now the only workaround seemed to be to use alternative task for our search & replace needs.
Affected task version: 3.3.9

image

@magnusbakken
Copy link

Since many people are getting hit by this, myself included, I'll take this opportunity to ask if there's a way to freeze the task version to the one before this bug? I can only choose 3.* in the dropdown in the UI. Would I be able to do set a specific version if I were using YAML pipelines? I happen to be using this task inside a Task Group, which I understand comes with some limitations.

@Flow013
Copy link
Author

Flow013 commented Dec 13, 2019

I found an analogue of this library in the marketplace, and replaced them in some places. But updating all pipelines to a new library is difficult. It’s easier to wait for the update.

@magnusbakken
Copy link

I replaced it with some pretty basic PowerShell:

(Get-Content $file) -replace $regex, $replacement | Set-Content $file

YMMV depending on how advanced your use case is.

@bparkhurst
Copy link

I am also getting this error now all of a sudden. Does anyone know the cause of why this all of a sudden stopped working?

@pauloeduardorocha
Copy link

Same problem here! Version updated 4 hours ago and my build stopped working :(

@bparkhurst
Copy link

What do we think about getting this fixed? Is everyone moving away from this or do we think the author will help us fix it quickly? I need to make a decision and have no developers to lend to this repo at this time. Thoughts from others in this thread?

@diegofrafer
Copy link

I replace the task with PowerShell task:

$configFiles = Get-ChildItem $(System.DefaultWorkingDirectory)\myPath**\config. env.json -rec
foreach ($file in $configFiles)
{
(Get-Content $file.PSPath) |
Foreach-Object { $_ -replace "/url/", "/$(BackendUrl)/" } |
Set-Content $file.PSPath
}

@Balaji-FSI
Copy link

Even in our continuous integration process, it is breaking our build pipeline. I am wondering whether the Author knew about this? is he working on it? we don't have any clue? We can find a work around, However it will be easier to reuse the extension component as it was tested and working before.

@mrmojo666
Copy link

same issue here, thank you for any update.

@mgeramb
Copy link

mgeramb commented Dec 16, 2019

Same error here

@bparkhurst
Copy link

I just replaced the plugin with a powershell script that does the same thing. Took me about 15 minutes.

@knom
Copy link
Owner

knom commented Dec 16, 2019

Thanks folks for raising this!
A new version was published to the marketplace that had a bug.. unfortunately it seems you cannot roll-back - only move forward.

I'm looking for a new way to improve testing (maybe a BETA test ring), so that will not happen again..

As for the fix - working on it today / tomorrow and posting here, when the new version is published!
Really sorry!

Meanwhile the script posted up there looks good.

@wupaz
Copy link

wupaz commented Dec 16, 2019

It's quite strange, I use same task on 2 servers , my Windows 2012 didn't work but on my W2019 it work!

@lumistu
Copy link

lumistu commented Dec 17, 2019

This powershell script does the trick. Lifted directly from a blog post but can no longer find the source, so credit and thanks to that poster whoever you are! Use the preview flag to check whether the script find the appropriate files without actually changing them.

$find = "tofind"
$replace = "replacewith"
$match = ".js" , ".ts"
$preview = $false

foreach ($sc in dir -recurse -include $match | where { test-path $.fullname -pathtype leaf} ) {
select-string -path $sc -pattern $find
if (!$preview) {
(get-content $sc) | foreach-object { $
-replace $find, $replace } | set-content $sc
}
}

@knom
Copy link
Owner

knom commented Dec 17, 2019

Can people post the PLATFORM where it doesn't work?
E.g. Windows Server 2012 (@wupaz), Windows Container Pipeline in Azure DevOps, etc..?

Especially the Powershell Version?
You can find it by running
Write-Host $PSVersionTable.PSVersion
in a Powershell script task.

@knom
Copy link
Owner

knom commented Dec 17, 2019

I have now published version 3.3.10, which should fix the bug!
Let me know, if you see the same!

Here is what happened (as usually a combination of mistakes)...

  • In Prevent adding a new line at the end of the modified file #26 a PR was made to include -NoNewline for Set-Content
  • The PR was approved and released in 3.3.8
  • Apparently the RELEASE process was broken and didn't really include the -NoNewline flag
  • I worked on the BUILD and RELEASE PIPELINE recently - and released 3.3.9 with the new pipeline (3.3.9 had NO CHANGES in SOURCE - only in METADATA)
  • BUT: Because for 3.3.8 the BUILD was broken - NOW in 3.3.9 the -NoNewline change came through
  • Turns out that -NoNewline isn't supported in Powershell < 5 - which I suspect people seeing the error are running (e.g. Windows Server 2012 by default)
  • I'm now only using -NoNewline if you have Powershell 5+

Please confirm if people seeing the issue were running Powershell < 5.
(which would confirm my suspicion!)

Again as usual.. a mix of things.. Apologies for that!
Let me know if the new version 3.3.10 works for you.

And if not, please supply your Powershell Version as well!

@knom knom closed this as completed Dec 17, 2019
@wupaz
Copy link

wupaz commented Dec 17, 2019

For your information, my
w2012R2 v4.0
w2019 v5.1.17763.1

@knom
Copy link
Owner

knom commented Dec 17, 2019

Does it work now?

@wupaz
Copy link

wupaz commented Dec 17, 2019

Yep! it work, thanks

@mattanknol
Copy link

This change broke the task for us, we use it on a server which only has PS3.0 installed. Because you added the PS4.0 check it broke (it worked fine before). Unfortunately it's rather difficult for us to upgrade the PowerShell version on this server.
Seeing as it worked perfectly fine before with PS3.0, can you lower the check for the PowerShell version to 3.0 instead of 4.0?

@knom
Copy link
Owner

knom commented Dec 19, 2019

Let's discuss on the other thread..

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

No branches or pull requests