Using variables in appveyor.yml

niemand.richard's Avatar

niemand.richard

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:

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

  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 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

  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:

    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!

  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

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

 

01 Oct, 2024 04:27 PM
26 Sep, 2024 03:49 PM
26 Sep, 2024 09:02 AM
25 Sep, 2024 07:07 PM
24 Sep, 2024 08:39 PM
24 Sep, 2024 06:47 AM