我刚刚在一台新机器上创建了一个工作区,从TFS获取了我们项目的最新信息,启用了NuGet恢复,并得到了以下输出:
1>------ Rebuild All started: Project: Caching, Configuration: Debug Any CPU ------
1> Restoring NuGet packages...
1> To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages'.
1> All packages listed in packages.config are already installed.
1> Caching Framework -> C:\MyProjLocation\Caching\bin\Debug\Caching.dll
2>------ Rebuild All started: Project: Library, Configuration: Debug Any CPU ------
2>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1635,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "LumenWorks.Framework.IO". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
2>C:\MyProjLocation\Library\SomeClass.cs(2,7,2,17): error CS0246: The type or namespace name 'LumenWorks' could not be found (are you missing a using directive or an assembly reference?)
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========
没有恢复任何NuGet包(有超过10个-出于可读性的考虑,我从上面的输出中删除了它们)。
看起来NuGet甚至没有尝试恢复第二个项目(库)的包。
我已经尝试将NuGet目标导入移动到Library.csproj
文件as mentioned here中的CSharp目标导入下,但仍然不起作用:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
我在Visual Studio2013上运行最新版本的NuGet (2.7.41101.371)。
编辑: packages.config
存在,并且NuGet包管理器用正确的包标记了库项目。
发布于 2014-01-04 05:38:20
你也从磁盘上删除了NuGet.targets文件吗?
如果NuGet.targets文件在那里,Visual Studio / NuGet.exe将尝试执行MSBuild包还原。
有关详细信息,请参阅this doc。
发布于 2015-05-07 02:33:24
在NuGet恢复丢失的包之前,我必须进入源代码控制并删除packages文件夹中的所有文件(repositories.config除外)。这个想法是使用包还原,而不是将包签入到源代码控制中。如果它在源代码管理中看到这些包,就不会下载它们。
发布于 2016-03-23 17:57:19
我也有同样的问题,也在本地机器上。尽管Package Manager Console和nuget.exe restore MySolution.sln
都报告说一切都已安装,但在解决方案目录中找不到packages
文件夹,也没有解析对包的引用。
我检查了所有项目文件,他们希望包放在..\packages
文件夹中,这与解决方案文件本身所在的文件夹相同。
我让它工作的方式是运行:
nuget.exe restore MySolution.sln -PackagesDirectory packages
这将强制nuget.exe将所有包下载到指定的文件夹,并恢复所有引用。
请记住,从NuGet 2.7开始,目标文件不受支持,msbuild假设使用一些集成的方式来恢复包,但它经常失败。
事实上,对于我自己的工作,我更喜欢使用Paket,当你习惯它的时候,它总是工作。它还支持目标文件和创建NuGet包的好方法。
https://stackoverflow.com/questions/20761322
复制相似问题