26
votes

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?

7

7 Answers

18
votes

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.

11
votes

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 ?

2
votes

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.

2
votes

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.

1
votes

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.

0
votes

It seems that creating a "Unit Test Project" instead of "Class Library" solves the problem. I fighted with the "Class Library" with no luck, but removing that project an creating a new one from the "Unit Test Project" template became with the Microsoft.VisualStudio.QualityTools.UnitTestFramework version 10.0.0.0 installed.

0
votes

I found that the DynamicInterop.0.8.1.nupkg has the dll file in a folder 'lib\netstandard1.2'. I just changed the folder name to lib\net40 and the package would install ok (I.m using VS2013). Also: the .nupkg is just a .zip file, so any zip tool lets you manipulate the contents.