0

I am using the NuGet Packager task as part of my TFS 2017 build procedure to create a NuGet package for a class library. I am getting the error:

[error]'System.Runtime' already has a dependency defined for 'Microsoft.NETCore.Platforms'. [error]System.Exception: Unexpected exit code 1 returned from tool NuGet.exe

I set the following task parameters:

Path to csproj or nuspec file(s) to pack: .\xxx\xxx.csproj
Package Folder: ./xxx/bin/Release
Include referenced projects: Checked
Automatic package versioning: Use the build number
Configuration to Package: $(BuildConfiguration)

I am using the same TFS task to create another NuGet package for another class library, and everything works fine.

I tried solutions provided by the following stackoverflow questions, but nothing worked.

TFS2015 NuGet Packager: [error] 'System.Collections' already has a dependency defined for 'Microsoft.NETCore.Platforms'

NuGet: 'X' already has a dependency defined for 'Y'

Any idea on how to fix this error?

RobertBaron
  • 2,817
  • 1
  • 12
  • 19

1 Answers1

0

As reported at 'System.Globalization' already has a dependency defined for 'Microsoft.NETCore.Platforms', this error has been fixed in the new multi-purpose NuGet Command task that supersedes the old NuGet Packager task and uses NuGet 4.0 by default.

Using the NuGet Command TFS task in place of the NuGet Packager TFS task fixed the error. The parameters used with the NuGet Command task are:

Command: pack
Arguments: .\xxx\xxx.csproj 
    -OutputDirectory ./xxx/bin/Release
    -Version $(Build.BuildNumber)
    -IncludeReferencedProjects
    -Properties Configuration=$(BuildConfiguration)
RobertBaron
  • 2,817
  • 1
  • 12
  • 19