NuGet package restore doesn't install packages for asp.net web site

Viewed 1699

I have a solution and this solution contains a asp.net web site (not application).

I want to enable C# 6, so have to install nuget packages. I did this in Visual Studio 2015, it creates C:\solution\website\packages.config.

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.7" targetFramework="net45" />
  <package id="Microsoft.Net.Compilers" version="2.3.2" targetFramework="net45" developmentDependency="true" />
</packages>

I want to follow the best practice that do not add the package binaries into version control system, so I only committed packages.config.

It seems automatic package restore doesn't work for web sites, so I plan to write a svn update script, that whenever I run svn update, the script will run to restore packages in case other developers ran svn clean that deletes unversioned files.

In the script I write

nuget.exe restore C:\solution\Website\ -PackagesDirectory C:\solution\packages

the command does download missing packages, but it doesn't install the packages.

Does anyone know why? Am I missing anything?

1 Answers

For NuGet 2.7+: Downloads and installs any packages missing from the packages folder.

Restore packages for a solution file

nuget restore a.sln

Restore packages for a solution file, using MSBuild version 14.0 to load the solution and its project(s)

nuget restore a.sln -MSBuildVersion 14

Restore packages for a project's packages.config file, with the packages folder at the parent

nuget restore proj1\packages.config -PackagesDirectory ..\packages

Restore packages for the solution in the current folder, specifying package sources

nuget restore -source "https://www.nuget.org/api/v2;https://www.myget.org/F/nuget"

For more info

Related