Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: dotnet nuget push symbols not working as expected #11871

Open
jmecosta opened this issue Jun 13, 2022 · 22 comments
Open

[Bug]: dotnet nuget push symbols not working as expected #11871

jmecosta opened this issue Jun 13, 2022 · 22 comments
Assignees
Labels
Area:Symbols Category:Quality Week Issues that should be considered for quality week Functionality:Push Priority:2 Issues for the current backlog. Product:dotnet.exe SeQuality Type:Bug

Comments

@jmecosta
Copy link

NuGet Product Used

dotnet.exe

Product Version

6.0.300

Worked before?

No response

Impact

No response

Repro Steps & Context

Hi,

Ive raised a ticket on our nuget server provider (proget) and they said that "dotnet nuget push" is a "bit" buggy with when using "*" argument... Wanted to report this buggy behaviour here so can help them also clarify a bit the behaviour:

dotnet nuget push --source http://ts-nuget.teklaad.tekla.com/nuget/ts-nuget/v3/index.json *.nupkg --symbol-source http://ts-nuget.teklaad.tekla.com/nuget/ts-nuget-symbols/v3/index.json --api-key KEY --symbol-api-key OTHERKEY --skip-duplicate

this pushes only the .nupkg
Pushing TeklaFusion.4.0.4.nupkg to 'http://ts-nuget.teklaad.tekla.com/nuget/ts-nuget/package'...
PUT http://ts-nuget.teklaad.tekla.com/nuget/ts-nuget/package/
Created http://ts-nuget.teklaad.tekla.com/nuget/ts-nuget/package/ 263ms
Your package was pushed.

The TeklaFusion.4.0.4.snupkg is never published or even detect looks like it by the CLI tooling....

thanks in advance for the clarification
jorge costa

Ive originally raise ticket on dotnet side, dotnet/sdk#25958 but they closed it .

Verbose Logs

No response

@zivkan
Copy link
Member

zivkan commented Jun 17, 2022

@jmecosta I was able to reproduce the issue using the same command line you used (changing the URLs to the localhost server I was testing with).

I found that by not specifying the --symbol-source <url> parameter, it actually worked. The server I was using, like nuget.org, includes a SymbolPackagePublish resource. If Proget's service index (index.json) includes this resource, just like nuget.org's does, then you should not need to specify the symbol source URL on the command line.

But we should not be silently ignoring the symbols package or silently failing, so that needs to be fixed.

@jmecosta
Copy link
Author

@zivkan thanks for confirming the problem

@jmecosta
Copy link
Author

@zivkan maybe related but:
https://docs.microsoft.com/en-us/nuget/create-packages/symbol-packages-snupkg

dotnet nuget push TeklaFusion.4.0.4.snupkg --source http://ts-nuget.teklaad.tekla.com/nuget/ts-nuget/v3/index.json

also doest do anything. i supose the SymbolPackagePublish is also missing from that source

@zivkan
Copy link
Member

zivkan commented Jun 22, 2022

@jmecosta I just remembered that there have been some changes to push over the last 2 years:

If you're on Windows, it would be great if you could try downloading NuGet.exe versions 5.8 and 6.1 from https://nuget.org/downloads, and try them out (perhaps with the --symbol-source argument), and let us know if either (or both) of those work. If this used to work and we can narrow down when it broke, it might be easier to fix.

@jmecosta
Copy link
Author

jmecosta commented Jun 22, 2022

6.2.1.2 not working
5.8.1 not working either
5.9.2 not working either

@nkolev92 nkolev92 added Priority:2 Issues for the current backlog. Category:Quality Week Issues that should be considered for quality week labels Jun 23, 2022
@jwfx
Copy link

jwfx commented Oct 18, 2022

Just tested this with the current dev branch (6.5) and it is not working either.

@zivkan
I don't really think the code you linked could actually work.

This loop here expects a path for every package, one for .nupkg and one for .snupkg. But the command handler calling this method only allows for a single argument to pass through.

But given that .snupkg should be handled automatically without the user explicitly specifying it as an argument, there probably should be some code in between those methods that handles looking for .snupkg next to the supplied .nupkg.

Could you give an update about this issue?

@zivkan
Copy link
Member

zivkan commented Oct 18, 2022

@jwfx we prioritize work based on a number of factors, one of which is upvotes. This issue doesn't have any upvotes yet, so might not have caught the eye of people triaging issues during sprint planning. This issue was created when it was my turn on the support rotation, and I just validated that the issue can be reproduced but support doesn't have enough time to bugfix.

@jwfx
Copy link

jwfx commented Oct 18, 2022

Thank you for the update and for linking that document. Hitting this issue directly from a search engine, that policy totally went past me.

@TobiasBreuer
Copy link

Just for information for anyone else hitting this from search engine:
I just realized that in my case, the issue was in the missing protocolVersion attribute in the xml of the NuGet source.

