在 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

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

看完费奥多尔的回答后,我尝试了environment.matrix,把configuration加到environment.matrix项中,得出:

environment:
matrix:
# Windows job
- job_name: Windows build
appveyor_build_worker_image: Visual Studio 2019
configuration: Release
# Linux job
- job_name: Linux build
appveyor_build_worker_image: Ubuntu1804
configuration: ReleaseNoGui
matrix:
fast_finish: true
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

它使用正确的配置构建 Linux。

最新更新