Skip to content

NuGet package push fails with error: NuGet.Temporary.Package "Invalid Package: failed metadata extraction"

Summary

Fails when pushing NuGet packages to the registry. nuget push command looks succesful at the client, but the uploaded package looks broken on the UI with error message NuGet.Temporary.Package "Invalid Package: failed metadata extraction".

Steps to reproduce

  • We are using a self-hosted gitlab installation with AWS s3 bucket. In our case, the problem started with version 13.12.8-ee.0, we migrated to version 14.2.4-ee.0 and the problem remains. Sometimes it works and the next time it doesn't.
  • We tested it in two different ways:
  1. We performed the following command on Windows 10 CLI after installed NuGet CLI:
nuget source Add -Name <source_name> -Source "https://gitlab.example.com/api/v4/projects/<your_project_id>/packages/nuget/index.json" -UserName <gitlab_username or deploy_token_username> -Password <gitlab_personal_access_token or deploy_token>

nuget push <package_file> -Source <source_name>

The CLI log look like this: WIndNuget

And the Gitlab Package Registry web Ui: WIndNuget2

  1. We also tested it through the gitlab-Ci: Our .gitlab-ci.yml file look like follow:
stages:
    - build
    - deploy

image: mcr.microsoft.com/dotnet/sdk:5.0

build-job:
    stage: build
    tags:
        - asprunner-test
    script:
        - dotnet build
    cache:
        key: compiled-code-cache-$CI_COMMIT_REF_SLUG
        untracked: true

deploy-job:
    stage: deploy
    tags:
        - asprunner-test
    script:
        - dotnet build -c Release
        - dotnet nuget add source "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/nuget/index.json" --name gitlab --username gitlab-ci-token --password $CI_JOB_TOKEN --store-password-in-clear-text
        - for n in `find . -name *.nupkg |grep Release`; do dotnet nuget push --source gitlab $n; done
    cache:
        key: compiled-code-cache-$CI_COMMIT_REF_SLUG
        untracked: true
    only:
        - tags

The gitlab-ci jobs log look like this: WIndNuget3

And the Gitlab Package Registry web Ui: WIndNuget4

  1. Our gitlab.rb file is configured like follows:
###### Enabling the Packages feature#
gitlab_rails['packages_enabled'] = true
gitlab_rails['packages_object_store_enabled'] = true
gitlab_rails['packages_object_store_remote_directory'] = "Our_bucket_name"
gitlab_rails['packages_object_store_direct_upload'] = false      
gitlab_rails['packages_object_store_background_upload'] = true     
gitlab_rails['lfs_object_store_direct_upload'] = true
gitlab_rails['packages_object_store_proxy_download'] = false 
gitlab_rails['packages_object_store_connection'] = {
   ## The below options configure an S3 compatible host instead of AWS
  'provider' => 'AWS',
  'region' => 'xxxxx',
  'aws_access_key_id' => 'xxxxx',
  'aws_secret_access_key' => 'Xxxx',
  'host' => 's3.xxx.de',
  'endpoint' => 'https://s3.xxx.de',
  'path_style' => true
}