MvvmCross.Core/Platform 5.7.0' 使用 '.NETFramework,Version=v4.6.1' 而不是项目目标框架 '.NETStandard,Version=v2.0' 恢复 [英] MvvmCross.Core/Platform 5.7.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'

查看:137
本文介绍了MvvmCross.Core/Platform 5.7.0' 使用 '.NETFramework,Version=v4.6.1' 而不是项目目标框架 '.NETStandard,Version=v2.0' 恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用最新版本 MvvmCross 创建 Android 和 iOS 应用程序.现在,由于不推荐使用可移植类库,我使用 .NET Standard 库版本 2.0.

我在 MvvmCross 的 NuGet 包中有这个警告......虽然项目编译但我不确定是否需要像最后一行所说的那样担心

<块引用>

此软件包可能与您的项目不完全兼容.

以下是确切的警告

<块引用>

警告 NU1701:使用包MvvmCross.Core 5.7.0"恢复'.NETFramework,Version=v4.6.1' 而不是项目目标框架'.NETStandard,版本 = v2.0'.此软件包可能不完全兼容与您的项目.

MvvmCross.Platform 5.7.0 的类似警告

[

解决方案

As

结果将类似于您的 csproj 中的以下内容

<PackageReference Include="MvvmCross" Version="5.7.0" NoWarn="NU1701"/><PackageReference Include="MvvmCross.Core" Version="5.7.0" NoWarn="NU1701"/><PackageReference Include="MvvmCross.Binding" Version="5.7.0" NoWarn="NU1701"/><PackageReference Include="MvvmCross.Platform" Version="5.7.0" NoWarn="NU1701"/><PackageReference Include="MvvmCross.CodeAnalysis" Version="5.7.0" NoWarn="NU1701"/></项目组>

注意,使用每个包方法依赖包警告不会通过抑制父包来抑制.因此,您需要将包作为依赖项引入以抑制警告.

项目级别

NuGet 还为您提供了在项目级别取消所有 NU1701 警告的选项.您可以通过如下手动编辑 csproj 来完成此操作

<NoWarn>NU1701</NoWarn></PropertyGroup>

或者通过 GUI,您可以修改 Suppress warnings 以包含 NU1701

I'm creating an Android and iOS app using MvvmCross, the latest version. Now as the portable class library is deprecated I am using .NET Standard library version 2.0.

I have this warning in the NuGet package of MvvmCross .....though the project compiles but I am not sure if I need to worry about it as the last line says

This package may not be fully compatible with your project.

Below is the exact warning

warning NU1701: Package 'MvvmCross.Core 5.7.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.

Similar warning for MvvmCross.Platform 5.7.0

[

解决方案

As J.Dhaik has already mentioned MvvmCross version 5.7.0 has not been updated to support .NET Standard yet. The next major release version 6.0.0 will add support for .NET Standard 2.0.

Using MvvmCross versions prior to 6.0.0 inside of a .NET Standard class library is however possible.

So why the warning?

You can check out the explanation I gave on this Stack Overflow question for why you would see the warning. Extract below

With .NET Standard 2.0 and the updated tooling in .NET Core SDK 2+ the .NET team wanted to make it easier to update or make use of .NET Standard libraries. The issue is that not all NuGet packages have been updated to support a version of .NET Standard. So they introduced a fallback targeting .NET Framework 4.6.1 which is nearly 100% compliant with .NET Standard (There are some API that are in the .NET Standard 2.0 spec that are not in .NET Framework 4.6.1 but they can be brought in via NuGet packages if required). So the warning you see is to inform you that the packages do not conform to a .NET Standard version you are targeting and as such may contain API's that are not executable in your runtimes making use of your .NET Standard 2.0 library.

How to suppress the warnings

NuGet provides two options, per package or project level.

Per package

You can edit your csproj and add NoWarn="NU1701" tag to your package reference or select properties of your NuGet package refernce (Solution Explorer > Dependencies > NuGet > {The package name} right click Properties) and add NU1701 to the NoWarn property.

The result would be similiar to the following in your csproj

<ItemGroup>
  <PackageReference Include="MvvmCross" Version="5.7.0" NoWarn="NU1701" />
  <PackageReference Include="MvvmCross.Core" Version="5.7.0" NoWarn="NU1701" />
  <PackageReference Include="MvvmCross.Binding" Version="5.7.0" NoWarn="NU1701" />
  <PackageReference Include="MvvmCross.Platform" Version="5.7.0" NoWarn="NU1701" />
  <PackageReference Include="MvvmCross.CodeAnalysis" Version="5.7.0" NoWarn="NU1701" />
</ItemGroup> 

Note, with using the per package approach dependency package warnings are not suppressed by suppressing the parent package. So you would need to bring in the package as a dependency in order to suppress the warnings.

Project level

NuGet also gives you the option to suppress all NU1701 warnings at a project level. You can do this via manually editing the csproj as follows

<PropertyGroup>
  <NoWarn>NU1701</NoWarn>
</PropertyGroup>

Or via the GUI you could modify Suppress warnings to include NU1701

这篇关于MvvmCross.Core/Platform 5.7.0' 使用 '.NETFramework,Version=v4.6.1' 而不是项目目标框架 '.NETStandard,Version=v2.0' 恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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