Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not install package '--'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5'

I created this package, I need it in a project but couldn't install it, this error appears:

Could not install package 'Mshwf.NiceLinq 1.0.9'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5', 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

I don't know why this happen, in another project (Console) I changed the framework to 4.6 and other versions and it wasn't a problem, but this only happen in this project (MVC and Web API):

this is the nuspec file:

<?xml version="1.0"?> <package >   <metadata>     <id>Mshwf.NiceLinq</id>     <version>1.0.9</version>     <title>Nice LINQ</title>     <authors>MShawaf</authors>     <owners>Mshawaf</owners>     <projectUrl>https://github.com/mshwf/NiceLinq</projectUrl>     <iconUrl>https://raw.githubusercontent.com/mshwf/NiceLinq/master/logo.png</iconUrl>     <requireLicenseAcceptance>false</requireLicenseAcceptance>     <description>See it as: WHERE ID IN (1, 2, 3, 7, 9, 22, 30, 101)</description>     <releaseNotes>Minor changes.</releaseNotes>     <copyright>Copyright 2016</copyright>     <tags>LINQ IEnumerable Where Contains Search Filter</tags>   </metadata> </package> 
like image 221
mshwf Avatar asked Feb 04 '17 10:02

mshwf


People also ask

How do I install project packages?

Quickly find and install a packageOpen your project or solution in Visual Studio, and select Tools > NuGet Package Manager > Package Manager Console to open the Package Manager Console window. In the console, enter Find-Package with a keyword to find the package you want to install.

What is package config Targetframework?

packages. config: The targetframework attribute of a dependency specifies the variant of a package to install.


1 Answers

Your package targets NETFramework,Version=v4.5.2. That means the assembly folder is lib\net452. You are trying to install the package to a higher framework (greater than 4.5) project. Create a project with framework 4.5.2 or rename the package's lib folder from net452 to the version which you want to target like net45 or net46.

You can target multiple framework too from a single package.

Edit your csproj file like this:

<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>

Refer here: https://docs.microsoft.com/en-us/nuget/create-packages/supporting-multiple-target-frameworks

For a complete, up-to-date list of target framework names, refer to https://docs.microsoft.com/en-us/nuget/reference/target-frameworks#supported-frameworks

like image 112
Mathivanan KP Avatar answered Oct 02 '22 16:10

Mathivanan KP