Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MvvmCross.Core/Platform 5.7.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'

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

[NuGet package warnings

like image 980
Santosh Avatar asked Jan 02 '23 13:01

Santosh


1 Answers

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.

VS 2017 - properties

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

VS 2019

like image 66
Plac3Hold3r Avatar answered Jan 05 '23 04:01

Plac3Hold3r