c# - 缺少有关成功安装 NuGet 包的引用

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

我正在关注这个guide设置我自己的 NuGet 私有(private)服务器,但使用 Visual Studio 2010。

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

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

包安装没有报错,但是我看到项目的reference文件夹里没有添加NuGet.Server,这是为什么?

编辑:进一步调查包内容,我发现 NuGet.Server 没有 net40lib。我可能需要 fork 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.  

最佳答案

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

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

关于c# - 缺少有关成功安装 NuGet 包的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36904694/

相关文章:

c# - 在 nuget 包中包含引用的项目

c# - 调用线程 .NET .this 与 .control

c# - 在 Google Visualization API (JavaScript) 中动态添加行

c# - 我的 WPF 应用程序未触发 MainWindow_Loaded

c# - LINQ left join ordered with empty right-items at the end

c# - Nuget Library - 将库的 DLL 复制到当前项目的输出目录

c# - ASP.NET 标识 : Make other fields in AspNetUsers unique key

c# - 我可以在不验证的情况下加载 XmlDocument 吗?

c# - 无法将 content1.png Assets 加载为非内容文件

c# - 无法添加对 'System.Net.Http' 的引用。请确保它在全局程序集缓存中