简体   繁体   English

迁移的Visual Studio Project找不到NuGet包

[英]Migrated Visual Studio Project not finding NuGet packages

I am migrating an MVC ASP.NET Visual Studio 2010 project to Visual Studio 2019. 我正在将MVC ASP.NET Visual Studio 2010项目迁移到Visual Studio 2019。

The Visual Studio 2010 project uses some old jQuery NuGet packages that I can't update to current ones due to time constraints and the numerous changes through out the project that doesn't fit into my current scope. Visual Studio 2010项目使用了一些旧的jQuery NuGet软件包,由于时间限制以及整个项目中的许多变化,这些软件包无法适应当前范围,因此我无法将其更新为当前的jQuery NuGet软件包。

The migrated 2019 project shows a number of errors all relating to the NuGet packages: 迁移的2019项目显示了许多与NuGet软件包有关的错误:

NuGet Package restore failed for project MyWebProject: Unable to find version '3.2.0' of package 'Microsoft.jQuery.Unobtrusive.Ajax'.
  C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'Microsoft.jQuery.Unobtrusive.Ajax.3.2.0' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
  Please see Error List window for detailed warnings and errors.            

NuGet Package restore failed for project MyWebProject: Unable to find version '2.1.1' of package 'jQuery'.
  C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'jQuery.2.1.1' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
  Please see Error List window for detailed warnings and errors.        
...
...
...

In the Visual Studio 2019 project, when I view the NuGet Installed packages, I see the packages listed but with a message Not available in this source 在Visual Studio 2019项目中,当我查看NuGet已安装的程序包时,我看到列出的程序包,但有一条消息在此源中不可用

According to the error messages, Visual Studio is looking for the packages in C:\\Program Files(x86)\\Microsoft SDKs\\NuGetPackages ; 根据错误消息,Visual Studio在C:\\ Program Files(x86)\\ Microsoft SDKs \\ NuGetPackages中查找包 however it should be looking in a directory named "packages" that actually contains the packages. 但是,它应该在实际上包含软件包的名为“ packages”的目录中查找。

I have placed the packages directory within the same directory as the project (but it would be better to put them in a common resource directory so that the team can find them when/if they are working on this project). 我已经将packages目录放置在与项目相同的目录中(但最好将它们放在公共资源目录中,以便团队在/如果正在从事此项目时可以找到它们)。 I have also edited the repositories.config file within the packages directory to point to the packages.config file for the project. 我还编辑了packages目录中的repositories.config文件,以指向该项目的packages.config文件。

I can restore all of this back to default if required. 如果需要,我可以将所有这些恢复为默认值。

Nothing I have done has helped me get past this problem. 我所做的一切都没有帮助我克服这个问题。

How do I direct Visual Studio 2019 to use the packages that exist within a directory that is not the Program Files directory? 如何指示Visual Studio 2019使用非Program Files目录的目录中存在的包?

Thanks 谢谢

How do I direct Visual Studio 2019 to use the packages that exist within a directory that is not the Program Files directory? 如何指示Visual Studio 2019使用非Program Files目录的目录中存在的包?

According to your error message: Please go Tools=>Options=>Nuget Package Manager to check your settings about Package sources. 根据您的错误消息:请转到Tools=>Options=>Nuget Package Manager以检查有关Package Tools=>Options=>Nuget Package Manager的设置。

Maybe you haven't checked the nuget.org as your package sources. 也许您没有检查nuget.org作为软件包的来源。 Please check this settings: 请检查以下设置:

在此处输入图片说明

In VS, when you click the Restore Nuget Packages option, it will search the packages from available sources . 在VS中,当您单击Restore Nuget Packages选项时,它将from available sources搜索软件包。 Most of the time the package which we need to restore comes from Nuget Gallery . 大多数时候,我们需要还原的软件包来自Nuget Gallery Just like the JQuery 2.1.1 , so by default we will set nuget.org as our necessary package sources. 就像JQuery 2.1.1 ,默认情况下,我们将nuget.org设置为必要的包源。

I've checked if I uncheck the nuget.org then I got the same issue like yours. 我检查了是否取消选中nuget.org,然后遇到了与您相同的问题。

So please: 所以,请:

1.Check the nuget.org as your package sources, if it not exists, just click the green + to create a new sources and set its source as https://api.nuget.org/v3/index.json 1.检查nuget.org作为您的软件包源,如果不存在,只需单击绿色+创建一个新源并将其源设置为https://api.nuget.org/v3/index.json

2.If the nuget.org exists with checked status, make sure its link is correct In addition: 2.如果nuget.org存在选中状态,请确保其链接正确。

however it should be looking in a directory named "packages" that actually contains the packages. 但是,它应该在实际上包含软件包的名为“ packages”的目录中查找。

If the packages folder you mean is the one locates in Solution directory : In my opinion, Restore Nuget Package doesn't mean searching sources from the packages folder , instead it will search packages from available package sources and install them to packages folder if something is missing in the packages folder .(for packages.config format) 如果您指的是packages文件夹,则位于Solution directory :我认为, Restore Nuget Package并不意味着searching sources from the packages folder ,而是从available package sources搜索软件包并将它们安装到packages folder如果有的话) packages folder缺少。(用于packages.config格式)

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

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