When I run the NuGet package command, I get an error: "AutoMapper" already has a dependency defined for "NETStandard.Library",

I had a problem packing my own nuget package, which includes AutoMapper 5.0.2. This causes an error only on the Build Team Team Services (VSTeam) Build servers.

My project uses .NET 4.6.1

Any ideas on how to fix it?

Here is the error:

2016-07-08T23:46:44.5801667ZC:\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 a question about GitHub: https://github.com/AutoMapper/AutoMapper/issues/1499

+6
source share
3 answers

I was able to fix / fix the problem by installing a PowerShell script to download the latest NuGet. Then I pointed all the NuGet tasks to this new nuget.exe. Pros: builds work again, Cons: each build loads 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 
+4
source

You need to install the new version of Nuget for your version for Visual Studio.

Get It From Here Nuget Gallery

+8
source

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

0
source

All Articles