从.Net Framework 4.5升级到4.6.1后重新定位Nuget [英] Nuget re-targeting after upgrading from .Net Framework 4.5 to 4.6.1

查看:52
本文介绍了从.Net Framework 4.5升级到4.6.1后重新定位Nuget的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.net解决方案,其中包含大约30个项目,所有这些项目都针对.Net Framework 4.5.并且每个都至少引用3-4个NuGet程序包.

I have a .net solution with approx 30 projects, all of them targeting .Net Framework 4.5. and each referencing at least 3-4 NuGet packages.

我们现在需要将它们更新为.Net Framework 4.6.1.所以这是我需要知道的:

We now need to update them to .Net Framework 4.6.1. So here's what I need to know:

  1. 我是否还需要重新定位NuGet软件包,还是可以跳过,因为这将是就地"升级?
  2. 如果可以,我是否可以通过将每个NuGet软件包的targetFramework ="net45"替换为targetFramework ="net461"来更新每个项目的packages.config文件?我见过一些建议卸载的线程,然后通过"update-package"命令重新安装该软件包.我今天尝试了一下,但最终还是遇到了一些错误.

推荐答案

软件包不会自动重新定向,但是对此有一个自动修复程序.

The packages will not be retargeted automatically, but there is an automated fix for this.

在Package Manager控制台中,只需运行:

In Package Manager Console simply run:

Update-Package -Reinstall

这将迫使程序包管理器重新安装每个项目中的每个程序包(而不更改引用程序包的版本).

This will force the package manager to reinstall every package in every project (without changing the version of the referenced package).

在以新框架为目标之后通过重新安装软件包,这会将所有引用更改为正确的版本.

By reinstalling the packages after the new framework is targeted this changes all the references to the correct version.

您还可以使用:

Update-Package -Reinstall -ProjectName Project.Name.Here

我已经多次使用此技术来解决nuget参考问题.

I have used this technique many times to fix nuget reference issues.

这篇关于从.Net Framework 4.5升级到4.6.1后重新定位Nuget的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