Search code examples
appveyor

Finding location of AppVeyor built artifact for post_build action


I have had AppVeyor building nuget packages and deploying them for me, but now I am trying to do something post_build to the nuget package.

So basically, I have:

build:
  project: XmlRpcCore.sln
  parallel: true
  verbosity: minimal
  publish_nuget: true
  publish_nuget_symbols: false

as well as:

deploy:
  - provider: NuGet
    name: nuget_release
    api_key:
      secure: MJz3DvmtiuNK6IVsPbxR3gWiSCnhKqm6tmPsjdRDgwGx9L2PQSSZ1eE7YS8dkZhx
    skip_symbols: true
    on:
      appveyor_repo_tag: true

and so forth and everything works fine.

Now, my problem comes in trying to find the nuget package for processing in post_build after the build step. It doesn't reside in APPVEYOR_BUILD_FOLDER. I see in output:

Successfully created package 'C:\Users\appveyor\AppData\Local\Temp\1\py7750yjd6\XmlRpcCore.3.1.0.62.nupkg'.

but I don't see any environment variables to help me out with that path so I can call a powershell command in post_build before deploy like so:

after_build:
 - ps: dir
 - ps: MagicCmd -InputPath "$env:<what might go here?>\XmlRpcCore.$env:TAG_VERSION.nuget"

Solution

  • The information about generated artifacts is available in PowerShell session: https://www.appveyor.com/docs/packaging-artifacts/#getting-information-about-uploaded-artifacts

    You can have a simple PowerShell script in before_deploy section analyzing that hash and putting desired value into environment variable, for example, to get the path of first generated artifact:

    before_deploy:
    - ps: |
        foreach ($artifactName in $artifacts.keys) {
          $env:packagePath = $artifacts[$artifactName].path
          break
        }
    - 'echo This is the path: %packagePath%'