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

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

问题描述

我有一个包含大约 30 个项目的 .net 解决方案,所有项目都针对 .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 文件?我已经看到一些线程建议卸载然后通过更新包"命令重新安装包.我今天试过了,但最终出现了一些错误.

推荐答案

包不会自动重定向,但有一个自动修复.

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

在包管理器控制台中只需运行:

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.

您也可以使用以下命令针对单个项目运行此程序:

You may also run this against a single project with :

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天全站免登陆