.gitlab-ci.yml for C#使用Docker image mono

时间:2016-04-26 04:02:53

标签: c# build mono gitlab gitlab-ci

我正在尝试设置gitlab-ci跑步者来构建c#应用。已使用gitlab, gitlab-ci, docker, runner设置mono image

我正在尝试xbuild example.sln但需要获得nuget packages,我不知道如何。

我的.gitlab-ci.yml目前看起来像这样。它会进入构建但是缺少包的错误。

before_script:

build:
 script:
    - xbuild  "example.sln"

2 个答案:

答案 0 :(得分:3)

在之前的脚本中,您需要安装并运行nuget命令行客户端,就像使用bash一样,在构建项目之前获取依赖项。

编辑:Ok nuget已经安装在官方单声道图像上,所以你应该这样做:

before_script:
    - nuget restore -NonInteractive

build:
 script:
    - xbuild  "example.sln"

不确定nuget命令,因为我不熟悉C#和Mono

答案 1 :(得分:1)

我花了一些时间弄清楚如何运行NUnit测试,尤其是因为Gitlab中的Mono模板不再是最新的,因此我必须找出通向nuget软件包的正确路径:

image: mono:latest

stages:
  - build
  - test

build:
  stage: build
  script:
  - nuget restore
  - MONO_IOMAP=case xbuild /t:Build /p:Configuration="Release" /p:Platform="Any CPU" MyPlugin.sln

test:
  stage: test
  script:
  - nuget restore
  - MONO_IOMAP=case xbuild /t:Build /p:Configuration="Release" /p:Platform="Any CPU" MyPlugin.sln
  - mono /root/.nuget/packages/nunit.consolerunner/3.9.0/tools/nunit3-console.exe Plugin.Tests/bin/Release/Plugin.Tests.dll