Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget package installation failure

Tags:

.net

nuget

When trying to install a package from our newly created private Nuget Feed i get the following error.

Could not install package 'GC.Timecode 1.0.0.3'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5.1', but the package does not contain any assembly references or content files that are compatible with that framework.

The Nuget package also targets 4.5.1. (Screenshot take from Nuget Package Explorer)

The Nuget Package is created by Octopack via On premises TFS, and then published to a private Proget Server

enter image description here

Nuspec file looks like this

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>GC.Timecode</id>
<version>1.0.0.3</version>
<authors>user</authors>
<owners>user</owners>
<licenseUrl>http://example.com</licenseUrl>
<projectUrl>http://example.com</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>The GC.Timecode deployment package, built on 25/01/2016</description>
<releaseNotes />
</metadata>
</package>

Contents of Package

enter image description here

What's going on here?

like image 729
MrBliz Avatar asked Jan 25 '16 11:01

MrBliz


People also ask

How do I force a NuGet package to Install?

Switch to the Browse tab, search for the package name, select it, then select Install). For all packages, delete the package folder, then run nuget install . For a single package, delete the package folder and use nuget install <id> to reinstall the same one.

How do I Install NuGet packages missing?

Enable package restore by choosing Tools > Options > NuGet Package Manager. Under Package Restore options, select Allow NuGet to download missing packages. In Solution Explorer, right click the solution and select Restore NuGet Packages.


2 Answers

Slippery Pete fixed this problem for me.

The first time I tried to install my Assembly I got:

Could not install package 'Package Name'. You are trying to install this >package into a project that targets '.NETFramework,Version=v4.6.1', but the >package does not contain any assembly references or content files that are >compatible with that framework. For more information, contact the package >author.

After ensuring my Assembly within the Nuget package was in the 'lib\net45' folder, I still got the error!

However after going to Tools->Options->Nuget->General and clearing the cache, the problem was solved.

like image 164
Tim Hobbs Avatar answered Oct 18 '22 20:10

Tim Hobbs


Make sure your nuspec file contains a 'lib/net45' target

<package>
  <metadata>
    ...
  </metadata>
  <files>
    <file src="bin\Release\*.*" target="lib/net45" />
  </files>
</package>
like image 31
Kris Avatar answered Oct 18 '22 20:10

Kris