Nugets install in visual studio 2015

29,800

Solution 1

Time has passed, but it is happening to me, and I have found that it has nothing to do with the framework version. The important text of the error message is: "...but the package does not contain any assembly references or content files...".

Indeed, my package does not have any visible content for Nuget: it has a non conventional folder with third party native libraries and a Install.ps1 that adds a post build event with a Xcopy command.

As an easy turnaround, just put a dummy file in the package Content folder or any other dummy content in lib, empty file node (not tried it), etc.

EDIT 29/5/2017

I am seeing that this answer is useful to others, and that is why I am going to elaborate a little more.

As I said, the problem is that Nuget don't see there is any content in the package, but it may have two causes:

  1. The package really does not have visible content because it moves the content with a script, etc. (as it was my case), and then it is necessary to create some dummy content as a workaround.

  2. There's a mistake in the specification of a package that must have content (as was the case of Evgeni Nabokov in the comments), and then you have to correct the specification to put things in place.

Sorry for my bad english.

Solution 2

The error message is saying you that there is no version of nuget for your framework version.

In VS2013 You probably create the project in 4.5.0 or 4.0.0 version of .Net framework.

Have you tried to change .Net version of your project to 4.5.2 ?

Solution 3

I had this issue when building my nuget packages in TeamCity, publishing them in local artifactory and then trying to use those packages in other projects.

In Order to avoid this issue - in TeamCity, BuildSteps ==> NuGet Pack ==> Package parameters ==> Specification files you have to select .csproj file over nuspec file and tick option "Prefer project files to .nuspec"

The package that build like that will be just fine to import and no more complaints from VS.

Solution 4

This might happen when the .NET standard of the solution and the corresponding NuGet package mismatch. Here is a table from this link:

╔════════════════════════════╦═══════════════════════════════════════════════════════════════╗
║ .NET Platform              ║ .NET Standard                                                 ║
╠════════════════════════════╬═══════╦═══════╦═══════╦═══════╦═══════╦═══════╦═══════╦═══════╣
║                            ║  1.0  ║  1.1  ║  1.2  ║  1.3  ║  1.4  ║  1.5  ║  1.6  ║  2.0  ║
╠════════════════════════════╬═══════╬═══════╬═══════╬═══════╬═══════╬═══════╬═══════╬═══════╣
║ .NET Core                  ║   →   ║   →   ║   →   ║   →   ║   →   ║   →   ║  1.0  ║ vNext ║
║ .NET Framework             ║   →   ║  4.5  ║ 4.5.1 ║  4.6  ║ 4.6.1 ║ 4.6.2 ║ vNext ║ 4.6.1 ║
║ Xamarin.iOS                ║   →   ║   →   ║   →   ║   →   ║   →   ║   →   ║   →   ║ vNext ║
║ Xamarin.Android            ║   →   ║   →   ║   →   ║   →   ║   →   ║   →   ║   →   ║ vNext ║
║ Universal Windows Platform ║   →   ║   →   ║   →   ║   →   ║ 10.0  ║   →   ║   →   ║ vNext ║
║ Windows                    ║   →   ║  8.0  ║  8.1  ║       ║       ║       ║       ║       ║
║ Windows Phone              ║   →   ║   →   ║  8.1  ║       ║       ║       ║       ║       ║
║ Windows Phone Silverlight  ║  8.0  ║       ║       ║       ║       ║       ║       ║       ║
╚════════════════════════════╩═══════╩═══════╩═══════╩═══════╩═══════╩═══════╩═══════╩═══════╝

You have to match both the framework and .NET standard version. I prefer .NET standard 1.4 and .NET Framework 4.6.1. By creating the .NET Standard, Microsoft is codifying the requirement of having consistent APIs across all .NET platforms. It seems like once you migrate your solutions to these level of compatibility, "incompatibility" or discovering the wheel again after each update will be a memory of the past.

Solution 5

I got this and it made no sense because I was already using it no problem on a framework 4.6 project and the error told me it wouldn't work on framework 4.6 which I knew to be untrue.

In the end I solved it by making another test project, copying the cs files etc from my old test project and then installing UnitTestFramework through NuGet. It works fine.

So something happens that only microsoft can solve I would guess but starting again seems to fix it.

Share:
29,800

Related videos on Youtube

ran
Author by

ran

Updated on September 12, 2020

Comments

  • ran
    ran over 3 years

    I try to install the nuget Microsoft.VisualStudio.QualityTools.UnitTestFramework in Visual Studio 2015 in simple project and got this message:

    Could not install package 'Microsoft.VisualStudio.QualityTools.UnitTestFramework 10.0.30319.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5.2', 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.

    But, when I try to install this package in Visual Studio 2013 in the same project this is work.

    How can I install this nuget in Visual Studio 2015?

  • ran
    ran over 8 years
    I changed .Net version of my project in visual studio 2013 to 4.5.2 and the install succeed. I also tried to change the .Net version in my project in visual studio 2015 to 4.5 and i still got this error.
  • Evgeni Nabokov
    Evgeni Nabokov over 7 years
    Yeah, I found the dlls in bin folder, not in lib. That was the reason.
  • derigel
    derigel about 7 years
    And for dummy file better to use special file marker (empty directory) _._.
  • SERWare
    SERWare about 7 years
    @derigel yes, it seems better, I'll try it. Thanks.
  • Dalibor
    Dalibor about 6 years
    How do you guys tamper with the package? I install it online through console by "Install-Package ", or by nuget manager. How can you possibly change the folders of the package you install?
  • SERWare
    SERWare almost 6 years
    @Dalibor I don't quite understand your question. Folders where libraries and other content is installed are specified before the package is generated and published with "nuget.exe", and those locations are independent of the package's install method. As long as you are the creator of the package, of course, if you are not the creator of the package you cannot "tamper" it at install time.
  • Dalibor
    Dalibor almost 6 years
    @SERWare, That was my point. If I had package installed, I could update its folders. However, if I cannot install a package from remote server, how could I rename folders of a package that I haven't installed yet, because I cannot install it.
  • dudeNumber4
    dudeNumber4 almost 6 years
    I am the author of internal package. @derigel , add such empty directory where? Adding it at the root of the folder containing package content doesn't work.