Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

    If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

    Download/ upload a NuGet package using cmd with ProGet Key or Username/ password

    Scheduled Pinned Locked Moved Support
    7 Posts 2 Posters 27 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      hashim.abu-gellban_3562
      last edited by

      Re: Download a NuGet package using cmd

      Q1: How can I pass the API key or username and password using the example provided of my old forum?

      Q2: How can I upload a NuGet package to a ProGet feed using similar API?

      Can you provide me with PowerShell script for that as in the referenced in my old forum?

      atrippA 1 Reply Last reply Reply Quote 0
      • atrippA Offline
        atripp inedo-engineer @hashim.abu-gellban_3562
        last edited by

        Hi @hashim-abu-gellban_3562 ,

        If you plan to use the NuGet API, it's best to familiarize yourself with how it works. We do not document this API nor provide examples, we simply implement Microsoft's API. Here area few links that may be helpful:

        • https://learn.microsoft.com/en-us/nuget/api/overview
        • https://learn.microsoft.com/en-us/nuget/api/package-publish-resource

        When Basic authentication is required, you can use api/{your-key} for username/password. You can learn more about API keys in ProGet here:

        • https://docs.inedo.com/docs/proget-administration-security-api-keys

        As an alternative, you may find ProGet's Common Package API to be easier to use; we also document it and have several examples:

        • https://docs.inedo.com/docs/proget-api-common-package

        Best,
        Alana

        1 Reply Last reply Reply Quote 0
        • H Offline
          hashim.abu-gellban_3562
          last edited by atripp

          The Following is the reply from Steve https://forums.inedo.com/topic/3956/download-a-nuget-package-using-cmd/2?_=1710614207806

          I see a few issues here...

          First, the URL you're using is not correct; the easiest way to to find the url by clicking the "download package link" in the ProGet UI. It will look like this: /nuget/your-feed-name/package/your-package-name/your-version-number

          Second, you're downloading a file - so you want to use a powershell command like this:

          $url = "https://myprogetserver/feeds/mynuggets/package/mypackage/1.0.0"
          $destination = "c:\mypackages\mypackage-1.0.0.zip"
          Invoke-WebRequest -Uri $url -OutFile $destination
          Best,
          Steve

          I tried api/{your-key} but it did not work.
          $url = "https://myprogetserver/feeds/mynuggets/package/mypackage/1.0.0/mykey"
          $destination = "c:\mypackages\mypackage-1.0.0.zip"
          Invoke-WebRequest -Uri $url -OutFile $destination

          I would like to download the package as mypackage.zip file. I do not need to install it.
          Is this correct? "https://myprogetserver/feeds/mynuggets/package/mypackage/1.0.0/mykey"

          Thanks,
          Hashim

          atrippA 1 Reply Last reply Reply Quote 0
          • atrippA Offline
            atripp inedo-engineer @hashim.abu-gellban_3562
            last edited by

            Hi @hashim-abu-gellban_3562 ,

            If you need to authenticate to the feed, you need to pass an API key using Basic authentication., with api as the username and your key as the password.

            Here is one way to do this in PowerShell.

            $user = 'api'
            $pass = 'abcdefg12345'
            $pair = "$($user):$($pass)"
            $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
            $basicAuthValue = "Basic $encodedCreds"
            $Headers = @{
                Authorization = $basicAuthValue
            }
            
            $url = "https://myprogetserver/feeds/mynuggets/package/mypackage/1.0.0"
            $destination = "c:\mypackages\mypackage-1.0.0.zip"
            Invoke-WebRequest -Uri $url -OutFile $destination -Headers $Headers
            

            I would recommend first getting your scripts to work without authentication, then add it in later.

            Cheers,
            Alana

            1 Reply Last reply Reply Quote 0
            • H Offline
              hashim.abu-gellban_3562
              last edited by

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • H Offline
                hashim.abu-gellban_3562
                last edited by

                Hi Alana,

                I found the issue of the url provided from the former forum. It should be "nuget" instead of "feeds", as follows:
                $url = "https://myprogetserver/**nuget**/mynuggets/package/mypackage/1.0.0"

                The complete PowerShell is as follows:

                $user = 'api'
                $pass = 'abcdefg12345'
                $pair = "$($user):$($pass)"
                $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
                $basicAuthValue = "Basic $encodedCreds"
                $Headers = @{
                    Authorization = $basicAuthValue
                }
                
                $url = "https://myprogetserver/nuget/mynuggets/package/mypackage/1.0.0"
                $destination = "c:\mypackages\mypackage-1.0.0.zip"
                Invoke-WebRequest -Uri $url -OutFile $destination -Headers $Headers
                

                Thanks,
                Hashim

                atrippA 1 Reply Last reply Reply Quote 1
                • atrippA Offline
                  atripp inedo-engineer @hashim.abu-gellban_3562
                  last edited by

                  @hashim-abu-gellban_3562 nice find, correct that was a typo :)

                  1 Reply Last reply Reply Quote 0

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  • 1 / 1
                  • First post
                    Last post
                  Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation