【问题标题】:Failing to upgrade a WPF app from .Net Framework 4.8 to .Net Framework 4.8.1 due to Nuget error NU1201由于 Nuget 错误 NU1201,无法将 WPF 应用程序从 .Net Framework 4.8 升级到 .Net Framework 4.8.1
【发布时间】:2022-11-12 19:00:49
【问题描述】:

我有一个基于 .Net Framework 4.8 并使用 Windows Application Packaging Project 打包的 WPF 项目。当我尝试将其升级到 .Net Framework 4.8.1 以支持 ARM64 时,我在 Nuget 恢复期间收到 NU1201 错误。

NU1201:WpfApp7 项目与 uap10.0.18362(UAP,版本 = v10.0.18362)不兼容。项目 WpfApp7 支持:net481 (.NETFramework,Version=v4.8.1)

我试图将所有内容削减到最小的可重现回购here

有2个tags

  • netframework48
  • netframework481

它们的区别在于在项目属性视图中切换到“.Net Framework 4.8.1”:

netframework48 上,运行 nuget restore .\WpfApp7.sln 成功恢复包,而在 netframework481 上,相同的命令失败并显示以下错误消息。

> nuget restore .\WpfApp7.sln
MSBuild auto-detection: using msbuild version '17.3.1.41501' from 'd:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\bin'.
Assets file has not changed. Skipping assets file writing. Path: D:\Work\temp\WpfApp7\WpfApp7\obj\project.assets.json
Restored D:\Work\temp\WpfApp7\WpfApp7\WpfApp7.csproj (in 69 ms).
Restoring packages for D:\Work\temp\WpfApp7\WpfApp7.Package\WpfApp7.Package.wapproj...
NU1201: Project WpfApp7 is not compatible with uap10.0.18362 (UAP,Version=v10.0.18362). Project WpfApp7 supports: net481 (.NETFramework,Version=v4.8.1)
NU1201: Project WpfApp7 is not compatible with uap10.0.18362 (UAP,Version=v10.0.18362) / win10-arm. Project WpfApp7 supports: net481 (.NETFramework,Version=v4.8.1)
NU1201: Project WpfApp7 is not compatible with uap10.0.18362 (UAP,Version=v10.0.18362) / win10-arm-aot. Project WpfApp7 supports: net481 (.NETFramework,Version=v4.8.1)
NU1201: Project WpfApp7 is not compatible with uap10.0.18362 (UAP,Version=v10.0.18362) / win10-arm64-aot. Project WpfApp7 supports: net481 (.NETFramework,Version=v4.8.1)
NU1201: Project WpfApp7 is not compatible with uap10.0.18362 (UAP,Version=v10.0.18362) / win10-x64. Project WpfApp7 supports: net481 (.NETFramework,Version=v4.8.1)
NU1201: Project WpfApp7 is not compatible with uap10.0.18362 (UAP,Version=v10.0.18362) / win10-x64-aot. Project WpfApp7 supports: net481 (.NETFramework,Version=v4.8.1)
NU1201: Project WpfApp7 is not compatible with uap10.0.18362 (UAP,Version=v10.0.18362) / win10-x86. Project WpfApp7 supports: net481 (.NETFramework,Version=v4.8.1)
NU1201: Project WpfApp7 is not compatible with uap10.0.18362 (UAP,Version=v10.0.18362) / win10-x86-aot. Project WpfApp7 supports: net481 (.NETFramework,Version=v4.8.1)
Assets file has not changed. Skipping assets file writing. Path: D:\Work\temp\WpfApp7\WpfApp7.Package\obj\project.assets.json
Failed to restore D:\Work\temp\WpfApp7\WpfApp7.Package\WpfApp7.Package.wapproj (in 500 ms).

Errors in D:\Work\temp\WpfApp7\WpfApp7.Package\WpfApp7.Package.wapproj
    NU1201: Project WpfApp7 is not compatible with uap10.0.18362 (UAP,Version=v10.0.18362). Project WpfApp7 supports: net481 (.NETFramework,Version=v4.8.1)
    NU1201: Project WpfApp7 is not compatible with uap10.0.18362 (UAP,Version=v10.0.18362) / win10-arm. Project WpfApp7 supports: net481 (.NETFramework,Version=v4.8.1)
    NU1201: Project WpfApp7 is not compatible with uap10.0.18362 (UAP,Version=v10.0.18362) / win10-arm-aot. Project WpfApp7 supports: net481 (.NETFramework,Version=v4.8.1)
    NU1201: Project WpfApp7 is not compatible with uap10.0.18362 (UAP,Version=v10.0.18362) / win10-arm64-aot. Project WpfApp7 supports: net481 (.NETFramework,Version=v4.8.1)
    NU1201: Project WpfApp7 is not compatible with uap10.0.18362 (UAP,Version=v10.0.18362) / win10-x64. Project WpfApp7 supports: net481 (.NETFramework,Version=v4.8.1)
    NU1201: Project WpfApp7 is not compatible with uap10.0.18362 (UAP,Version=v10.0.18362) / win10-x64-aot. Project WpfApp7 supports: net481 (.NETFramework,Version=v4.8.1)
    NU1201: Project WpfApp7 is not compatible with uap10.0.18362 (UAP,Version=v10.0.18362) / win10-x86. Project WpfApp7 supports: net481 (.NETFramework,Version=v4.8.1)
    NU1201: Project WpfApp7 is not compatible with uap10.0.18362 (UAP,Version=v10.0.18362) / win10-x86-aot. Project WpfApp7 supports: net481 (.NETFramework,Version=v4.8.1)

NuGet Config files used:
    C:\Users\arieszhang\AppData\Roaming\NuGet\NuGet.Config
    C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config
    C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config

Feeds used:
    C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
    https://api.nuget.org/v3/index.json
1 of 2 projects are up-to-date for restore.

搜索了一圈,但仍然没有弄清楚这个错误的确切含义?以及如何解决这个问题?在我的项目中,既没有项目依赖项,也没有从 NetStandard 到 NetCoreApp 的依赖项,正如错误的 definition 所说。

我已经尝试了 WpfApp7.Package 属性中的每个 UWP 目标,但无论选择哪个最低版本,错误仍然存​​在,因此我假设 UWP 目标版本不太可能是原因。

同样的问题也在这里交叉发布:https://github.com/NuGet/Home/discussions/12206


2022 年 11 月 12 日更新: 在上面的 github 问题中有一个很好的答案。请在此处查看:https://github.com/NuGet/Home/discussions/12206#discussioncomment-4082656

【问题讨论】:

    标签: c# .net wpf nuget .net-4.8


    【解决方案1】:

    请在此处查看所有受支持的 .NET Framework 4.8.1 Windows 版本(在this blog post 中找到):

    Windows 客户端版本:Windows 11,Windows 10 版本 21H2、Windows 10 版本 21H1、Windows 10 版本 20H2

    因此,从那条信息来看,我会说 Windows 10 10.0.18362 aka Windows 10 版本 1903 对于 .NET Framework 4.8.1 来说太旧了。

    【讨论】:

    • 我也怀疑过,所以我尝试将最小目标 UWP 版本更改为最新的 Windows 11 22H2 (10.0.22621) 但仍然出现相同的错误(除了错误消息变为“Project WpfApp7 与uap10.0.22621不兼容”) .
    猜你喜欢
    • 1970-01-01
    • 2022-07-07
    • 2011-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多