1
votes

I have a few nuget packages created and installed on my local Nuget Server. They work fine. I can install them no problem. But when I created another package and put it to the server the package install always fails with the error:

Could not install package ... 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.

The project is exactly the same: it uses the same framework version (4.5). I have created yet another package with the same settings and it works as expected. The project does not reference anything that require other frameworks. In fact all assemblies it uses are used in other packages too.

The nuspec is the same: the same target location as in other packages. I tried to include other framework versions and it did not help.

<file src="bin\Release\*.*" target="lib\net45\" />

I checked what's packed in the resulting nupkg. It has the dlls in lib/net45. I did not find any differences from other packages.

I am totally confused. Why are packages for very similar projects produce different results.

Is there any way to find out what causes the error: Install failed. Rolling back...

Victor

1
What nuget feed are you using? I had similiar problems with ProGet.Mariusz Jamro

1 Answers

0
votes

The error means "This project is .NET 4.5 and nuget package you're trying to install contains nothing for .NET 4.5". Looks like something is wrong. So first let's inspect the nuget package.

This line in *.nuspec file:

<file src="bin\Release\*.*" target="lib\net45\" />

means "copy everything from bin\Release and put in in lib\net45 directory inside of the nuget package archive". It doesn't check if the files in "bin\Release" were actually compiled against .NET 4.5. It doesn't check if there is anything in the "bin\Release" at all.

Step 1: You need to check in the project which contains code for your nuget package (NOT the project which uses it) that you're actually building it against .NET 4.5. You can for example check that the *.csproj contain line like that:

<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>

If it's ok run clean and build to make fresh dlls. Make sure you make use a "Release" configuration and not "Debug" by accident.

Step 2: In the project which is supposed to consume your nuget package check if the dll(s) made in step 1. are actually OK. You can add a reference to a dll manually bypassing nuget (References -> Add reference -> Browse and select dlls made in Step 1). If it will work that you know your dlls are OK and the problem lies in between - the nuget packaging.

Step 3: If Step 1 and Step 2 were ok check how you package and publish your nuget package and check your nuget feed. It's hard to tell without details about your specific environment, but there are many options:

  • Maybe your nuget feed rejects nuget publish command?
  • Maybe you're pushing wrong version number and consuming different version?
  • Maybe you're pushing pkg with version which already exists and the feed is not overwriting it.
  • Maybe your nuget feed is messing something with the pkg file?