查找AppVeyor构建的工件的位置以进行post_build操作

时间:2020-01-16 20:06:35

标签: appveyor

我有AppVeyor构建nuget程序包并为我部署它们,但是现在我正在尝试对nuget程序包做build: project: XmlRpcCore.sln parallel: true verbosity: minimal publish_nuget: true publish_nuget_symbols: false

所以基本上,我有:

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

以及:

post_build

以此类推,一切正常。

现在,我的问题来自尝试在build步骤之后在APPVEYOR_BUILD_FOLDER中找到要处理的nuget包。它不驻留在Successfully created package 'C:\Users\appveyor\AppData\Local\Temp\1\py7750yjd6\XmlRpcCore.3.1.0.62.nupkg'. 中。我在输出中看到:

post_build

但是我看不到任何环境变量可以帮助我解决该问题,因此我可以在deploy之前在after_build: - ps: dir - ps: MagicCmd -InputPath "$env:<what might go here?>\XmlRpcCore.$env:TAG_VERSION.nuget" 中调用powershell命令,如下所示:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            DataBase db = new DataBase()
            {
                students = new List<Students>() {
                    new Students() { Id = 1, StudentId = 15, CourseName = "Biology 101"},
                    new Students() { Id = 2, StudentId = 21, CourseName = "English 201"},
                    new Students() { Id = 3, StudentId = 38, CourseName = "History 301"},
                    new Students() { Id = 4, StudentId = 41, CourseName = "Anthropology 401"},
                    new Students() { Id = 5, StudentId = 15, CourseName = "Graphics 210"},
                    new Students() { Id = 6, StudentId = 21, CourseName = "Physics Lab B"}
                }
            };

            List<int> searchIds = new List<int>() { 15, 21 };

            List<Students> results = db.students.Where(x =>  searchIds.Contains(x.StudentId))
                .GroupBy(x => x.StudentId)
                .Select(x => x.FirstOrDefault())
                .ToList();

        }
    }
    public class DataBase
    {
        public List<Students> students { get;set;}
    }
    public class Students
    {
        public int Id { get; set; }
        public int StudentId { get; set; }
        public string CourseName { get; set; }
    }

}

1 个答案:

答案 0 :(得分:1)

有关生成的工件的信息可在PowerShell会话中找到:https://www.appveyor.com/docs/packaging-artifacts/#getting-information-about-uploaded-artifacts

您可以在before_deploy部分中使用一个简单的PowerShell脚本,分析该哈希并将所需的值放入环境变量中,例如,以获取第一个生成的工件的路径:

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