0
votes

My solution grabs some nuget packages from Nuget.org and some of them are in my repository under the "lib" folder. I am aware that having packages in my repository is not the best option, but for now, i am stuck with it.

In my solution nuget.config looks like this :

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
    <add key="CustomSource" value="../lib" />
  </packageSources>
    <activePackageSource>
    <add key="All" value="(Aggregate source)"  />
  </activePackageSource>
  <solution>
    <add key="disableSourceControlIntegration" value="true" />
  </solution>
</configuration>

It works fine in Visual Studio.

In VSTS I changed the nuget restore task option : Restore Nuget

My build fails like this:

The nuget command failed with exit code(1) and error(Failed to retrieve information about 'Microsoft.Extensions.Configuration.Abstractions' from remote source 'D:\a\1\lib'.)

Packages failed to restore

Obviously, Microsoft.Extensions.Configuration.Abstractions, is supposed to download from nuget.org. What should I change so it tries to use the 2 nuget sources? Thanks!

1
Is the folder containing your references actually D:\a\1\lib? I would guess that it is not, since build source is downloaded to D:\a\1\s. You have a relative pathing issue.Daniel Mann
Should be correct as it says this at some point : 2018-07-25T14:32:35.1270714Z Running restore with 2 concurrent jobs. 2018-07-25T14:32:35.1270848Z Reading project file D:\a\1\s\Api\Domain.Modules.Tests\Domain.Modules.Tests.csproj. 2018-07-25T14:32:35.1270994Z Reading project file D:\a\1\s\Api\src\Data.Caching\Data.Caching.csproj.. On top of that, i would understand if it crahsed on a "Entrprise nuget", here is crashes on a nuget.org package... Thanks :)Tom
@DanielMann thank you, you were right, i didn't look the right way, if one of the folder doesn't exists, the errors pops, and that was the problem.. i had to change the source to ../s/Projectname/lib". Thanks!Tom

1 Answers

1
votes

If you specify your own NuGet.config file in NuGet restore task, it will save the content of the specify NuGet.config file to a temporary config file like: D:\a\1\Nuget\tempNuGet_3274.config.

So If you are using Hosted agent, you should specify the local feed path as:

<add key="CustomSource" value="../s/Projectname/lib" />

Besides, you can also use private agent which locate in your local machine, so that the packages can be found from other directory.