我创建了一个C#项目(C# 7.0 & .net framework 4.7.2),并添加了一些单元测试(NUnit 3.11.0)。
这段代码存储在Gitlab中,我可以在本地运行测试和构建。但现在我想通过Gitlab CI实现自动化。根据这的堆叠溢出帖子和互联网上的很多文章,你应该在一台Windows机器上创建自己的跑步者。
但是这些答案大部分已经很古老了,Gitlab CI现在可以处理Docker图像了。但后来我遇到了问题。我应该为这个跑步者用什么形象?我试过microsoft/dotnet-框架和microsoft/dotnet,但它们都没有用。
microsoft/dotnet-framework给出了错误消息:No such image: microsoft/dotnet-framework
而且microsoft/dotnet映像不包含.net 4.7.2库,因此不能用于构建。
Gitlab CI + Docker映像+ C# build?
是否仍然不可能为C#构建(控制台应用程序)创建带有Docker映像的Gitlab运行程序?还是我只是做错了什么?
我现在..gitlab ci.yml
image: microsoft/dotnet-framework
stages:
- build
before_script:
- 'dotnet restore'
app-build:
stage: build
script:
- 'dotnet build'
only:
- master更新
感谢@Andreas,我现在有了一个图片(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.发布于 2019-01-16 23:59:47
我认为,如果您使用.net框架4.7.2,并且您想要构建无痛的,您需要使用Visual的Windows。也许会有帮助:https://medium.com/@n3d4ti/build-net-project-with-gitlab-ci-44e6c3562a8
发布于 2019-01-16 11:34:16
Mono映像正在为我在GitLab中构建GitLab应用程序而工作。
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平台可能会根据像AnyCPU这样的构建配置而改变。
https://stackoverflow.com/questions/53434460
复制相似问题