在 appveyor 上启动 redis-server

start redis-server on appveyor

我想 运行 在 AppVeyor 上进行一些需要可用的 redis 实例的 xUnit 测试。 我没有在 AppVeyor 的 "Service" 中找到 Redis,所以我最终得到了一个自定义解决方案,正如您从 appveyor.yml

中看到的那样
version: 1.0.{build}
before_build:
- nuget restore .\Hangfire.Redis.StackExchange.sln
- START .\packages\Redis-32.2.6.12.1\tools\redis-server.exe ".\packages\Redis-32.2.6.12.1\tools\redis.conf"
- '@ECHO Redis Started'
build:
  publish_nuget: true
  publish_nuget_symbols: true
  verbosity: minimal

不幸的是,构建过程停留在 START .\packages\Redis-32.2.6.12.1\tools\redis-server.exe ".\packages\Redis-32.2.6.12.1\tools\redis.conf"

任何想法或可能的解决方法?

尝试 运行 Redis 作为 Windows 服务:

before_build:
- nuget restore .\Hangfire.Redis.StackExchange.sln
- packages\Redis-32.2.6.12.1\tools\redis-server.exe --service-install
- packages\Redis-32.2.6.12.1\tools\redis-server.exe --service-start
- '@ECHO Redis Started'

对于任何感兴趣的人,这就是 appveyor.yml 的作用。 它基本上直接从 github 下载发行版,在文件夹中解压缩,安装并启动 Redis 作为服务

version: 1.0.{build}
before_build:
- ps: >-
    Invoke-WebRequest "https://github.com/MSOpenTech/redis/releases/download/win-2.8.17.4/redis-2.8.17.zip" -OutFile .\redis-2.8.17.zip;

    $destFolder = "redis-2.8.17";

    $shell = new-object -com shell.application;


    $zip = $shell.NameSpace("$pwd\redis-2.8.17.zip");

    if (Test-Path $pwd$destFolder )

    {
        del $pwd$destFolder -Force -Recurse
    }

    md ".\redis-2.8.17";

    foreach($item in $zip.items())

    {
        $shell.Namespace("$pwd\redis-2.8.17").copyhere($item);
    it kind of worked

    cd $destFolder

    .\redis-server.exe --service-install

    .\redis-server.exe --service-start

    cd ..
- nuget restore Hangfire.Redis.StackExchange.sln
build:
  publish_nuget: true
  publish_nuget_symbols: true
  verbosity: minimal

就我个人而言,我总是会使用 chocolatey 在 AppVeyor Build Worker 上安装所需的任何基础设施。所以这是我要使用的 appveyor.yml(它对我自己需要 Redis 的项目有用):

version: 1.0.{build}
before_build:
- choco install redis-64
- redis-server --service-install
- redis-server --service-start
- nuget restore .\Hangfire.Redis.StackExchange.sln
build:
  publish_nuget: true
  publish_nuget_symbols: true
  verbosity: minimal

这里是 appveyor.yml 的示例,其中包含与 redis-3.2.100 一起使用的 powershell 脚本,目前在 chocolately 上不可用:

appveyor.yml

install:
    - cmd: cd c:\ && mkdir c:\redis-3.2.100
    - ps: c:\Users\root\repos\<YOUR_REPO>\deploy\redis.ps1

redis.ps1

Add-Type -assembly "system.io.compression.filesystem"
$source="https://github.com/MicrosoftArchive/redis/releases/download/win-3.2.100/Redis-x64-3.2.100.zip"
$destination="c:\redisarchive"
Invoke-WebRequest $source -OutFile $destination
[IO.Compression.ZipFile]::ExtractToDirectory('c:\redisarchive', 'c:\redis-3.2.100')

cd c:\redis-3.2.100
.\redis-server.exe --service-install
.\redis-server.exe --service-start
cd ..