gitlab ci build无法还原asp.net核心项目的软件包

时间:2018-09-17 20:13:33

标签: asp.net-core continuous-integration devops gitlab-ci gitlab-ci-runner

我试图配置一个简单的管道来构建我的asp.net核心应用程序并将其部署到共享托管中,但是它始终无法恢复Newtonsoft.Json,我对该项目是可构建的并且在本地计算机上完全可以工作表示怀疑ci文件如下所示:

image: microsoft/dotnet:latest

stages:
  - build

before_script:
  - dotnet restore -s https://api.nuget.org/v3/index.json --packages ./.nuget/

build:
  stage: build
  script:
    - "dotnet build"

我在管道内部遇到的错误是:

/usr/share/dotnet/sdk/2.1.402/Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Newtonsoft.Json". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

我也只尝试了dotnet恢复,但是结果相同。

1 个答案:

答案 0 :(得分:0)

我发现了问题,我添加了Newtonsoft.Json作为参考,而不是从nuget进行安装(实际上Visual Studio从快速操作中为我添加了它),因此我删除了参考并将其作为软件包安装,并且一切正常