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

4
  • 1
    You need to update the version of NuGet you are using as described here - stackoverflow.com/questions/38247961/… Commented Jul 9, 2016 at 9: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. Commented Jul 9, 2016 at 15:05
  • Looks like the Hosted Build Server is running NuGet 3.3.0.212 Commented Jul 9, 2016 at 15:15
  • Looking at the NuGet source code NETStandard was added in NuGet 3.4 and also in NuGet 2.12. Commented Jul 14, 2016 at 15:09

3 Answers 3

9

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

Get it from here Nuget gallery

Sign up to request clarification or add additional context in comments.

1 Comment

Of course something goofy like this would be the fix. lol Thank you, that worked for me.
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

3 Comments

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 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"
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.
@VictorF: For standalone Powershell script it can be used $PSScriptRoot (i.e. $targetNugetExe = "$PSScriptRoot/nuget.exe" )
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.