Mr.*_*guy 7 .net c# gitlab docker gitlab-ci
我创建了一个 C# 项目 ( C# 7.0& .net framework 4.7.2),并添加了一些单元测试 ( NUnit 3.11.0)。
该代码存储在 Gitlab 存储库中,我可以在本地运行测试和构建。但现在我想通过 Gitlab CI 自动执行此操作。根据这篇stackoverflow 帖子和互联网上的很多文章,您应该在 Windows 计算机上创建自己的运行器。
但其中大多数答案已经很旧了,Gitlab CI 现在可以使用 Docker 镜像。但后来我遇到了我的问题。我应该为这个跑步者使用什么图像?我尝试过microsoft/dotnet-framework和microsoft/dotnet但这些都不起作用。
给出microsoft/dotnet-framework错误消息:No such image: microsoft/dotnet-framework
并且microsoft/dotnet图像不包含.net 4.7.2库,因此它不能用于构建。
Gitlab CI + Docker 镜像 + C# 构建?
是否仍然无法使用用于 C# 构建(控制台应用程序)的 Docker 映像创建 Gitlab CI 运行器?或者我只是在这里做错了什么?
我当前的 .gitlab-ci.yml
image: microsoft/dotnet-framework
stages:
- build
before_script:
- 'dotnet restore'
app-build:
stage: build
script:
- 'dotnet build'
only:
- master
Run Code Online (Sandbox Code Playgroud)
更新
感谢@Andreas Zita 我现在有了一张图片 ( dsfnctnl/gitlab-dotnetcore-builder:0.15.0)。不幸的是,这给了我与microsoft/dotnet. 这可能是我的构建脚本中的一个错误(或者我希望如此),但我似乎找不到它是什么。
错误:
$ dotnet restore
Nothing to do. None of the projects specified contain packages to restore.
$ dotnet build
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Nothing to do. None of the projects specified contain packages to restore.
/usr/share/dotnet/sdk/2.1.500/Microsoft.Common.CurrentVersion.targets(1179,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.7.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/builds/test/TestProject.csproj]
/usr/share/dotnet/sdk/2.1.500/Microsoft.Common.CurrentVersion.targets(1179,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.7.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [/builds/test/TestProjectTests.csproj]
Build FAILED.
Run Code Online (Sandbox Code Playgroud)
Mono 图像正在帮助我在 GitLab 中构建 C# 应用程序。
image: mono:4.4.0.182
stages:
- build
app-build:
stage: build
script:
- MONO_IOMAP=case xbuild/t:Build/p:Configuration="Debug"/p:Platform="x86"
myApp.sln
only:
- master
Run Code Online (Sandbox Code Playgroud)
平台可能会根据构建配置(如 AnyCPU)而改变。
| 归档时间: |
|
| 查看次数: |
5604 次 |
| 最近记录: |