To clarify - the follwoing would not work but instead only publish the package on push:

<add key="Artifactory" value="https://......./api/nuget/v3/xyz-local" />
<add key="ArtifactorySymbols" value="https://....../api/nuget/v3/xyz-local/symbols" />

However, changing the source definition to following:

<add key="Artifactory" value="https://......./api/nuget/v3/xyz-local" protocolVersion="3" />
<add key="ArtifactorySymbols" value="https://....../api/nuget/v3/xyz-local/symbols" />

Magically makes everything work as expected - i.e. a simple nuget push myPackage.nupkg will now push the package and detect and push the corresponding *.snupkg file.

❗ However - due to #9170 still being open, we now have to manually fix the config file as part of our CI pipeline 😞

@jwfx
Copy link

jwfx commented Feb 13, 2023

@jmecosta
The just released ProGet version 2022.20 adds support for pushing .snupkg automatically together with .nupkg without using the --symbol-source parameter.

The unexpected behavior of the --symbol-source parameter in nuget.exe remains though.

@mbxsuite
Copy link

mbxsuite commented Mar 7, 2023

can confirm for local pushes

dotnet nuget push a.0.01.nupkg a.0.01.snupkg --source /nuget --symbol-source /snupkg

does

  • only push nupgk,
  • but not the new symbols package,
  • state that the snupkg file does not exist, which is wrong.

Leaving out the symbol-source parameter, will lead to havinig the snupkg being silently ignored.

#dotnet --version
6.0.406
#dotnet nuget --version
NuGet Command Line
6.3.2.9

@jvmlet
Copy link

jvmlet commented Jun 19, 2023

Same issue with nuget 6.6.1.2, please prioritize.

@jvmlet
Copy link

jvmlet commented Aug 31, 2023

Just noticed that I'm getting file does not exist only in unix, executing same command on windows (dotnet nuget push My.snupckg) DOES pushes it .

@Zaneo
Copy link

Zaneo commented Oct 19, 2023

Looking here: https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Commands/Utility/CommandRunnerUtility.cs#L107-L110

I found when stepping through with a debugger:

if (packageSource == null)
{
    packageSource = new PackageSource(source);
}

Should probably be:

if (packageSource == null)
{
    packageSource = new PackageSource(source)
    {
        ProtocolVersion = 3
    };
}

This seems to cause the SymbolPackageUpdateResourceV3 to fail to resolve given that it creates a V2 repository by default.

@Zaneo
Copy link

Zaneo commented Oct 19, 2023

I also cannot find an execution path that sets:
symbolPackageUpdateResource to a non-null value if a user specifes the symbolSource

 if (string.IsNullOrEmpty(symbolSource)
                && !noSymbols
                && !sourceUri.IsFile
                && sourceUri.IsAbsoluteUri)
            {
                symbolPackageUpdateResource = await CommandRunnerUtility.GetSymbolPackageUpdateResource(sourceProvider, source);
                if (symbolPackageUpdateResource != null)
                {
                    symbolSource = symbolPackageUpdateResource.SourceUri.AbsoluteUri;
                }
            }

After this point symbolPackageUpdateResource is never assigned to.

Which causes:

bool isSymbolEndpointSnupkgCapable = symbolPackageUpdateResource != null;

To always be false.

I suspect somewhere in here:

// Precedence for symbol package API key: -SymbolApiKey param, config, package API key (Only for symbol source from SymbolPackagePublish service)
            if (!string.IsNullOrEmpty(symbolSource))
            {
                symbolApiKey ??= CommandRunnerUtility.GetApiKey(settings, symbolSource, symbolSource);

                // Only allow falling back to API key when the symbol source was obtained from SymbolPackagePublish service
                if (symbolPackageUpdateResource != null)
                {
                    symbolApiKey ??= apiKey;
                }
            }

The symbolPackageUpdateResource was supposed to be resolved.

@Zaneo
Copy link

Zaneo commented Oct 19, 2023

What worked for me:

  1. Do NOT specify SymbolSource this cause a failure
  2. Do create a NuGet.config with your source:
<add key="Artifactory" value="https://......./api/nuget/v3/xyz-local" protocolVersion="3" />
  1. Specify EXACTLY the same string for your source, including trailing slash or not
  2. Specify the A.nupkg file exactly.
dotnet nuget push "A.nupkg" -s https://......./api/nuget/v3/xyz-local -k <YOUR API KEY>

@SuperJMN
Copy link

More than 2 years and still open? 😒

@SuperJMN
Copy link

What worked for me:

  1. Do NOT specify SymbolSource this cause a failure
  2. Do create a NuGet.config with your source:
