在Appveyor中为每个平台构建不同的解决方案配置

时间:2019-10-22 14:48:16

标签: appveyor

我试图将Linux构建和测试添加到我维护的C#库中。解决方案中的一个库需要WinForms,因此无法在Linux上构建。我在解决方案中添加了ReleaseNoGui配置,我希望Linux构建该配置,而不是Release。这可能吗?这是我尝试过的方法,但仍在构建Release

(…)

image: 
  - Visual Studio 2019
  - Ubuntu1804

configuration: Release

(…)

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


for:
  - 
    matrix:
      only:
        - image: Visual Studio 2019

    deploy:
      - provider: NuGet
        name: nuget_release
        api_key:
(snipped...)
  -
    matrix:
      only:
        - image: Ubuntu1804

    configuration: ReleaseNoGui

2 个答案:

答案 0 :(得分:1)

for.matrix专门基于环境变量进行配置。当前,image是不受支持的环境变量。

要实现所需的目标,可以改用以下appveyor.yml配置:

environment:
  matrix:

  # Windows job
  - job_name: Windows build
    appveyor_build_worker_image: Visual Studio 2019

  # Linux job
  - job_name: Linux build
    appveyor_build_worker_image: Ubuntu1804

matrix:
  fast_finish: true

configuration: Release

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

for:
-
  matrix:
    only:
      - job_name: Windows build

  deploy:
    - provider: NuGet
      name: nuget
-
  matrix:
    only:
      - job_name: Linux build

  configuration: ReleaseNoGui

答案 1 :(得分:0)

在阅读了Feodor的答案之后,我尝试了module_that_contains_function_to_be_mocked,并将environment.matrix添加到configuration项目中,并得出:

environment.matrix

以正确的配置构建Linux。