6

I'm having an issue packaging my own nuget package, which includes AutoMapper 5.0.2. This is only producing an error within the Visual Studio Team Services (VSTeam) Build servers.

My project is using .NET 4.6.1

Any ideas on how to fix?

Here is the error:

2016-07-08T23:46:44.5801667Z C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\1.102.0\agent\worker\tools\NuGet.exe pack "C:\a\1\s\Project.csproj" -OutputDirectory "C:\a\1\s\Project\bin\release" -Properties Configuration=release -IncludeReferencedProjects 
2016-07-08T23:46:45.0458195Z MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
2016-07-08T23:46:45.0468395Z Attempting to build package from 'Project.csproj'.
2016-07-08T23:46:45.1942694Z Packing files from 'C:\a\1\s\Project\bin\Release'.
2016-07-08T23:46:45.3942642Z ##[error]**'AutoMapper' already has a dependency defined for 'NETStandard.Library'.**
2016-07-08T23:46:45.4142626Z ##[error]System.Exception: Unexpected exit code 1 returned from tool NuGet.exe
2016-07-08T23:46:45.4152639Z ##[error] at Microsoft.TeamFoundation.DistributedTask.Task.Internal.PowerShell.InvokeToolCmdlet.ProcessRecord()
2016-07-08T23:46:45.4152639Z ##[error] at System.Management.Automation.CommandProcessor.ProcessRecord()

I also opened an issue on GitHub: https://github.com/AutoMapper/AutoMapper/issues/1499

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
Phobis
  • 7,524
  • 10
  • 47
  • 76
  • 1
    You need to update the version of NuGet you are using as described here - http://stackoverflow.com/questions/38247961/nuget-package-manager-automapper-already-has-a-dependency-defined-for-micros – Matt Ward Jul 09 '16 at 09:16
  • I figured that was the case. I just don't know how to do that on a Hosted build server for Visual Studio Online. – Phobis Jul 09 '16 at 15:05
  • Looks like the Hosted Build Server is running NuGet 3.3.0.212 – Phobis Jul 09 '16 at 15:15
  • Looking at the [NuGet source code](https://github.com/NuGet/NuGet.Client/commit/5cd1148dc6d6c05a430841ddb7f27dc31e137d41) NETStandard was added in [NuGet 3.4](https://docs.nuget.org/release-notes/nuget-3.4) and also in NuGet 2.12. – Matt Ward Jul 14 '16 at 15:09

3 Answers3

9

You need to install new Nuget version for your visual studio version.

Get it from here Nuget gallery

JConstantine
  • 3,980
  • 1
  • 33
  • 46
Alienalone
  • 133
  • 1
  • 1
  • 6
4

I was able to fix/workaround the issue by putting a PowerShell script in to download the latest NuGet. Then I pointed all of the NuGet tasks to this new nuget.exe. Pros: builds are working again, Cons: each build downloads NuGet again, causing unnecessary load on NuGet.org.

Here is my PowerShell:

$sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
$targetNugetExe = "$(build.sourcesdirectory)/nuget.exe"
Invoke-WebRequest $sourceNugetExe -OutFile $targetNugetExe
Set-Alias nuget $targetNugetExe -Scope Global -Verbose
nuget
Phobis
  • 7,524
  • 10
  • 47
  • 76
  • The script didn't seem to work for me (I've got The term 'Build.SourcesDirectory' is not recognized as the name of a cmdlet, function, script file, or operable program.), but what worked was simply downloading https://dist.nuget.org/win-x86-commandline/latest/nuget.exe file, replacing the file in my project, and then simply everywhere in VSO setting NuGet path to "$(Build.SourcesDirectory)\.nuget\nuget.exe" – Victor F Aug 01 '16 at 16:13
  • Instead of downloading `nuget.exe` on every build, I included it in source control and pointed build step to use it instead. But same problem - nuget version is breaking stuff. – trailmax Aug 18 '16 at 21:26
  • @VictorF: For standalone Powershell script it can be used `$PSScriptRoot` (i.e. `$targetNugetExe = "$PSScriptRoot/nuget.exe" `) – Michael Freidgeim Aug 31 '16 at 00:52
0

If someone using Team City you also need to use / install newer version of Nuget.

darmis
  • 2,879
  • 1
  • 19
  • 21