Using variables in appveyor.yml
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:
after_build:
- cmd: dotnet nuget push Rn.Common.1.0.{build}.nupkg -k {NuGetKey} -s https://www.nuget.org/
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?
e.g. https://ci.appveyor.com/project/rniemand/rn-common/builds/20917617
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
| ? | 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

Support Staff 1 Posted by Owen McDonnell on 11 Dec, 2018 07:09 AM
For
cmd:environment variables are accessed by surrounding variable name with%%.i.e.
%build%,%NuGetKey%2 Posted by niemand.richard on 11 Dec, 2018 09:21 PM
Thanks for that - I replaced the line in question with:
- cmd: dotnet nuget push Rn.Common.1.0.%version%.nupkg -k %NuGetKey% -s https://www.nuget.org/
But it didn't seem to work:
cd bin/Release
dotnet nuget push Rn.Common.1.0.%version%.nupkg -k %NuGetKey% -s https://www.nuget.org/
error: File does not exist (Rn.Common.1.0..nupkg).
Command exited with code 1
Support Staff 3 Posted by Owen McDonnell on 11 Dec, 2018 10:00 PM
Here's a list of environment variables set for every build.
Versionis not one of them, so unless you set it as an environment variable its not available. ...Perhaps you meant to useAPPVEYOR_BUILD_VERSION.4 Posted by niemand.richard on 11 Dec, 2018 10:43 PM
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:
https://github.com/rniemand/Rn.Common/blob/master/appveyor.yml
and
https://github.com/rniemand/Rn.Common/blob/master/build/package.ps1
Appreciate all the help!
Owen McDonnell closed this discussion on 27 Jun, 2019 05:27 AM.