Search code examples
tfsbuildnugetpackagenuget-server

Build fails in TFS by giving an error "Packages failed to publish"


When I publish a NuGet to TFS using a build step, I get following error messages:

2017-05-26T09:58:26.8605708Z ##[error]Error: d:\a\_tasks\NuGetPublisher_333b11bd-d341-40d9-afcf-b32d5ce6f25b\0.2.34\node_modules\nuget-task-common\NuGet\3.3.0\NuGet.exe failed with return code: 1
2017-05-26T09:58:26.8605708Z ##[error]Packages failed to publish

enter image description here


Solution

  • Find the AssemblyInfo.cs file. There are two lines of code as shown below.

    [assembly: AssemblyVersion("1.0.0.0")]
    [assembly: AssemblyFileVersion("1.0.0.0")]
    

    And change this to this as shown below

    [assembly: AssemblyVersion("1.0.*")]
    //[assembly: AssemblyFileVersion("1.0.*")]
    

    So that the compiler will set the File Version to be equal to the Product Version. And it automatically increases.

    Ex : enter image description here

    And finally build succeeded. Here is the screen shot.

    enter image description here