Missing reference on successful NuGet package installation

hendryanw picture hendryanw · Apr 28, 2016 · Viewed 8.3k times · Source

I am following this guide to setup my own NuGet private server, but using Visual Studio 2010.

I have successfully added the NuGet.Server package through Package Manager Console, but when I want to build the WebApplication I got errors:

The type or namespace name 'Server' does not exist in the namespace 'NuGet' (are you missing an assembly reference?)

There is no error in the package installation, but I see that NuGet.Server is not added in the reference folder of the project, Why is that happen?

Edit : Further investigating on the package contents, I see that NuGet.Server does not have the lib for net40. I might need to fork NuGet.Server source and compile it in net40 to fix this.

Here is my logs from Package Manager Console:

PM> Install-package nuget.server  
Attempting to resolve dependency 'NuGet.Core (≥ 2.10.1)'.  
Attempting to resolve dependency 'Microsoft.Web.Xdt (≥ 2.1.0)'.  
Attempting to resolve dependency 'Newtonsoft.Json (≥ 8.0.1)'.  
Attempting to resolve dependency 'RouteMagic (≥ 1.3.0)'.  
Attempting to resolve dependency 'WebActivatorEx (≥ 2.1.0)'.  
Attempting to resolve dependency 'Microsoft.Web.Infrastructure (≥ 1.0.0.0)'.  
Installing 'Microsoft.Web.Xdt 2.1.1'.  
You are downloading Microsoft.Web.Xdt from Microsoft Corporation, the license agreement to which is available at http://go.microsoft.com/fwlink/?LinkId=273778. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.  
Successfully installed 'Microsoft.Web.Xdt 2.1.1'.  
Installing 'NuGet.Core 2.10.1'.  
Successfully installed 'NuGet.Core 2.10.1'.  
Installing 'Newtonsoft.Json 8.0.1'.  
Successfully installed 'Newtonsoft.Json 8.0.1'.  
Installing 'RouteMagic 1.3'.  
Successfully installed 'RouteMagic 1.3'.  
Installing 'Microsoft.Web.Infrastructure 1.0.0.0'.  
Successfully installed 'Microsoft.Web.Infrastructure 1.0.0.0'.  
Installing 'WebActivatorEx 2.1.0'.  
Successfully installed 'WebActivatorEx 2.1.0'.  
Installing 'NuGet.Server 2.10.3'.  
Successfully installed 'NuGet.Server 2.10.3'.  
Adding 'Microsoft.Web.Xdt 2.1.1' to WebApplication2.  
Successfully added 'Microsoft.Web.Xdt 2.1.1' to WebApplication2.  
Adding 'NuGet.Core 2.10.1' to WebApplication2.  
Successfully added 'NuGet.Core 2.10.1' to WebApplication2.  
Adding 'Newtonsoft.Json 8.0.1' to WebApplication2.  
Successfully added 'Newtonsoft.Json 8.0.1' to WebApplication2.  
Adding 'RouteMagic 1.3' to WebApplication2.  
Successfully added 'RouteMagic 1.3' to WebApplication2.  
Adding 'Microsoft.Web.Infrastructure 1.0.0.0' to WebApplication2.  
Successfully added 'Microsoft.Web.Infrastructure 1.0.0.0' to WebApplication2.  
Adding 'WebActivatorEx 2.1.0' to WebApplication2.  
Successfully added 'WebActivatorEx 2.1.0' to WebApplication2.  
Adding 'NuGet.Server 2.10.3' to WebApplication2.  
File Conflict  
File 'Web.config' already exists in project 'WebApplication2'. Do you want to overwrite it?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "N"):A  
Overwrite existing file 'Web.config'.  
Successfully added 'NuGet.Server 2.10.3' to WebApplication2.  

Answer

BenDoingCoding picture BenDoingCoding · May 4, 2016

I got the same error when trying to build it with Visual Studio 2015 in a project that had the target framework set to .NET Framework 4.0. Setting the target framework to .NET Framework 4.6.1 fixed it for me.

I would suggest using a newer version of Visual Studio if possible, or compiling it with the newer framework itself via the command line. This other stack overflow answer may be of assistance if you wish to do the later. How to build .NET 4.6 Framework app without Visual Studio installed?