Upgrading to .NET Core 2.0: PackageTargetFallback and AssetTargetFallback cannot be used together
Solution 1:
In .NET Core 1.0 and 1.1, it was needed to set PackageTargetFallback
when referencing packages that are known to work on .NET Core but don't officially support it - e.g. PCL libraries or libraries built for the legacy dotnet
framework moniker.
Due to this, the project (.csproj
, .fsproj
, ...) will contain a line similar to:
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
In most cases, this line can simply be removed and the project should build because .NET Core 2.0 already defines AssetTargetFallback
to be net461
- meaning that any NuGet package that is compatible with .NET Framework 4.6.1 or higher can be used without additional configuration.
If this introduces more build / restore errors, change the line to:
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
The reason for the change is that PackageTargetFallback
is considered deprecated and should be replaced with AssetTargetFallback
which behaves only slightly different.
The breaking change in the tooling is that netcoreapp2.0
and netstandard2.0
automatically set AssetTargetFallback
which conflicts with any PackageTargetFallback
value defined in the project file.