Sir Crispalot
Sir Crispalot

Reputation: 4844

Why can't I install a NuGet package which has target framework profile of 136?

I am trying to install Humanizer (see also GitHub and NuGet Gallery pages) using the NuGet package manager inside Visual Studio 2010. The documentation suggests it should support .NET 4+.

Issuing the following command on a brand new empty MVC4 project:

PM> install-package Humanizer

Gives me the following result:

Successfully installed 'Humanizer 1.26.1'.
Successfully uninstalled 'Humanizer 1.26.1'.
Install failed. Rolling back...
Install-Package : Could not install package 'Humanizer 1.26.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references that are compatible with that framework. For more information, contact the package author.
At line:1 char:16
+ install-package <<<< Humanizer
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

PM>

I contacted the author directly (and subsequently raised an issue on GitHub). He mentioned that the package targets Profile136 (can also be seen in the csproj file) which should support .NET 4:

<TargetFrameworkProfile>Profile136</TargetFrameworkProfile>

I had a look around and read this SO question which discusses building portable class libraries. Having read that, I discovered that Visual Studio 2010 requires an add-in to enable building of PCLs.

I realise I'm not building here, but I installed it anyway, along with the updated reference assemblies v4.6.

Having looked in the following folder:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0\Profile

I discovered that I only have profiles up to 131, but no 136.

An answer to the SO question mentioned earlier suggests that 136 was added in the Windows Phone SDK 8.0. However I can't install this on Windows 7.

Why can't I install this package in Visual Studio 2010? Is it because I don't have profile 136 on my machine, or is that only required for building PCLs?

Note that I have installed other NuGet packages successfully, e.g. log4net.

Upvotes: 0

Views: 1858

Answers (1)

Matt Ward
Matt Ward

Reputation: 47907

You should not need to have the Portable Class Libraries installed to add the Humanizer NuGet package to a project that targets .NET 4.0.

The Profile 136 is in the Portable v4.6 reference assemblies. To install this you need to unzip the zip file that the installer installs. However you should not need to have any PCLs installed.

As a test I renamed the .NETPortable library directory so NuGet did not detect the portable libraries. Then with an empty ASP.NET MVC 4 project I could add a reference to Humanizer in Visual Studio 2010.

If you have a recent version of NuGet installed then it should work.

Upvotes: 2

Related Questions