How to correctly publish with dotnet cli to MyGet with SymbolSource (nupkg + snupkg unified publishing)

517 Views Asked by At

I've tried every imaginable combination of the example commands in the official docs, but these are all using nuget.exe.

The following nuget issue states that publishing with the dotnet cli to the offical nuget.org v3 endpoint https://api.nuget.org/v3/index.json works.


When publishing to the MyGet v3 endpoint with

dotnet nuget push <package-name>.nupkg --api-key <write-api-key> --source https://www.myget.org/F/<some-site>/api/v3/index.json

the .nupkg file is published but the .snupkg one is not.


When publishing the .snupkg file only to the MyGet v3 endpoint with

dotnet nuget push <package-name>.snupkg --api-key <write-api-key> --source https://www.myget.org/F/<some-site>/api/v3/index.json

the result is:

error: Unable to load the service index for source https://www.myget.org/F/<some-site>/api/v3/index.json.
error:   Response status code does not indicate success: 401 (Unauthorized).

Also tried with:

dotnet nuget push <package-name>.snupkg --api-key <write-api-key> --source https://www.myget.org/F/<some-site>/api/v3/index.json --no-service-endpoint

.. with the same result

Manually uploading the .snupkg file via the WebUI works.

I'm using:

.NET Core SDK (reflecting any global.json):
 Version:   3.1.201
 Commit:    b1768b4ae7

Any hints?

This unanswered question seems somewhat linked

1

There are 1 best solutions below

0
Damjan On

I got the same problem during pushing multiple nuget packages. The solution was to push to the V2 API of MyGet, but it only worked if the packages were in the same directory and I used the directory in the command instead of the package name. Ex.

dotnet nuget push $(Build.SourcesDirectory)/packages/ --source https://www.myget.org/F/<feedname>/api/v2 -k <token>

DISCLAIMER: I'm doing this from TFS CI/CD build task.