0
votes

Is there an easy way to install the CommonServiceLocator nuget package to a .NET Standard 1.4 project in visual studio 2017?

Installing the nuget package fails with:

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.

1
The general consensus is that you shouldn't use CommonServiceLocator or any abstraction over DI containres at all. Read this and this.Steven

1 Answers

1
votes

NuGet packages that are compatible with a PCL can usually be used by using the PackageTargetFallback property in the csproj file like this:

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

Note that in .NET Standard 2.0 / .NET Core 2.0 tooling, this is changing to AssetTargetFallback but should no longer be necessary since .NET Standard and .NET Core 2.0 are automatically compatible with packages that work on .NET 4.6.1.