简体   繁体   English

package.config更新不会更新引用

[英]package.config update does not update the references

I have multiple projects referencing the same NuGet Package. 我有多个项目引用相同的NuGet包。 When I got latest code, I realized that one of the projects had an updated package.config and also updated reference to the Dll that is provided by that package. 当我得到最新的代码时,我意识到其中一个项目有一个更新的package.config,并且还更新了对该包提供的Dll的引用。

Now, I also updated package.config on other prjects hoping the as soon as I do an upgrade on that NuGet engine will see that and fetch me new DLLs. 现在,我还在其他项目上更新了package.config,希望一旦我对NuGet引擎进行升级,就会看到并获取新的DLL。 Well, it did not happen. 好吧,它没有发生。 After that I tried following things and none of them worked: 在那之后,我尝试了一些事情,但没有一个工作:

  1. Deleting the old version of DLL and then doing Restore package 删除旧版本的DLL,然后执行还原包
  2. Deleting the packages folder, restarting my VS 2015 and restoring the package 删除packages文件夹,重新启动我的VS 2015并恢复软件包

Also, funny thing is that when I go to Manage Nuget Packages and look at the package for which I need new DLL, it shows that it is already at new version and I do not need to upgrade it. 另外,有趣的是,当我去管理Nuget Packages并查看我需要新DLL的包时,它表明它已经是新版本,我不需要升级它。

Is there any ways I can get NuGet engine to upgrade these packages? 有什么方法可以让NuGet引擎升级这些包吗?

Just editing the packages.config file will not cause Visual Studio to make any changes to your project. 只编辑packages.config文件不会导致Visual Studio对项目进行任何更改。 Also NuGet restore does not modify your project. NuGet还原也不会修改您的项目。 NuGet restore just downloads the NuGet packages and makes them available for your project. NuGet恢复只是下载NuGet包并使它们可用于您的项目。

Instead of editing the packages.config file I would just use the NuGet Package Manager in Visual Studio, or the Package Management Console, to update the NuGet package in the projects required. 我只是使用Visual Studio中的NuGet包管理器或包管理控制台来更新所需项目中的NuGet包,而不是编辑packages.config文件。

Other alternatives include updating the project files (.csproj) to use the correct updated assembly references. 其他替代方法包括更新项目文件(.csproj)以使用正确的更新程序集引用。 Or you can run an Update-Package -reinstall to force the NuGet packages to be uninstalled and installed again in the projects. 或者,您可以运行Update-Package -reinstall以强制卸载NuGet包并在项目中再次安装。 That will fix the assembly references. 这将修复程序集引用。

If your solution can be opened by Visual Studio 2017, I suggest to use the latest PackageReference to manage nuget. 如果您的解决方案可以由Visual Studio 2017打开,我建议使用最新的PackageReference来管理nuget。 Packages.config has several drawbacks and PackageReference solve these problems. Packages.config有几个缺点,PackageReference解决了这些问题。

Here's the solution to migrate to PackageReference: https://github.com/NuGet/Home/wiki/Packages.config-to-PackageReference-Migrator 以下是迁移到PackageReference的解决方案: https//github.com/NuGet/Home/wiki/Packages.config-to-PackageReference-Migrator

Also, you can this use this vs extension: https://marketplace.visualstudio.com/items?itemName=TaylorSouthwickMSFT.NuGetPackagetoProjectjsonConverter 此外,您可以使用此扩展名: https//marketplace.visualstudio.com/items?itemName = TaylorSouthwickMSFT.NuGetPackagetoProjectjsonConverter

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

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