简体   繁体   English

成功的Nuget包恢复后项目不知道包

[英]Project Not Aware Of Packages After Successful Nuget Package Restore

I am working on a large C# project with other team members. 我正在与其他团队成员一起开展一个大型C#项目。 So far the project has been kind of disorganized and every one has had their way of getting their environment up and running for development. 到目前为止,该项目一直处于混乱状态,每个人都有自己的方式来开发和运行开发。 For a new member (and future ones) I am trying to document and tighten up our development process. 对于新成员(以及未来的成员),我正在努力记录并加强我们的开发过程。 The project is version controlled by git and members are using VS2012, VS2015, and Monodevelop. 该项目由git控制,成员使用VS2012,VS2015和Monodevelop。

The C# projects in our C# solution all have NuGet packages they require. 我们的C#解决方案中的C#项目都有他们需要的NuGet包。 I have in the .gitignore file the following: 我在.gitignore文件中有以下内容:

# NuGet Packages
*.nupkg
# Ignore the actual packages but not the config file for them
**/packages/**/*
!**/packages/repositories.config
# don't ignore build/, which is used as an MSBuild target.
!**/packages/build/

So when I push from one machine and then clone on the other, I do have a solution with projects contained with in. These projects have packages.config files, which is the xml file that contains the name of packages and versions needed. 因此,当我从一台机器上推出然后克隆另一台机器时,我确实有一个包含在其中的项目的解决方案。这些项目有packages.config文件,这是包含所需包和名称的xml文件。

Here Is Where My Problem Is 这是我的问题所在

I tried on a fresh Windows 7 Machine with VS2015 Community Edition to clone the repo, which worked fine. 我试用了一台带有VS2015 Community Edition的全新Windows 7机器来克隆repo,它运行良好。 Then there was a prompt to restore the NuGet packages. 然后提示恢复NuGet包。 I did that. 我做到了 I can see that the packages and versions are installed with the NuGet package manager view for the project of interest: 我可以看到包和版本随感兴趣的项目的NuGet包管理器视图一起安装: 在此输入图像描述 But in my References of my project they do not appear to be installed: 但在我的项目参考中,它们似乎没有安装: 在此输入图像描述

Tried to isolate the problem with a smaller project 试图用较小的项目来解决问题

I thought maybe this was odd so I closed the solution and started a new small solution with one small console application project. 我想也许这很奇怪所以我关闭了解决方案,并开始了一个新的小解决方案与一个小型控制台应用程序项目。 I added an old version of NUnit to this project and verified that the NuGet package was installed into the pakcages directory. 我在此项目中添加了旧版本的NUnit,并验证了NuGet包已安装到pakcages目录中。 Then I closed the solution, and deleted the packages directory. 然后我关闭了解决方案,并删除了packages目录。 When I opened the solution it realized that the package was not there so I tried to do the restore packages action through the right click on the package menu. 当我打开解决方案时,它意识到包不在那里所以我尝试通过右键单击包菜单来执行恢复包操作。 This worked just fine. 这很好用。

So I think I must have some other configuration in my big C# project messed up. 所以我认为我的大C#项目中必须有其他一些配置搞砸了。 I don't know if it is installing the packages somewhere else on my system. 我不知道它是否在我的系统上的其他地方安装软件包。 Any pointers on where to look or what configurations to look at would be helpful and appreciated! 任何关于在哪里查看或查看哪些配置的指针都会有所帮助和赞赏!

(I have not seen this issue else where, where the package is apparently installed but the project is still unaware of it) (我还没有看到这个问题,在哪里,显然安装了包但项目仍然没有意识到它)

Update 7/28/2016 I was having a look at the nuget.config file for the solution and it appears that there was a line in there: 更新7/28/2016我正在查看解决方案的nuget.config文件,看起来那里有一条线:

<add key="repositorypath" value="External\Packages" />

Then I found a directory in the same level as my solution file named External Packages . 然后我找到了一个与我的名为External Packages解决方案文件相同级别的目录。 I'd like to note that the person who originally set this solution and its projects up is no longer around. 我想要注意的是,最初设置此解决方案及其项目的人已经不在了。 So I deleted that directory and the nuget.config file. 所以我删除了该目录和nuget.config文件。 I restarted VS2015 and ran the restore NuGet Packages action. 我重新启动了VS2015并运行了恢复NuGet Packages操作。 This appeared to restore the packages and made a directory called packages where they are stored now. 这似乎恢复了包并创建了一个名为packages的目录,它们现在存储在这些目录中。 This now mimicks what I was seeing in my small project where I tried to recreate this behavior. 这现在模仿我在我试图重新创建此行为的小项目中看到的内容。

But I am still running into the issue where the NuGet Package Manager says the packages are installed but the 'References' do not show them. 但我仍然遇到NuGet包管理器说安装包但“参考”没有显示它们的问题。

So I am wondering is there a way to config VS to look where these packages are stored for the references? 所以我想知道有没有办法配置VS来查看这些包存储的参考?

@RoberHarvey had the right solution. @RoberHarvey有正确的解决方案。 The problem was in the .csproj files for the projects in my solution. 问题出在我解决方案中项目的.csproj文件中。 This was all part of a code base that never really had a good way of keeping track of packages and there were failed attempts in the past to fix it. 这是代码库的一部分,从来没有真正有一个很好的方法来跟踪包,并且过去没有尝试修复它。 So there were some inconsistencies persisting in my project files. 因此,我的项目文件中存在一些不一致的问题。 This was remedied by uninstalling and reinstalling the problem packages after deleting the old nuget.config file. 通过在删除旧的nuget.config文件后卸载并重新安装问题包来解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM