[英]Changin text in a file using RegexReplaceInFilesWithEncoding gives an error - FAKE F#MAKE
I am trying to change text in a file in FAKE code using a predefined function RegexReplaceInFilesWithEncoding
. 我正在尝试使用预定义的函数RegexReplaceInFilesWithEncoding
更改FAKE代码中的文件中的文本。 But it is throwing an error .... ie The value is not a function and can not be applied
. 但它抛出一个错误....即The value is not a function and can not be applied
。 below is my code : 下面是我的代码:
Note: version_no is dynamic , but for the time being I am using it as static. 注意:version_no是动态的,但暂时我将它用作静态。
#r "./packages/FAKE/tools/FakeLib.dll"
open Fake
let version_no = "0.65"
Target "ChangeText" (fun _ ->
!! "D:/test/TestFile.txt"
|> RegexReplaceInFilesWithEncoding @"admintool: XYZ.XYZ.XYZ_0.[0-9][09]"
@"admintool: XYZ.XYZ.XYZ_"+version_no
System.Text.Encoding.UTF8)
"ChangeText"
RunTargetOrDefault "ChangeText"
In F#, function application has the highest precedence of all operations. 在F#中,函数应用程序具有所有操作的最高优先级。 That includes the "plus" operator. 这包括“加”运算符。
This means that code like this: 这意味着代码如下:
f x+5
Will be interpreted like this: 将被解释为这样:
(f x) + 5
The application of f
to x
comes first, because it has the highest precedence, and the + 5
part comes after. 首先应用f
到x
,因为它具有最高的优先级,而+ 5
部分则在之后。
To fix this, just add parentheses around the operation: 要解决此问题,只需在操作周围添加括号:
f (x+5)
Or, applying this to your case: 或者,将此应用于您的案例:
Target "ChangeText" (fun _ ->
!! "D:/test/TestFile.txt"
|> RegexReplaceInFilesWithEncoding @"admintool: XYZ.XYZ.XYZ_0.[0-9][09]"
(@"admintool: XYZ.XYZ.XYZ_"+version_no)
System.Text.Encoding.UTF8)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.