上篇文章介绍了 GitLab CI 的持续集成配置方法,本篇文章将主要介绍 NUnit 的持续集成和遇到的一些坑
1.NUnit 单元测试持续集成
- 下载,
- 在持续集成的 CI 服务器上,安装 msi,并将安装路径从 C:\Program Files (x86) 改到 C:\NUnit,因为 shell 脚本好像处理括号或者空格比较麻烦。
- 将之前的 shell 脚本的 /p:Configuration=Release 改成 /p:Configuration=Debug
- 构建 shell 脚本命令
- C: \NUnit\nunit - console\nunit3 - console.exe " ConsoleApplication1 "
【全部脚本】
- stages: -build job: stage: build script: -echo "Restoring NuGet Packages..." - C: \test\nuget.exe restore "ConsoleApplication1.sln" - echo "Solution Build..." - C: \Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe / p: Configuration = Debug / p: Platform = "Any CPU" / consoleloggerparameters: ErrorsOnly / maxcpucount / nologo / verbosity: quiet "ConsoleApplication1.sln" - C: \NUnit\nunit - console\nunit3 - console.exe " ConsoleApplication1.sln"tags: except: -tags
2. 遇到的问题
2.1 一台机子配置多个 CI 服务
原理就是用 sc 命令创建一个 gitlab_runner 的服务,如下段代码
- sc create gitLab_FrameWork binPath = "D:\Kog_ECode\Kog_Framework\gitlab-ci-multi-runner-windows-amd64.exe run --working-directory D:\Kog_ECode\Kog_Framework --config D:\Kog_ECode\Kog_Framework\config.toml --service gitlab-runner --syslog"
核心是 BindPath,bindPath 如何填写,参考可以把 gitlab-runner 服务的搞进来,改个路径即可
2.2 MSBuild 编译错误
MSBuild 间接引用会报错,我直接安装的 vs2015,网上说安装 vs2015 编译工具和 netframework 的 sdk 版本即可解决
错误如下:
- error CS0012: The type 'XXXXXXX'is defined in an assembly that is not referenced.You must add a reference to assembly 'System.XXXXXX, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Microsoft Build Tools 2015 下载地址 :
Microsoft Build Tools 2013 下载地址:
2.3 MSB4019
CI 服务器用 msbuild 命令编译时候,会出现 MBS4019(想看到错误编号,只要把命令 / verbosity:quiet 改成 / verbosity=diagnostic 即可)
错误:
- error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\webApplications\XXXX.targets"was not found.Confirm that the path in the declaration is correct,
- and that the file exists on disk.)
打开,引起错误的原因是这句话
【解决办法】
1 > 安装 Microsoft Visual Studio 2015 Shell (独立),Visual Studio 2015 Isolated Shell(需要有注册 Connect 账号)
2 > 把缺失的 target 拷贝上去, 或者删除
【参考资料】
来源: http://www.cnblogs.com/newP/p/5777256.html