0

是否有一種簡單的方法將CommonServiceLocator nuget包安裝到Visual Studio 2017中的.NET Standard 1.4項目中?參考CommonServiceLocator .NET Standard 1.4上的Nuget

安裝NuGet包失敗:

包CommonServiceLocator 1.3.0不與 netstandard1.4(.NETStandard,版本= V1.4)兼容。軟件包 CommonServiceLocator 1.3.0支持:portable-net40 + sl5 + win8 + wp8 + wpa81 (.NETPortable,Version = v0.0,Profile = Profile328)一個或多個軟件包 與.NETStandard版本= v1.4不兼容。

+0

一般的共識是,你不應該使用CommonServiceLocator或任何關於DI包含的抽象。閱讀[this](http://blog.ploeh.dk/2011/07/28/CompositionRoot/)和[this](http://blog.ploeh.dk/2014/05/19/di-friendly-library /)。 – Steven

回答

1

的NuGet包是與PCL兼容,通常可以通過在文件的csproj像這樣使用PackageTargetFallback property使用:

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

注意,在.NET 2.0標準/ .NET 2.0的核心工具,這將更改爲AssetTargetFallback,但應該不再需要,因爲.NET Standard和.NET Core 2.0會自動與.NET 4.6.1上的軟件包兼容。