Commit bfc94a6c authored by David McFarland's avatar David McFarland
Browse files

nuget-package-hook: add helper to create .nupkg.metadata

This also adds an empty contentHash to the metadata, which is required
to fix a parsing error on sdk 11+.
parent 998719b9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ lib.makeOverridable (
        dir=$out/share/nuget/packages/${lib.toLower pname}/${lib.toLower version}
        mkdir -p $dir
        cp -r . $dir
        echo {} > "$dir"/.nupkg.metadata
        createNupkgMetadata "$dir"

        runHook postInstall
      '';
+8 −1
Original line number Diff line number Diff line
# shellcheck shell=bash disable=SC2154

createNupkgMetadata() {
  # since sdk 11, contentHash is required to avoid:
  # NuGet.targets(198,5): error : Error parsing nupkg metadata file [...]/.nupkg.metadata : \
  # JSON deserialization for type 'NuGet.Packaging.NupkgMetadataFile' was missing required properties including: 'contentHash'.
  echo '{ "contentHash": "" }' > "$1"/.nupkg.metadata
}

unpackNupkg() {
    local -r nupkg="$1" unpacked="$2"
    local nuspec nuspec_l
@@ -14,7 +21,7 @@ unpackNupkg() {
        mv "$nuspec" "$nuspec".tmp
        mv "$nuspec".tmp "$nuspec_l"
    fi
    echo {} > .nupkg.metadata
    createNupkgMetadata .
    cd - >/dev/null
}

+1 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ let
          for dir in tools runtimes/*/native; do
            [[ ! -d "$dir" ]] || chmod -R +x "$dir"
          done
          echo {} > .nupkg.metadata
          createNupkgMetadata .
        )

        popd