File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,13 @@ Trace-VstsEnteringInvocation $MyInvocation
16
16
try {
17
17
Import-VstsLocStrings " $PSScriptRoot \task.json"
18
18
19
+ # Check Powershell Version
20
+ if ($PSVersionTable.PSCompatibleVersions -notcontains ' 4.0' )
21
+ {
22
+ Write-VstsTaskError " This task requires Powershell 4.0 or later"
23
+ exit ;
24
+ }
25
+
19
26
$inputSearchPattern = (Get-VstsInput - Name InputSearchPattern - Require)
20
27
$useUTF8 = Get-VstsInput - Name UseUTF8 - AsBool - Require
21
28
$useRaw = Get-VstsInput - Name UseRAW - AsBool - Require
47
54
Write-Host " Replacing $findRegex with $replaceRegex ($ext )"
48
55
49
56
foreach ($path in $inputPaths ) {
50
- $setContentParams = @ { Path = $path ; NoNewLine = $true }
57
+ $setContentParams = @ { Path = $path ; }
58
+
59
+ # NoNewline is only available in Powershell >= 5.0
60
+ if ($PSVersionTable.PSCompatibleVersions -contains ' 5.0' )
61
+ {
62
+ $setContentParams.Add (" NoNewline" , $true );
63
+ }
64
+
51
65
$getContentParams = @ { Path = $path }
52
66
53
67
Write-Host " ...in file $path "
You can’t perform that action at this time.
0 commit comments