Using variables in appveyor.yml

niemand.richard's Avatar


11 Dec, 2018 05:48 AM

Hi All

I am trying to get my head around building a .net core app (SDK 2.1) on AppVeyor, so far I have got 90% of the process bedded down, however I am struggling with publishing my package to NuGet - more specifically using variables in the appveyor.yml file, on this line:

  - cmd: dotnet nuget push Rn.Common.1.0.{build}.nupkg -k {NuGetKey} -s

Ideally I would like it to substitute 2 variables here - (1) the build number to address the packaged NuGet file and (2) and environment variable I defined for the NuGet publish key. I have tried many different ways of escaping the variable and Googled the heck out of it with no luck.

Could someone please point me in the right direction here - it would be greatly appreciated.

P.S. presuming I get this right - would the API key be printed out in the build log?


  1. Support Staff 1 Posted by Owen McDonnell on 11 Dec, 2018 07:09 AM

    Owen McDonnell's Avatar

    For cmd: environment variables are accessed by surrounding variable name with %%.
    i.e. %build%, %NuGetKey%

  2. 2 Posted by niemand.richard on 11 Dec, 2018 09:21 PM

    niemand.richard's Avatar

    Thanks for that - I replaced the line in question with:

        - cmd: dotnet nuget push Rn.Common.1.0.%version%.nupkg -k %NuGetKey% -s

    But it didn't seem to work:

    cd bin/Release
    dotnet nuget push Rn.Common.1.0.%version%.nupkg -k %NuGetKey% -s
    error: File does not exist (Rn.Common.1.0..nupkg).
    Command exited with code 1

  3. Support Staff 3 Posted by Owen McDonnell on 11 Dec, 2018 10:00 PM

    Owen McDonnell's Avatar

    Here's a list of environment variables set for every build. Version is not one of them, so unless you set it as an environment variable its not available. ...Perhaps you meant to use APPVEYOR_BUILD_VERSION.

  4. 4 Posted by niemand.richard on 11 Dec, 2018 10:43 PM

    niemand.richard's Avatar

    Thanks for that - I gave up on the venture because I was concerned of exposing my API key in the build log, and had a lot more success with a PowerShell script, namely:


    Appreciate all the help!

  5. Owen McDonnell closed this discussion on 27 Jun, 2019 05:27 AM.

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


06 Jun, 2024 02:12 PM
06 Jun, 2024 03:49 AM
04 Jun, 2024 03:53 AM
30 May, 2024 04:03 PM
27 May, 2024 02:06 AM
20 May, 2024 09:52 PM