我创建了一个C#项目 (
但是大多数答案已经相当陈旧了,Gitlab CI现在可以使用Docker镜像。但是我遇到了问题。我应该为此runner使用哪个镜像?我尝试了microsoft/dotnet-framework和microsoft/dotnet,但它们都无法正常工作。
C# 7.0
& .net framework 4.7.2
) 并添加了一些单元测试 (NUnit 3.11.0
)。这段代码存储在Gitlab仓库中,我可以在本地运行测试和构建。但现在我想通过Gitlab CI自动化这个过程。根据这篇stackoverflow文章和互联网上的许多文章,您应该在Windows机器上创建自己的runner。但是大多数答案已经相当陈旧了,Gitlab CI现在可以使用Docker镜像。但是我遇到了问题。我应该为此runner使用哪个镜像?我尝试了microsoft/dotnet-framework和microsoft/dotnet,但它们都无法正常工作。
microsoft/dotnet-framework
会显示错误消息:No such image: microsoft/dotnet-framework
而microsoft/dotnet
镜像不包含.net 4.7.2
库,因此无法用于构建。
Gitlab CI + Docker镜像 + C#构建?
是否仍然无法创建一个使用Docker镜像进行C#构建 (控制台应用程序)的Gitlab CI runner?还是我在这里做错了什么?
我的当前 .gitlab-ci.yml 文件
image: microsoft/dotnet-framework
stages:
- build
before_script:
- 'dotnet restore'
app-build:
stage: build
script:
- 'dotnet build'
only:
- master
更新
感谢 @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.
microsoft/
镜像是Windows镜像。您需要寻找基于Linux的C#构建器镜像。 - tkausl