我有一个示例脚本,我无法理解该文件中的一段代码,这里是代码:
Target "Package1" (fun _ ->
NuGet (fun p ->
{ p with
OutputPath = DeployDir
ReleaseNotes = ReleaseNote
WorkingDir = BuildDir
Publish = false
Version = PackageVersion
Files = [
(@"*.dll", Some "lib", None)
(@"*.pdb", Some "lib", None)
]
})
"src/Client/Project.Client.nuspec"
)
此目标的订单是最后一次。那么使用这个目标的目的是什么呢?什么是src/Project.Client/Project.Client.nuspec
的最后一行。如果有人能详细解释这一点,那将非常有用。
答案 0 :(得分:2)
看看缩进。 "src/Client/Project.Client.nuspec"
字符串缩进进一步而不是NuGet
,因为它是NuGet
函数的参数之一(需要两个参数)。以下是编写此目标的另一种方式,具有相同的效果但不同的缩进:
Target "Package1" (fun _ ->
NuGet
(fun p -> { p with OutputPath = DeployDir
ReleaseNotes = ReleaseNote
WorkingDir = BuildDir
Publish = false
Version = PackageVersion
Files = [
(@"*.dll", Some "lib", None)
(@"*.pdb", Some "lib", None)
]
}
)
"src/Client/Project.Client.nuspec"
)
或者让它更清晰:
let nuGetParameterFunction =
(fun p -> { p with OutputPath = DeployDir
ReleaseNotes = ReleaseNote
WorkingDir = BuildDir
Publish = false
Version = PackageVersion
Files = [
(@"*.dll", Some "lib", None)
(@"*.pdb", Some "lib", None)
]
}
)
Target "Package1" (fun _ ->
NuGet nuGetParameterFunction "src/Client/Project.Client.nuspec"
)
这两个片段与您询问的片段完全相同。只是在这些中,NuGet
函数需要两个参数,这一点更为明显。
答案 1 :(得分:1)
如果查看NuGetHelper的文档,NuGet函数的签名为setParams:(NuGetParams -> NuGetParams) -> nuspecOrProjectFile:string -> unit
。
这意味着该函数采用setParams
函数,该函数从默认的NuGetParams
集创建一组新的NuGetParams
。以及写入生成的nuspec
文件的路径。
在您的示例中,setParams
函数定义为(我的评论):
fun p ->
{ p with // p is the default NuGetParams
OutputPath = DeployDir // set OutputPath from FAKE properties
ReleaseNotes = ReleaseNote // Set ReleaseNotes to ReleaseNote (from FAKE)
WorkingDir = BuildDir // Set WorkingDir from FAKE properties
Publish = false // Do not publish to NuGet.org
Version = PackageVersion // Set Version number
Files = [ // Put these files from WorkingDir into the package
(@"*.dll", Some "lib", None)
(@"*.pdb", Some "lib", None)
]
})
Target "Package1"
是最后一个目标的原因是确保setParams
值的所有值都有效。