gpt4 book ai didi

AppVeyor CI : use build script for linux and MSBuild for Windows

转载 作者:行者123 更新时间:2023-12-04 13:59:27 26 4
gpt4 key购买 nike

设想

我在 AppVeyor 上有一个 CMake 项目,我正在尝试向其中添加 Linux Build。我的 Windows 版本在 before_build 中使用 CMake 生成器用于生成使用 build: project 构建的 Visual Studio 解决方案的脚本.

我想用 build_script: 执行我的 Linux 构建反而。但是,当我向矩阵添加构建脚本时,出现错误:

The build phase is set to "MSBuild" mode (default), but no Visual Studio project or solution files were found in the root directory. If you are not building Visual Studio project switch build mode to "Script" and provide your custom build command.



尝试的解决方案

我试过添加 build: offbuild: Script到矩阵但是这些选项都没有帮助。是我为 Windows 定义脚本并使用 build_script 的唯一选择在两个平台上?

例子

我的 appveyor.yml文件看起来像这样
version: 'build-{build}-{branch}'

image:
- Visual Studio 2017
- Ubuntu

platform:
- x64

configuration:
- Release
- Debug

environment:
APPVEYOR_YML_DISABLE_PS_LINUX: true

install:
- ps: .\install-dependency.ps1
- sh: ./install-dependency.sh

for:
-
matrix:
only:
- image: Ubuntu
before_build:
- mkdir -p build; cd build; cmake -DCMAKE_BUILD_TYPE=%CONFIGURATION% ..
build_script:
- make

-
matrix:
only:
- image: Visual Studio 2017
before_build:
- cmake -G "Visual Studio 15 2017" -A x64 .
build:
project: $(APPVEYOR_PROJECT_NAME).sln

test_script:
- CTest -C %CONFIGURATION%

尝试的解决方案详细信息

作为引用,这是我尝试指定构建选项的方式
matrix:
only:
- image: Ubuntu
build: Script
before_build:
- mkdir -p build; cd build; cmake -DCMAKE_BUILD_TYPE=%CONFIGURATION% ..

进一步的研究

我尝试执行独立的 Linux 构建,一切都按预期工作,我不需要修改任何 script参数。也许 AppVeyor 即使设置了矩阵也不支持混合构建类型。
version: 'build-{build}-{branch}'

image: Ubuntu

platform:
- x64

configuration:
- Release
- Debug

install:
- sh: ./install-dependency.sh

before_build:
- mkdir -p build; cd build; cmake -DCMAKE_BUILD_TYPE=%CONFIGURATION% ..

build_script:
- make

test_script:
- ctest -C %CONFIGURATION%

最佳答案

虽然我还没有找到所问问题的解决方案,但有一种在两个平台上构建的解决方法。对于 Windows,我可以使用 default MSBuild脚本msbuild <project> /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" .

version: 'build-{build}-{branch}'

image:
- Visual Studio 2017
- Ubuntu

platform:
- x64

configuration:
- Release
- Debug

environment:
APPVEYOR_YML_DISABLE_PS_LINUX: true

install:
- ps: .\install-dependency.ps1
- sh: ./install-dependency.sh

for:
-
matrix:
only:
- image: Ubuntu
before_build:
- mkdir -p build; cd build; cmake -DCMAKE_BUILD_TYPE=%CONFIGURATION% ..
build_script:
- make

-
matrix:
only:
- image: Visual Studio 2017
before_build:
- cmake -G "Visual Studio 15 2017" -A x64 .
build_script:
- msbuild %APPVEYOR_PROJECT_NAME%.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"

test_script:
- ctest -C %CONFIGURATION%

关于AppVeyor CI : use build script for linux and MSBuild for Windows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53578876/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com