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

查看:10
本文介绍了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 的建议有所帮助,以下是他的两篇博文:

解决方案

使用您当前的设置,您应该确保在两个解决方案和解决方案2 nuget.targets 应该将 nuget install 命令指向 Solution1Packages 输出目录.您的文件夹结构将如下所示:

原因:Library1.csproj 引用指向 Solution1Packages 位置.将此项目添加到Solution2时,项目引用没有改变,但解决方案将恢复Solution2Packages而不是Solution1Packages中的包.

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

例如:

<块引用>

<PackagesOutDir>$(SolutionDir)..LibrariesPackages</PackagesOutDir>

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

<块引用>

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

...

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


可选,如果您想使用单个 Packages 文件夹,您可以修改 both .nugetNuGet.targets 文件并设置nuget install 命令的 -o(或 -OutputDirectory)开关.

将此附加到 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 Solution1Packages outputdirectory. Your folder structure will look like this:

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

If you already have installed packages in the projects of Solution2, you'll need to make sure those still restore against Solution2Packages. 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)..LibrariesPackages</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 .nugetNuGet.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天全站免登陆