本教程演示如何把WPF程序从 <TargetFrameworkVersion>v4.8 </TargetFrameworkVersion>升级到<TargetFramework>net8.0-windows</TargetFramework>.
下载并安装.NET Upgrade Assistant - Visual Studio Marketplace
Supported .NET upgrades:
- .NET Framework to .NET 6+ (including .NET 9.0 Preview)
- .NET Core to .NET 6+ (including .NET 9.0 Preview)
- Any .NET version to .NET 6+ (including .NET 9.0 Preview) that is higher than the current version
- Azure Functions v1, v2, v3 to v4 isolated (targeting net6.0 or net7.0)
- Xamarin.Forms to MAUI
- Note: For Xamarin->MAUI .xaml file transformations the Upgrade Assistant includes basic namespace replacements. More comprehensive .xaml file transformations require Visual Studio 17.6.
Supported project types:
- ASP.NET
- Azure Functions
- WPF
- WinForms
- Class libraries
- Console
- Xamarin.Forms
- .NET MAUI
- UWP
Coming soon:
- WCF to WCF Core upgrade
以上更新信息可在.NET Upgrade Assistant - Visual Studio Marketplace中获取到。
安装过程会默认勾选已安装的Visual Studio版本,我本机用的vs2022 Community版本。
安装成功后,打开你的项目,右击选择项目进行升级。
具体步骤如下图所示:
建议更新到LTS版本。
需要一个项目一个项目的升级,升级完成后如果出现引用错误,可重新添加项目间的引用,然后Clean下Solution,rebuild即可。
PS:Upgrade总共有三种方式,可根据自己项目情况进行选择。默认推荐In-place project upgrade。