locked
Pushing Nuget Packages using Microsoft Release Management Client RRS feed

  • Question

  • I'm trying to Push/publish a nuget package through release managament. I looked and saw no way to do that so I decided to create a poweshell tool and Action to do this. I went with the script from https://dzone.com/articles/using-powershell-publish-nuget

    changing it to 

    Param([string]$nugetServer,[string]$apiKey,[string]$packageName, [string]$nuget)
    
    $latestRelease = $nuget list $packageName
    $version = $latestRelease.split(" ")[1];
    
    $versionTokens = $version.split(".")
    $buildNumber = [System.Double]::Parse($versionTokens[$versionTokens.Count -1]) 
    $versionTokens[$versionTokens.Count -1] = $buildNumber +1
    $newVersion = [string]::join('.', $versionTokens)
    echo $newVersion
    
    get-childitem | where {$_.extension -eq ".nupkg"} | foreach ($_) {remove-item $_.fullname}
    $nuget pack -Version $newVersion
    $package = get-childitem | where {$_.extension -eq ".nupkg"}
    $nuget push -Source $nugetServer $package $apiKey
    

    I have the arguments set for the script in the deployment sequence as

    -nugetServer 'http://myserver' -apiKey 'xxxxxxxx' -packageName 'Name.Package' -nuget '\\Mypath\NuGet.exe'


    When I execute a new release, I get the following in the log

    At \\MyPath\DeployNuget.ps1:3 char:25
    + $latestRelease = $nuget list $packageName
    +                         ~~~~
    Unexpected token 'list' in expression or statement.
    At \\Mypath\DeployNuget.ps1:13 char:8
    + $nuget pack -Version $newVersion
    +        ~~~~
    Unexpected token 'pack' in expression or statement.
    At \\Mypath\nuget\DeployNuget.ps1:15 char:8
    + $nuget push -Source $nugetServer $package $apiKey
    +        ~~~~
    Unexpected token 'push' in expression or statement.
        + CategoryInfo          : ParserError: (:) [], ParseException
        + FullyQualifiedErrorId : UnexpectedToken



    Where do I need to put the nuget.exe so that it executes? or Do i need to re-write the poweshell? or Rather what could I be doing wrong? FYI the Nuget.exe is in the same folder as the ps1 script

     

    me

    Thursday, October 29, 2015 7:37 PM

Answers

  • Hi,

    Thanks for posting here.

    The code you referenced is a little old. You may use something new.

    Powershell NuGet publish script

    https://gist.github.com/PureKrome/90a1587ea2b6c4f51269

    May


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, October 30, 2015 9:07 AM
    Moderator

All replies

  • Hi,

    Thanks for posting here.

    The code you referenced is a little old. You may use something new.

    Powershell NuGet publish script

    https://gist.github.com/PureKrome/90a1587ea2b6c4f51269

    May


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, October 30, 2015 9:07 AM
    Moderator
  • Thanks, this does work. The only issue you'd have to enter the nuget file version.


    me

    Monday, November 9, 2015 7:43 PM
  • Hi,

    Thanks for your feedback and I am glad the issue is fixed.

    May


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, November 12, 2015 1:37 AM
    Moderator