NuGet没有丢失包 [英] NuGet not getting missing packages

查看:105
本文介绍了NuGet没有丢失包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VSS中具有以下项目结构

现在在 Visual Studio 2010 Pro 中: 我打开 Solution2 ,然后将 Library1添加为外部项目.

Library1引用了两个我通过NuGet获得的外部库.当我构建我的Solution2时,一切正常. 因此,我签入了所有项目.

问题: 当另一个开发人员从sourcesafe获取Solution2并进行构建时,它表示Library1缺少那些外部库dll.

尝试以下操作:

1: http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages

所以现在我在Solution2下有一个.nuget文件夹,它已签入.但这仍然没有带来dll.

我怀疑是在单独的解决方案中的Library1导致了此问题.

有什么想法如何通过NuGet自动获取丢失的包裹吗?

更新:
Xavier的建议有所帮助,这是他的两篇博客文章:

解决方案

在当前设置下,您应确保已在两个解决方案和 Solution2 应将nuget install命令指向Solution1\Packages输出目录.您的文件夹结构将如下所示:

原因:Library1.csproj引用指向Solution1 \ Packages位置.将此项目添加到Solution2时,项目引用不会更改,但是该解决方案会将软件包还原到Solution2 \ Packages中,而不是Solution1 \ Packages中.

如果您已经在Solution2的项目中安装了软件包,则需要确保这些软件包仍针对Solution2 \ Packages进行了还原.为此,我建议您在共享项目文件中设置一个MSBuild属性(在nuget.targets文件的导入语句上方),然后将此MSBuild属性值传递到RestoreCommand中. >

例如:

< PackagesOutDir> $(SolutionDir).. \ Libraries \ Packages</PackagesOutDir>

并调整nuget.targets文件,例如:

< PackagesOutDir Condition =''$(PackagesOutDir)==''''> $(SolutionDir)\ Packages</PackagesOutDir>

...

< RestoreCommand> ... -o``$(PackagesOutDir)"</RestoreCommand>


可选,如果要使用单个Packages文件夹,则可以修改两者 .nuget\NuGet.targets文件并为-o(或-OutputDirectory)开关设置nuget install命令.

将其附加到RestoreCommand元素:-o"$(SolutionDir .. \ Packages";将确保所有软件包在单个位置得到还原:

请注意,每次执行此操作后,每次安装NuGet软件包时,都必须手动更新已安装的软件包引用!

I have following project structure in VSS

Now in Visual Studio 2010 Pro: I open Solution2 and then add Library1 as external project.

Library1 is referencing two external libraries which I get via NuGet. When I build my Solution2 it all works fine. So I checked-in all my project.

Issue: When another developer gets the Solution2 from sourcesafe and builds, it says Library1 is missing those external libraries dlls.

Tried following:

1: http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages

So now I have .nuget folder under Solution2 which gets checked-in. But that's still not bringing the dlls.

My doubt is the Library1 being in a separate solution is causing this issue.

Any ideas how to get missing packages automatically via NuGet?

Update:
Xavier's suggestions helped and here are two of his blog posts:

解决方案

With your current setup, you should make sure you have enabled NuGet Package Restore on both solutions and the Solution2 nuget.targets should point the nuget install command to the Solution1\Packages outputdirectory. Your folder structure will look like this:

Reason: the Library1.csproj references are pointing to the Solution1\Packages location. When adding this project to Solution2, the project references are not changed, but the solution will restore the packages in Solution2\Packages instead of Solution1\Packages.

If you already have installed packages in the projects of Solution2, you'll need to make sure those still restore against Solution2\Packages. To do that, I'd recommend you to set an MSBuild property within the shared project files (above the import statement for the nuget.targets file) and pass this MSBuild property value into the RestoreCommand.

E.g.:

<PackagesOutDir>$(SolutionDir)..\Libraries\Packages</PackagesOutDir>

And adjust the nuget.targets file, e.g.:

<PackagesOutDir Condition="$(PackagesOutDir) == ''">$(SolutionDir)\Packages</PackagesOutDir>

...

<RestoreCommand>... -o "$(PackagesOutDir) "</RestoreCommand>


Optionally, If you want to use a single Packages folder, you could modify both .nuget\NuGet.targets files and set the -o (or -OutputDirectory) switch for the nuget install command.

Appending this to the RestoreCommand element: -o "$(SolutionDir..\Packages" will ensure all packages get restored in a single location:

Note that you will have to manually update the installed package references each time you install a NuGet package after doing this!

这篇关于NuGet没有丢失包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