缺少成功NuGet包安装的参考

时间:2016-04-28 03:24:58

标签: c# visual-studio-2010 nuget nuget-server

我正在关注此guide来设置我自己的NuGet私人服务器,但使用的是Visual Studio 2010。

我已经通过NuGet.Server成功添加了Package Manager Console包,但是当我想构建WebApplication时,我遇到了错误:

  

类型或命名空间名称' Server'命名空间中不存在NuGet' (你错过了一个程序集引用吗?)

软件包安装中没有错误,但是我发现项目的参考文件夹中没有添加NuGet.Server,为什么会这样?

编辑:进一步调查包内容,我发现NuGet.Server没有lib net40。我可能需要分叉NuGet.Server source并在net40中编译以解决此问题。

以下是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.  

2 个答案:

答案 0 :(得分:14)

在尝试使用Visual Studio 2015在目标框架设置为.NET Framework 4.0的项目中构建它时,我遇到了同样的错误。将目标框架设置为.NET Framework 4.6.1为我修复了它。

如果可能的话,我建议使用较新版本的Visual Studio,或者通过命令行使用较新的框架本身进行编译。如果您希望稍后执行此其他堆栈溢出应答可能会有所帮助。 How to build .NET 4.6 Framework app without Visual Studio installed?

答案 1 :(得分:1)

任何不想或不能定位其他.NET Framework版本的人的选项是安装以前版本的NuGet.Server。例如,版本2.10.3以.NET 4.5为目标。

相关问题