VSTS Build Package location config

Viewed 4322

When building a project in VSTS we first download the nuget packages in a NUget restore step.

the path to nuget.config points to a file in the solution folder .nuget. in this file there is a path to the repository.

when running the build the restore step works fine and all the packages gets restored into this directory.

2017-07-12T14:11:15.7270814Z Adding package '***' to folder 'd:\a\3\s\microservices\MyPackages12'

but during the build the packages can't be found because of a wrong location.

2017-07-12T14:11:27.7978408Z           Considered "..\..\MyPackages\

this only seems to fail for packages from a package feed from vsts.

where or how can i change the locations for the packages in the buildstep?

thanks..

Edit

Nuget.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="repositoryPath" value="..\MyPackages" />
  </config>
  <packageSources>
    <add key="nuget.org" value="https://www.nuget.org/api/v2/"  />
    <add key="MyWebAPI" value="https://MyWebAPI.pkgs.visualstudio.com/_packaging/MyWebAPI/nuget/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>

Edit 2 I've got it working but not as i like it.

first current solution. version 2 of the nuget installer

buildscreen

current nuget.config.

<?xml version="1.0" encoding="utf-8"?>
 <configuration>
  <config>
<add key="repositoryPath" value="..\s\WebSiteCiCd\Packages" />
  </config>
  <packageSources>
    <!-- remove any machine-wide sources with <clear/> -->
    <clear />
    <!-- add a Team Services feed -->
    <add key="MyGreatFeed" value="https://CICD.pkgs.visualstudio.com/_packaging/CICDWebAPI/nuget/v3/index.json" />
    <!-- also get packages from the NuGet Gallery -->
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
  </packageSources>
  <activePackageSource>
    <add key="All" value="(Aggregate source)" />
  </activePackageSource>
 </configuration>

what i don't like is the

<add key="repositoryPath" value="..\s\WebSiteCiCd\Packages" />

I would like to have a centralized nuget.config without specific project names.

the problem i think is because of the build task dooesn't look at the nuget.config settings but takes the settings in de proj file..

which is in the failing builds.. in this case i used

<add key="repositoryPath" value="..\MyPackages" />

this results in a restore step

2017-07-14T06:35:40.5913207Z Restoring NuGet package Microsoft.AspNet.WebPages.3.2.3.
2017-07-14T06:35:40.5923209Z   GET https://www.nuget.org/api/v2/Packages(Id='Microsoft.AspNet.WebPages',Version='3.2.3')
2017-07-14T06:35:40.6643208Z   OK https://www.nuget.org/api/v2/Packages(Id='Microsoft.AspNet.WebApi.WebHost',Version='5.2.3') 113ms
2017-07-14T06:35:40.6683214Z   GET https://www.nuget.org/api/v2/package/Microsoft.AspNet.WebApi.WebHost/5.2.3
2017-07-14T06:35:40.6798131Z Completed installation of Microsoft.AspNet.Razor 3.2.3
2017-07-14T06:35:40.6818132Z Adding package 'Microsoft.AspNet.Razor.3.2.3' to folder 'd:\a\1\MyPackages'
2017-07-14T06:35:40.6828123Z Completed installation of Microsoft.AspNet.Mvc 5.2.3

but in the build step it uses a different location

 2017-07-14T06:35:49.5938928Z d:\a\1\s\WebSiteCiCd\WebSiteCiCd\WebSiteCiCd.csproj(297,5): error : This project references NuGet package(s) that are missing on this computer. 
Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. 
The missing file is ..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props.

it uses the ..\packages\ reference path

hopes this helps..

3 Answers
Related