0

When our CI Server (CruiseControl.NET running as administrator) runs

dotnet build foo.sln

it fails with the following messages like

error NU1100: Unable to resolve 'Serilog (>= 2.7.1)' for '.NETCoreApp,Version=v2.2'. [C:\path\to\foo.sln]

Serilog only being an example. In fact every nuget package will result in the same error.

Why?

Running the same command from cmd.exe succeeds.

It would seem like this question is a duplicate of some already asked questions, but I do not think so (the other questions are different).

Anders Lindén
  • 6,839
  • 11
  • 56
  • 109

2 Answers2

0

It seems I had to run this in the CI server

nuget sources add nuget.org

I only have to this once.

Maybe there is a way to add that nuget source with the dotnet command instead of using nuget.exe.

Anders Lindén
  • 6,839
  • 11
  • 56
  • 109
0

Since nuget sources add works, I am not sure why you need another way. This the most direct way to edit the global nuget.config on the build machine.

But to answer your question, you can add nuget sources temporarily:

dotnet restore -s https://artifactory.example.com/api/nuget/nuget.org

from How do I register a new NuGet package source

or you can specify nuget sources (incl nuget.org) in a well placed nuget.config. "Well placed" is typically in the same folder as the sln, so it can be committed to the build machine.

Andrew Dennison
  • 1,069
  • 11
  • 9
  • I was running the mentioned command as a build server script (once) to add the nuget source. In other words, I had to run it in the right context (as the same user as the buildserver runs script as). – Anders Lindén Aug 16 '19 at 13:36
  • I could remove that script once I had been running it. – Anders Lindén Aug 16 '19 at 13:37