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

[Feature]: Ability to specify relative path on nuget push #11697

Closed
bgreman opened this issue Mar 28, 2022 · 3 comments
Closed

[Feature]: Ability to specify relative path on nuget push #11697

bgreman opened this issue Mar 28, 2022 · 3 comments
Labels
Functionality:Push Resolution:Duplicate This issue appears to be a Duplicate of another issue Type:Feature

Comments

@bgreman
Copy link

bgreman commented Mar 28, 2022

NuGet Product(s) Involved

NuGet.exe

The Elevator Pitch

I propose adding another parameter (and perhaps configuration option) to nuget push. This parameter (perhaps -DestinationRelativePath or similar) would allow use of the -Source parameter to specify a configured Package Source, and then the remainder of the PUT request would be built by concatenating the package source and the value of the DestinationRelativePath. So if one's Package Source called MyNuGetSource was configured with the URL https://mynugetserver.com/api/nuget/v3/my-nuget-repo and one executed the following:

nuget push MyPackage.nupkg -Source MyNuGetSource -DestinationRelativePath MyPackage/1.1The eventual PUT request would be tohttps://mynugetserver.com/api/nuget/v3/my-nuget-repo/MyPackage/1.1/MyPackage.nupkg`

NuGet would still use the credentials specified for the MyNugetSource Package Source, including any stored credentials and client certificate information. Currently this is impossible with regard to client certificates.

Additional Context and Details

NuGet push allows pushing to any arbitrary NuGet repository URL using the -Source parameter. Alternately, the NuGet CLI can store configuration for a given Package Source, including authentication information (username/password, client certificates, etc). However, if one attempts to push to a location that is a sub-path of an existing configured Package Source, NuGet is unable to recognize this and use the configuration for that Package Source.

For example, if I have configured a Package Source called MySource as follows:
<add key="MyNuGetSource" value="https://mynugetserver.com/api/nuget/v3/my-nuget-repo"/>
and I then attempt to perform the following:
nuget push myPackage.nupkg -Source https://mynugetserver.com/api/nuget/v3/my-nuget-repo/subDir1/subDir2, the NuGet CLI does not recognize that this is a subPath of my configured MyNugetSource source, and thus will prompt for credentials if the server side requires authentication. This can be an issue for automated builds, though credential providers could theoretically work around this issue, or one could pass an apiKey on the command line. What cannot be worked around is if the server requires client certificate authorization, since those options can only be specified in the NuGet config file, and not on the command line.

Why might one want to use a relative path in the nuget push? One reason is if their repository target doesn't function the way NuGet.Server does. NuGet.Server will create an appropriate folder structure and place the pushed package into the correct location within it. For example, in Artifactory NuGet repos, a simple nuget push will result in the package being dropped into the root of the repository. For large repos, this can be troublesome.

@heng-liu heng-liu added Functionality:Push Resolution:Duplicate This issue appears to be a Duplicate of another issue labels Mar 29, 2022
@heng-liu
Copy link
Contributor

Hi @bgreman , I think this is a duplicate of #10157. Please let me know if you disagree.
Adding any context/upvotes there is helpful: #10157

@bgreman
Copy link
Author

bgreman commented Mar 29, 2022

@heng-liu I do not think this is a duplicate, that one seems to be referring to relative paths for where the packages to be pushed are currently located when also using a wildcard pattern for which packages to push, not a relative path for the destination sub-path within the targeted remote Package Source. The example command in #10157 doesn't even specify the -s or -Source parameter.

@ghost
Copy link

ghost commented Sep 23, 2022

@heng-liu please reopen this, it is not a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:Push Resolution:Duplicate This issue appears to be a Duplicate of another issue Type:Feature
Projects
None yet
Development

No branches or pull requests

3 participants