<add key="Artifactory" value="https://......./api/nuget/v3/xyz-local" protocolVersion="3" />
  1. Specify EXACTLY the same string for your source, including trailing slash or not
  2. Specify the A.nupkg file exactly.
dotnet nuget push "A.nupkg" -s https://......./api/nuget/v3/xyz-local -k <YOUR API KEY>

This doesn't upload the .snupkg.

@jrodrigv
Copy link

jrodrigv commented Nov 10, 2024

So we are at the end of 2024 and using NET 8 this is still an issue which is shameful. I was trying to move from symbols.nupkg to snupkgs but after a day testing different things I was not able to upload it to JFrog Artifactory.

Doing something like this:
dotnet nuget push "A.nupkg" -s https://......./api/nuget/v3/xyz-local -k <YOUR API KEY>

Will upload only the nupkg and do nothing with its snupkg.

And if I try to upload the snupkg doing something like:
dotnet nuget push "A.snupkg" -s https://......./api/nuget/v3/xyz-local -k <YOUR API KEY>

Then the command ends without any error or any log, but of course it didn't upload anything.

So now I will go back to symbols.nupkg...

@romainf-ubi
Copy link

romainf-ubi commented Dec 4, 2024

I have the same issue. I was able to push the .snupkg, but only if I don't define a sub-directory directory (which is not an option in my company).

So I would like to run this command line (but it doesn't take the .snupkg):

dotnet nuget push ./packages/MyLib.*.nupkg \
  --source "https://artifactory.tld/artifactory/api/nuget/v3/nuget/MyLib" \
  --api-key "~~APIKEY~~"

# Only pushes the .nupkg.
# Notice the "/MyLib" at the end of the URL, that allows me to push the package.

But this command line worked, but I can't push to a sub-dir:

dotnet nuget push ./packages/MyLib.*.nupkg \
  --source "https://artifactory.tld/artifactory/api/nuget/v3/nuget/index.json" \
  --api-key "~~APIKEY~~"

# This pushed both the .nupkg and .snupkg, but the problem is that this command line pushes
# the packages at the root of the repository, and I need to push them under "MyLib/"

I really don't see how to fix this issue 🤨

@jmecosta
Copy link
Author

jmecosta commented Dec 4, 2024

we are using this to publish symbols, in fact ive already given up on snpkg format, pretty much that package is just a package with pdbs that need to be index in artifactory... so this works

  - name: Publish DotNet Api
    working-directory: BuildDrop
    run:          
      dotnet nuget push PackageCs.*.nupkg --api-key ${{secrets.ARTIFACTORY_API_NUGET_API_KEY}} --source https://artifactory/artifactory/api/nuget/v3/feed --timeout 1200 --skip-duplicate
      
      
  - name: Publish Symbols
    run:          
      dotnet nuget push PackageSymbols.*.nupkg --api-key  ${{ secrets.ARTIFACTORY_SYMBOLS_FEED_API_NUGET_API_KEY }} --source https://artifactory/artifactory/api/nuget/v3/feed/symbols --timeout 1200 --skip-duplicate

In artifactory as far as i know you need to specify /symbols which is something non standard, so i wouldnt be blaming nuget tooling beucase of how Artifactory implemented this

@romainf-ubi
Copy link

romainf-ubi commented Dec 5, 2024

I think I found a solution.. though don't know yet if it's a workaround or the expected behavior.

My main issue was that I needed to push the .nupkg into a sub-directory in our Artifactory (and not at the root). But apparently, symbols can't be stored at the same place as your .nupkg. They seem to be stored at the root, under a .symbols/ directory, from what I've seen. Because of that, I can't use the simpler command line proposed in various documentations that allows to push both .nupkg and .snupkg. So my solution is to split the command line in two:

# GitLab CI:
publish-nuget-packages:
  variables:
    ARTIFACTORY: 'https://artifactory.tld/artifactory/api/nuget/v3/nuget'
    ARTIFACTORY_SYMBOL: 'https://artifactory.tld/artifactory/api/nuget/v3/nuget/index.json'
  script:
    # Push the packages first, and then the symbols. This is necessary because we push the .nupkg
    # under MyLib/, but it's not possible to push symbols under a directory.
    - dotnet nuget push ./packages/MyLib.*.nupkg
      --source "${ARTIFACTORY}/MyLib" --api-key "${ARTIFACTORY_API_KEY}"
    - dotnet nuget push ./packages/MyLib.*.snupkg
      --source "${ARTIFACTORY_SYMBOL}" --api-key "${ARTIFACTORY_API_KEY}"

Edit: I discovered, by mistake, that you can actually use the same URL for both.

Edit 2: nope.. we do need 2 different URLs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:Symbols Category:Quality Week Issues that should be considered for quality week Functionality:Push Priority:2 Issues for the current backlog. Product:dotnet.exe SeQuality Type:Bug
Projects
None yet
Development

No branches or pull requests