Search code examples
nugetnuget-server

How do I publish to a private nuget repository from the command line?


I've found several helpful documents on this topic but I can't seem to make head nor tail of them. Can someone explain to me like I'm five how I can publish to a private nuget repository from the command line? Specifically, how do I authenticate to my artifactory nuget repository? The command I'm using is

nuget push Mypkg1.0.0.nupkg -Source http://artifactory/artifactory/api/nuget/MypgkRepo

I have zero experience with nuget but am working on making it part of our build process in order to build only what changed and fetch the rest from the repo. Thanks!


Solution

  • I guess the trick is you have to add an authenticated source before trying to push. For example,

    nuget sources add -Name A -Source http://af/artifactory/api/nuget/MyPkgRepo -User user -pass pass
    

    (from here)

    Then call setapikey like this

    nuget setapikey user:pass -Source A
    

    Source

    After doing that, I can say

    nuget push Mypkg1.0.0.nupkg -Source A
    

    and it says "Using credentials from config" rather than asking me for mine.