问题
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
[
回答1:
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
回答2:
This error message is easy, it meanns that MvvmCross has not been updated to net.standard yet.
This will be a common error with nuggets until Net.Standard becomes widely adapted. However there is a solution in this case.
https://www.mvvmcross.com/documentation/getting-started/netstandard
When using .NET Standard 2 you do not need to specify a package target fallback. In .NET Standard 2 the PackageTargetFallback flag has been deprecated and instead defaults to net461 (.NET Framework 4.6.1) or higher. If however, this does not suit your use case you can override this behaviour with the AssetTargetFallback.
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
来源:https://stackoverflow.com/questions/49688230/mvvmcross-core-platform-5-7-0-was-restored-using-netframework-version-v4-6-1