Search code examples
.netvisual-studio-2015nugetoctopack

Nuget 3 - Octopack - Wrong Framework Target error


I'm getting mad trying to solve this one. My environment:

  • VS2015
  • Nuget extension 3.3.0.167
  • Octopack package 3.0.45.

When I run the following command below, the package is correctly generated:

 v4.0.30319\msbuild PackagingTest.sln /t:Rebuild
/p:Configuration=Release /p:RunOctopack=true
/p:OctoPackPackageVersion=1.1.1/p:OctoPackPublishPAckageToFileShare=C:\Packages

But when I try to Install the package in a second project I get this exception:

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

  • Both are targeting the same framework (4.5).
  • If you extract the library from the package and reference it, there's nothing weird going on there.
  • If you add the package from VS2013, it works perfectly.

I've notice Octopack version (dowloaded from the v3 endpoint https://api.nuget.org/v3/index.json) has Nuget.exe v.2.8, instead of the 3.xxx that it should. So I've tried to manually replace the nuget.exe file to generate the package, with no changes.

Any clues of what am I missing?

Thanks in advance


Solution

  • As far as I am aware using Octopack will generate a NuGet package (.nupkg) that can be used for OctopusDeploy only. It does not generate a NuGet package that can be used by NuGet in Visual Studio.

    Whilst Octopus Deploy uses .nupkg files the structure of the files in the .nupkg file are different. For the .nupkg to be possible to install into a .NET 4.5 project it would need the assembly inside a lib\net45 directory. If you look inside your .nupkg it will most likely not have this directory but will probably have the assemblies just in the root of the .nupkg.

    If you want to use the .nupkg file with NuGet you should look at using NuGet.exe to genreate the .nupkg file.

    The reason is probably works with Visual Studio 2013 is that it is treating it as a solution level NuGet package which are not currently supported in Visual Studio 2015.