Configuring the feed used by dnu to restore packages

glennc edited this page May 18, 2016 · 2 revisions

#This documentation is now out of date. For information on configuring NuGet feeds see http://docs.nuget.org/consume/nuget-config-file

Once DNX is installed on the machine, the ‘dnu’ command can be used to manage packages for the project. For example, ‘dnu restore’ command downloads all packages that are listed in the project.json file. ‘dnu’ uses Nuget internally to download packages and hence points to the Nuget feed (https://www.nuget.org/api/v2/) by default. Since the VNext packages are available on the myget feed, we need to update the feed to this so that packages can be looked up on this feed.

Configuring the feed for Nuget is done via a NuGet.config file which is available in the user profile folder. On Windows machine it can be found at %AppData%\NuGet\NuGet.config and on *nix machines which run ASP.NET via Mono it can be found at ~/.config/NuGet/NuGet.config. By default the content should be

<?xml version=”1.0” encoding=”utf-8”?>
<configuration/>

In addition, the samples on the Home repo and MusicStore as well as Bug Tracker have NuGet.config in their root folders. These have the vnext feed in them and hence ‘dnu restore’ on these applications pulls in the right set of packages.

There are two feeds from where developers can download VNext packages

Updating feed on Windows machines

Windows machine with Visual Studio 2015

On Windows machine with Visual Studio 2015 installed, this can be done through the Package Manager Console Settings. Open Tools--> Options--> Nuget Package Manager--> Package Sources. Add the above master or vnext feeds and save. This should update the NuGet.config file automatically.

Window machine without Visual Studio 2015

On Windows machines without VS installed, the nuget feed can be updated in the %AppData%\NuGet\NuGet.config folder. To pull the packages from the ‘vnext’ feed on Myget update the content of the files to

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="AspNetVNext" value="https://www.myget.org/F/aspnetvnext/api/v2/" />
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
  </packageSources>
  <disabledPackageSources />
  <activePackageSource>
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
  </activePackageSource>
</configuration>

If you need to pull the packages from the master feed update the ‘AspNetVNext’ feed to ‘https://www.myget.org/F/aspnetmaster/api/v2/’

Updating feed on *Nix machines

Install Mono on the machines to run ASP.NET 5 projects. Once Mono is install the nuget config file can be found at ~/.config/NuGet/NuGet.config. To pull the packages from the ‘vnext’ feed on Myget, open the file in any text editor and update the contents to

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="AspNetVNext" value="https://www.myget.org/F/aspnetvnext/api/v2/" />
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
  </packageSources>
  <disabledPackageSources />
  <activePackageSource>
    <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
  </activePackageSource>
</configuration>

If you need to pull the packages from the master feed update the ‘AspNetVNext’ feed to ‘https://www.myget.org/F/aspnetmaster/api/v2/’