F# FAKE - 无法获取 FAKE 以合并 .nuspec 文件中的占位符参数

F# FAKE - Unable to get FAKE to merge placeholder arguments in .nuspec file

我有以下带有此代码的 FAKE 文件,用于将 NuGet 包打包到一个解决方案中:https://github.com/Aaronontheweb/akka-monitoring/blob/master/build.fsx#L143

for nuspec in !! "src/**/*.nuspec" do
        printfn "Creating nuget packages for %s" nuspec

        CleanDir workingDir

        let project = Path.GetFileNameWithoutExtension nuspec 
        let projectDir = Path.GetDirectoryName nuspec
        let projectFile = (!! (projectDir @@ project + ".*sproj")) |> Seq.head
        let releaseDir = projectDir @@ @"bin\Release"
        let packages = projectDir @@ "packages.config"        
        let packageDependencies = if (fileExists packages) then (getDependencies packages) else []
        let dependencies = packageDependencies @ getAkkaDependency project
        let releaseVersion = release.NugetVersion
        let desc = description project

        let pack outputDir  =
            NuGetHelper.NuGet
                (fun p ->
                    { p with
                        Description = desc
                        Authors = authors
                        Copyright = copyright
                        Project =  project
                        Properties = ["Configuration", "Release"]
                        ReleaseNotes = release.Notes |> String.concat "\n"
                        Version = releaseVersion
                        Tags = tags |> String.concat " "
                        OutputPath = outputDir
                        WorkingDir = workingDir
                        Dependencies = dependencies })
                nuspec

        // Copy dll, pdb and xml to libdir = workingDir/lib/net45/
        ensureDirectory libDir
        !! (releaseDir @@ project + ".dll")
        ++ (releaseDir @@ project + ".pdb")
        ++ (releaseDir @@ project + ".xml")
        ++ (releaseDir @@ project + ".ExternalAnnotations.xml")
        |> CopyFiles libDir

        // Copy all src-files (.cs and .fs files) to workingDir/src
        let nugetSrcDir = workingDir @@ @"src/"
        // CreateDir nugetSrcDir

        let isCs = hasExt ".cs"
        let isFs = hasExt ".fs"
        let isAssemblyInfo f = (filename f).Contains("AssemblyInfo")
        let isSrc f = (isCs f || isFs f) && not (isAssemblyInfo f) 
        CopyDir nugetSrcDir projectDir isSrc

        //Remove workingDir/src/obj and workingDir/src/bin
        removeDir (nugetSrcDir @@ "obj")
        removeDir (nugetSrcDir @@ "bin")

        // Create both normal nuget package and symbols nuget package. 
        // Uses the files we copied to workingDir and outputs to nugetdir
        printfn "nugetDir %s" nugetDir
        pack nugetDir

以及以下 .nuspec 文件 https://github.com/Aaronontheweb/akka-monitoring/blob/master/src/Akka.Monitoring/Akka.Monitoring.Nuspec

<?xml version="1.0" encoding="utf-8"?>
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
    <id>@project@</id>
    <title>@project@@title@</title>
    <version>@build.number@</version>
    <authors>@authors@</authors>
    <owners>@authors@</owners>
    <licenseUrl>https://github.com/Aaronontheweb/akka-monitoring/blob/master/LICENSE</licenseUrl>
    <projectUrl>https://github.com/Aaronontheweb/akka-monitoring</projectUrl>
    <iconUrl>https://raw.githubusercontent.com/akkadotnet/akka.net/gh-pages/images/icon-32x32.png</iconUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>@description@</description>
    <releaseNotes>@releaseNotes@</releaseNotes>
    <copyright>@copyright@</copyright>
    <tags>@tags@</tags>
    @dependencies@
  </metadata>
</package>

自从升级到最新版本的 FAKE 和 NuGet 后,出现以下错误:

Time Elapsed 00:00:01.03
Finished Target: Build
Starting Target: CopyOutput (==> Build)
Creating D:\Repositories\olympus\akkadotnet-performance-counters\bin\Akka.Monitoring
Creating D:\Repositories\olympus\akkadotnet-performance-counters\bin\Akka.Monitoring.StatsD
Finished Target: CopyOutput
Starting Target: CleanNuget
Creating D:\Repositories\olympus\akkadotnet-performance-counters\bin\nuget
Finished Target: CleanNuget
Starting Target: BuildRelease (==> CopyOutput, CleanNuget)
Finished Target: BuildRelease
Starting Target: Nuget (==> BuildRelease)
Creating nuget packages for D:\Repositories\olympus\akkadotnet-performance-counters\src\Akka.Monitoring\Akka.Monitoring.
Nuspec
Creating D:\Repositories\olympus\akkadotnet-performance-counters\bin\build
Creating D:\Repositories\olympus\akkadotnet-performance-counters\bin\build\src\
Deleting D:\Repositories\olympus\akkadotnet-performance-counters\bin\build\src\obj
D:\Repositories\olympus\akkadotnet-performance-counters\bin\build\src\bin does not exist.
nugetDir bin\nuget
D:\Repositories\olympus\akkadotnet-performance-counters\.nuget\nuget.exe pack -Symbols -Version 0.3.3 -OutputDirectory "
D:\Repositories\olympus\akkadotnet-performance-counters\bin\nuget" "D:\Repositories\olympus\akkadotnet-performance-count
ers\src\Akka.Monitoring\Akka.Monitoring.Nuspec"    -Properties Configuration="Release"
Running build failed.
Error:
System.Exception: Error during NuGet package creation. D:\Repositories\olympus\akkadotnet-performance-counters\.nuget\nu
get.exe pack -Symbols -Version 0.3.3 -OutputDirectory "D:\Repositories\olympus\akkadotnet-performance-counters\bin\nuget
" "D:\Repositories\olympus\akkadotnet-performance-counters\src\Akka.Monitoring\Akka.Monitoring.Nuspec"    -Properties Co
nfiguration="Release"
The element 'metadata' in namespace 'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd' cannot contain text. Lis
t of possible elements expected: 'references, summary, frameworkAssemblies, developmentDependency, language, dependencie
s' in namespace 'http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd'.
   at Fake.NuGetHelper.NuGet(FSharpFunc`2 setParams, String nuspecOrProjectFile) in C:\code\fake\src\app\FakeLib\NuGet\N
ugetHelper.fs:line 406
   at FSI_0001.Build.createNugetPackages[a](a _arg1) in D:\Repositories\olympus\akkadotnet-performance-counters\build.fs
x:line 185
   at FSI_0001.Build.clo@228-8.Invoke(Unit _arg1) in D:\Repositories\olympus\akkadotnet-performance-counters\build.fsx:l
ine 229
   at Fake.TargetHelper.runSingleTarget(TargetTemplate`1 target) in C:\code\fake\src\app\FakeLib\TargetHelper.fs:line 41
1

TL;DR;它似乎是 FAKE 实际上不再在 .nuspec 文件上进行占位符替换,而 NuGet 正在获取文件的文字内容,而不是具有提供的编程值的合并文件。

我做错了什么?

FAKE 正在寻找“.nuspec”文件,但您的文件名为“.Nuspec”。 https://github.com/fsharp/FAKE/commit/15dc617624ac514268b8e9a4bd80dd1203e61054 应该修复它。发布中。

下次你可能想开一个 FAKE issue。然后我会更快地修复它。