.NET Standard 1.4 上的参考 CommonServiceLocator Nuget

Reference CommonServiceLocator Nuget on .NET Standard 1.4

在 visual studio 2017 年,是否有将 CommonServiceLocator nuget 包安装到 .NET Standard 1.4 项目的简便方法?

安装 nuget 包失败:

Package CommonServiceLocator 1.3.0 is not compatible with netstandard1.4 (.NETStandard,Version=v1.4). Package CommonServiceLocator 1.3.0 supports: portable-net40+sl5+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile328) One or more packages are incompatible with .NETStandard,Version=v1.4.

与 PCL 兼容的 NuGet 包通常可以通过在 csproj 文件中使用 PackageTargetFallback property 来使用,如下所示:

<PropertyGroup>
  <PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wpa81+wp8</PackageTargetFallback>
</PropertyGroup>

请注意,在 .NET Standard 2.0 / .NET Core 2.0 工具中,这将更改为 AssetTargetFallback 但不再需要,因为 .NET Standard 和 .NET Core 2.0 自动与可用的包兼容在 .NET 4.6.1 上。