我有以下设置:
- nuget.exe 版本:1.6.21205.9031
- 项目 A.csproj 打包到 A.1.0.0.0.nupkg 中,并发布到本地 IIS 上托管的本地包存储库(我的 VS Nuget 扩展我能够添加A-package 到新项目)
- 项目 B.csproj 依赖于我使用 VS Nuget 扩展添加的 A-package
现在,当我
nuget spec
运行B.nuspec 已创建。
然后我运行,
nuget pack B.csproj -verbose
但在创建的 B 包中,它们不依赖于 A 包。 nuget pack 命令告诉我它已找到 packages.config 文件(其中包含对 A 包的依赖项),但随后它显示“依赖项:无”。
我缺少什么?问题可能是 A 包只能在我的本地包存储库中找到吗?我怎样才能让 nuget.exe 知道这个本地存储库?
多谢!
i have the following setting:
- nuget.exe Version: 1.6.21205.9031
- Project A.csproj packaged into A.1.0.0.0.nupkg, and published to a LOCAL package repository hosted on my local IIS (My VS Nuget Extension i able to add the A-package to a new project)
- Project B.csproj has a dependency to the A-package that i added with the VS Nuget Extension
Now, when i run
nuget spec
the B.nuspec is created.
Then i run
nuget pack B.csproj -verbose
but in the created B-package, their is NO dependency to the A-package. The nuget pack command tells me that it has found the packages.config file (which contains the dependency to the A-package), but then it says "Dependencies: None".
What am i missing? Could the problem be that the A-package can only be found in my local package repository? How can i make nuget.exe aware of this local repository?
Thanks a lot!
发布评论
评论(5)
nuget pack
需要能够找到packages
文件夹才能解决依赖关系(请参阅http://nuget.codeplex.com/workitem/3097),或者与 .csproj 位于同一文件夹中(只要在其上一级有一个.sln
文件) )或在一个NuGet.Config
中指定的文件夹。nuget pack
needs to be able to find thepackages
folder in order to resolve dependencies (see http://nuget.codeplex.com/workitem/3097), either in the same folder as the .csproj (as long as there's a.sln
file one level above it) or in a folder specified inNuGet.Config
.我想我可能已经弄清楚了......
我们的库解决方案打开了 Nuget Package Restore。我关闭了 NuGet Package Restore,之后在创建 NuGet 包时包含了项目依赖项。
我不太确定为什么当打开包还原时依赖项没有包含在包中,但是哦,好吧:)。
I think I may have figured this out...
Our library solution had Nuget Package Restore turned on. I turned off NuGet Package Restore, and after that the project dependences were included when I created the NuGet packages.
I'm not really sure why the dependencies were not included in the package when Package Restore was turned on, but oh well :).
“
Nuget.exe spec A.csproj
”将创建一个非常薄的 NuSpec 文件,该文件不会有任何依赖项。对于我们的流程,使用 powershell 脚本将项目引用和其他依赖项从项目的packages.config
添加到B.nuspec< 中的
节点/代码>。'
Nuget.exe pack A.nuspec
' 将是正确的。'
Nuget.exe spec A.csproj
' will create a very thin NuSpec file which won't have any dependencies. For our process use a powershell script to add the Project References and other dependencies from the project'spackages.config
to the<dependency>
node inB.nuspec
.'
Nuget.exe pack A.nuspec
' will then be correct.此处提出了类似的问题,答案解释说:
这些的原因导致问题的原因是 NuGet 会查找解决方案级别包文件夹来决定引入哪些包依赖项(不太确定如何做出此决定)。如果该包文件夹的路径不正确(如果 NuGet 使用错误的解决方案文件就会出现这种情况),则它无法正确解析依赖项。另外如果packages文件夹为空,也无法正确解析依赖关系。
我遇到了同样的问题,并将解决方案文件添加到项目文件夹(以前没有解决方案)帮助我解决了问题。
Similar question was asked here, and the answer explains that:
The reason why these were causing problems is because NuGet looks for the solution level packages folder to decide which package dependencies to pull in (not quite sure how this determination is made). If the path to that packages folder is incorrect (as it would be if NuGet uses the wrong solution file), then it can't resolve the dependencies correctly. In addition if the packages folder is empty, it also cannot resolve the dependencies correctly.
I had the same problem and adding solution file to project folder (previously without solution) helped me to resolve the issue.
我缺少依赖项,因为我在
packages
文件夹中没有我使用的所有包的*.nupkg
文件。这很难追踪,因为
nuget pack
的输出看起来正在工作:我一直在使用 GitHub 的 Visual Studio
.gitignore
并且只注释掉了关于“Package Restore”的一行(因为我想提交我的包),但我应该注释掉 二。它应该看起来像这样:感谢 Rick Mohr 的回答链接到 CodePlex 工作项 3097,其中 feiling 解释了如何使用
packages
文件夹:feiling 引用的依赖信息位于
*.nupkg
文件内。更改.gitignore
并提交所有缺失的*.nupkg
文件后,我的 TeamCity 构建服务器就能够成功创建具有正确依赖项的 NuGet 包。The dependencies were missing for me because I didn't have the
*.nupkg
files in thepackages
folder for all the packages I was using.This was pretty hard to track down, because the output of
nuget pack
looked like it was working:I had been using GitHub's Visual Studio
.gitignore
and only commented out the one line about "Package Restore" (because I wanted to commit my packages), but I should have commented out two. It should look like this:Thanks to Rick Mohr's answer for linking to the CodePlex work item 3097, where feiling explains how the
packages
folder is used:The dependency information that feiling refers to is inside the
*.nupkg
files. Once I changed the.gitignore
and committed all the missing*.nupkg
files, my TeamCity build server was able to successfully create my NuGet package with the correct dependencies.