Search code examples
batch-filenuget

Nuget pack AND push within same batch script


I'm having a heck of time writing a batch script to both pack and push the resulting .nupkg file up to my private nuget feed. I can call pack just fine, but I don't know how to parse the name of the nupkg out of the resulting output in order to do the push. Unfortunately, the version number auto-increments all the time, so I can't just make an assumption of what the resulting file would be named.

FWIW, I'm using myget.org for my private hosting, but this is could easily be applied to any host (including nuget.org).


Solution

  • nuget push supports wildcards, so you could do something like this:

    REM delete existing nuget packages
    del *.nupkg
    
    nuget pack MyProject.csproj
    
    nuget push *.nupkg