2015-02-23 11 views
5

Tôi muốn chạy một số kiểm tra xUnit trên AppVeyor cần một phiên bản redis có sẵn. tôi không tìm thấy Redis trong "Dịch vụ" của AppVeyor vì vậy tôi kết thúc với một giải pháp tùy chỉnh, như bạn có thể nhìn thấy từ appveyor.ymlbắt đầu redis-server trên appveyor

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 

tiếc là quá trình xây dựng bị mắc kẹt tại START .\packages\Redis-32.2.6.12.1\tools\redis-server.exe ".\packages\Redis-32.2.6.12.1\tools\redis.conf"

bất kỳ ý tưởng hoặc cách giải quyết có thể?

Trả lời

3

Đối với bất cứ ai quan tâm, đó là appveyor.yml rằng đã làm các trick. Nó cơ bản tải về việc phát hành trực tiếp từ github, giải nén vào một thư mục, cài đặt và bắt đầu Redis như một dịch vụ

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 
4

Cố gắng chạy Redis như một dịch vụ 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' 
+0

ý tưởng hay! Thật không may phiên bản 2.6.12 của redis không hỗ trợ được cài đặt như một dịch vụ, nhưng tôi sẽ cố gắng ý tưởng tương tự thông qua sô cô la – mCasamento

+1

Nó hoạt động! ;) Tôi sẽ đăng câu trả lời ở đây – mCasamento

+2

Tuyệt vời! Để tham khảo trong tương lai - một cách khác để bắt đầu một quá trình mà không chặn việc xây dựng đang sử dụng lệnh ghép ngắn PowerShell 'Bắt ​​đầu-Xử lý'. Thông thường, bạn nên thêm một số độ trễ trên dòng tiếp theo với lệnh 'Start-Sleep' để cho phép tiến trình khởi động. –

2

Cá nhân tôi sẽ luôn luôn sử dụng chocolatey cài đặt bất cứ cơ sở hạ tầng cần thiết trên trên AppVeyor Xây dựng Worker. Vì vậy, đây là appveyor.yml rằng tôi sẽ sử dụng (và đó làm việc cho tôi về dự án của riêng tôi cần 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 
0

Dưới đây là ví dụ về appveyor.yml với một kịch bản PowerShell làm việc với redis-3.2.100 mà hiện không khả dụng trên 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 .. 
Các vấn đề liên quan