Search code examples
nugetazure-devopsazure-pipelines-release-pipelinenuspecnuget-spec

Invalid .nuspec file: target framework `Unsupported,Version=v0.0` is not supported


So embarrassing to ask something that is that well documented, but I am lost with an error which I get when I push my NuGet package:

enter image description here

System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 400 (The NuGet package contains an invalid .nuspec file. The error encountered was: 'The target framework Unsupported,Version=v0.0 is not supported.'. Correct the error and try again.).

I use the VSTS NuGet task to push the package to NuGet.org which delivers the aforesaid error. There's nothing customized, just the default settings:

In my nuspec file I have listed dependencies, simplified example:

<dependencies>
  <group targetFramework="netcoreapp">
    <dependency id="Microsoft.NETCore.App" version="2.0.0" exclude="Build,Analyzers" />
  </group>
  <group targetFramework="net462" />
  <group targetFramework="netstandard1.0" />
</dependencies>

I assume my targetFramework is set incorrectly yet it is as per documentation NuGet Target Frameworks. I tried target frameworks like netstandard and netcoreapp2.0, they all cause the same problem.

My package files:

<files>
  <file src="bin\MINE.Core.dll" target="lib\netcoreapp\MINE.Core.dll" />
  <file src="bin\MINE.Core.NetFX.dll" target="lib\net462\MINE.Core.NetFX.dll" />
  <file src="bin\MINE.Core.PCL.dll" target="lib\netstandard1.0\MINE.Core.PCL.dll" />
  <file src="readme.core.txt" target="" />
</files>

If I leave the dependencies section empty (<dependencies />) everything works perfectly fine except for the package doesn't list the dependencies which I'd like to include. Also, If I don't use groups and therefore don't target frameworks, but list all dependent packages, everything works fine.

Any hint to solve this (probably silly) issue would be warmly appreciated.


Solution

  • The release definition isn't the problem, the build definition is. When the to be pushed NuGet package gets packed, ensure the correct NuGet version is being used.

    For example, the deprecated NuGet Packager task in VSTS used to package uses internally an older version of NuGet. Therefore, replacing the VSTS task with the recommended NuGet task solves the problem and NuGet.org won't complain about incorrectly nuspec files anymore.

    enter image description here