Publish NuGet artifact to account feed only on tag push

leonard.thieu's Avatar


10 Aug, 2017 09:03 PM

I'm trying to publish a NuGet artifact only on tag push. I've tried

  - provider: NuGet
      secure: <api_key>
    artifact: /$(PROJECT).*\.nupkg/
      appveyor_repo_tag: true

but this doesn't seem to work as it requires the NuGet package to be pushed as an artifact and the act of pushing the artifact also causes it to be published. It happens even if I change the artifact's type to File or set publish_nuget to false. Based on Publishing nuget artifact only on git tags, it looks like I have to write my own script to do this. I wrote the following script (note the tag check is temporarily inverted for testing)

  - ps: |
      $appveyor_repo_tag = $env:APPVEYOR_REPO_TAG

      if ($appveyor_repo_tag -eq "false") {
        $configuration = $env:CONFIGURATION
        $platform = $env:PLATFORM
        $appveyor_build_folder = $env:APPVEYOR_BUILD_FOLDER
        $project = $env:PROJECT

        if ($configuration -eq "") {
          $configuration = "Debug";
        switch ($platform) {
          "x86" { break }
          "x64" { break }
          default { $platform = "AnyCPU" }

        nuget pack "$appveyor_build_folder\$project\$project.csproj" -Properties "Configuration=$configuration;Platform=$platform"

        [xml]$nuspec = Get-Content -Path "$appveyor_build_folder\$project\$project.nuspec"
        $version = $nuspec.package.metadata.version

        $api_key = $env:NUGET_API_KEY

        nuget push "$appveyor_build_folder\$project.$version.nupkg" -Source "" -ApiKey "$api_key" -NonInteractive
      } else {
        Write-Host ""NuGet" deployment has been skipped as environment variable has not matched ("appveyor_repo_tag" is "$appveyor_repo_tag", should be "true")"

which reports success (full build log)

Pushing toofz.NecroDancer.Leaderboards.3.0.7.nupkg to ''...
  Created 806ms
Your package was pushed.

but the new package doesn't show up when I check in Visual Studio.

  1. Support Staff 1 Posted by Ilya Finkelshte... on 10 Aug, 2017 10:57 PM

    Ilya Finkelshteyn's Avatar

    You do not have to do nuget push command, you can simple publish nuget artifact and AppVeyor will publish it to project and account nuget feeds.
    Regarding visibility in VS, please try Include prerelease checkbox.

  2. 2 Posted by leonard.thieu on 10 Aug, 2017 11:22 PM

    leonard.thieu's Avatar

    Thanks. Using Push-AppveyorArtifact in place of nuget push fixes the issue. I did not have to use the Include prerelease checkbox.

  3. leonard.thieu closed this discussion on 10 Aug, 2017 11:22 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac