问题
This question NuGet: 'X' already has a dependency defined for 'Y' has the answer for when NuGet has this issue in Visual Studio, but how do I update NuGet in TFS 2015?
I am using the NuGet Packager build task and it is giving me the error
[error] 'System.Collections' already has a dependency defined for 'Microsoft.NETCore.Platforms'.
If this is not a bug then what am I doing wrong. The project is .Net 4.5.2 so I can't see why it would even have 'Microsoft.NETCore.Platforms'.
It should be noted that this build server already has about another 15 or so NuGet Packager builds that are working completely fine - this is the only broken one.
packages.config
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net452" />
<package id="Autofac" version="4.2.0" targetFramework="net452" />
<package id="Autofac.Configuration" version="4.0.1" targetFramework="net452" />
<package id="Autofac.Extras.CommonServiceLocator" version="4.0.0" targetFramework="net452" />
<package id="Autofac.Mvc5" version="4.0.0" targetFramework="net452" />
<package id="CommonServiceLocator" version="1.3" targetFramework="net452" />
<package id="EntityFramework" version="6.1.3" targetFramework="net452" />
<package id="LinqKit" version="1.1.8.0" targetFramework="net452" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net452" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.2" targetFramework="net452" />
<package id="Microsoft.Extensions.Configuration" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Extensions.Configuration.Abstractions" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Extensions.Primitives" version="1.0.0" targetFramework="net452" />
<package id="Microsoft.Net.Compilers" version="1.3.2" targetFramework="net452" developmentDependency="true" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net452" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
<package id="NLog" version="4.3.11" targetFramework="net452" />
<package id="System.Collections" version="4.0.11" targetFramework="net452" />
<package id="System.Diagnostics.Debug" version="4.0.11" targetFramework="net452" />
<package id="System.IO" version="4.1.0" targetFramework="net452" />
<package id="System.Linq" version="4.1.0" targetFramework="net452" />
<package id="System.Resources.ResourceManager" version="4.0.1" targetFramework="net452" />
<package id="System.Runtime" version="4.1.0" targetFramework="net452" />
<package id="System.Runtime.Extensions" version="4.1.0" targetFramework="net452" />
<package id="System.Runtime.InteropServices" version="4.1.0" targetFramework="net452" />
<package id="System.Threading" version="4.0.11" targetFramework="net452" />
<package id="WebGrease" version="1.6.0" targetFramework="net452" />
</packages>
NuGet Packager Task Debug Output
2016-11-10T08:05:00.0196078Z Set workingFolder to default: E:\VsoAgents\agent2\tasks\NuGetPackager\0.1.58
2016-11-10T08:05:00.0196078Z Executing the powershell script: E:\VsoAgents\agent2\tasks\NuGetPackager\0.1.58\NuGetPackager.ps1
2016-11-10T08:05:00.1758635Z ##[debug]Entering script System.Management.Automation.InvocationInfo.MyCommand.Name
2016-11-10T08:05:00.1758635Z ##[debug]Parameter Values
2016-11-10T08:05:00.1758635Z ##[debug]searchPattern = E:\VsoAgents\agent2\_work\17\s\My.Project.Name\My.Project.Name.csproj
2016-11-10T08:05:00.1758635Z ##[debug]versionByBuild = false
2016-11-10T08:05:00.1758635Z ##[debug]outputdir = E:\VsoAgents\agent2\_work\17\a\nuget
2016-11-10T08:05:00.1758635Z ##[debug]configurationToPack = Release
2016-11-10T08:05:00.1758635Z ##[debug]buildProperties =
2016-11-10T08:05:00.1758635Z ##[debug]nuGetAdditionalArgs =
2016-11-10T08:05:00.1758635Z ##[debug]nuGetPath =
2016-11-10T08:05:00.1758635Z ##[debug]Importing modules
2016-11-10T08:05:00.1914879Z ##[debug]Loading module from path 'E:\VsoAgents\agent2\agent\worker\Modules\Microsoft.TeamFoundation.DistributedTask.Task.Internal\Microsoft.TeamFoundation.DistributedTask.Task.Internal.dll'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Add-BuildAttachment'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Convert-String'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Get-IndexedSourceFilePaths'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Get-JavaDevelopmentKitPath'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Get-MSBuildLocation'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Get-ServiceEndpoint'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Get-TfsClientCredentials'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Get-ToolPath'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Get-TaskVariable'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Get-VisualStudioPath'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Get-VssConnection'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Invoke-Ant'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Invoke-BatchScript'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Invoke-Maven'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Invoke-MSBuild'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Invoke-PublishSymbols'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Invoke-Tool'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Invoke-VSTest'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Publish-BuildArtifact'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Copy-BuildArtifact'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Add-BuildArtifactLink'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Register-XamarinLicense'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Unregister-XamarinLicense'.
2016-11-10T08:05:00.1914879Z ##[debug]Importing cmdlet 'Get-X509Certificate'.
2016-11-10T08:05:00.2071133Z ##[debug]Loading module from path 'E:\VsoAgents\agent2\agent\worker\Modules\Microsoft.TeamFoundation.DistributedTask.Task.Common\Microsoft.TeamFoundation.DistributedTask.Task.Common.dll'.
2016-11-10T08:05:00.2071133Z ##[debug]Importing cmdlet 'Complete-Task'.
2016-11-10T08:05:00.2071133Z ##[debug]Importing cmdlet 'Get-LocalizedString'.
2016-11-10T08:05:00.2071133Z ##[debug]Importing cmdlet 'Set-TaskVariable'.
2016-11-10T08:05:00.2071133Z ##[debug]Importing cmdlet 'Set-TaskProgress'.
2016-11-10T08:05:00.2071133Z ##[debug]Importing cmdlet 'Add-TaskIssue'.
2016-11-10T08:05:00.2071133Z ##[debug]Importing cmdlet 'Write-TaskDetail'.
2016-11-10T08:05:00.2071133Z ##[debug]Importing cmdlet 'Find-Files'.
2016-11-10T08:05:00.2227381Z Checking pattern is specified
2016-11-10T08:05:00.2227381Z Output folder used but doesn't exists, creating it
2016-11-10T08:05:00.2539913Z E:\VsoAgents\agent2\_work\17\a\nuget
2016-11-10T08:05:00.2539913Z No Pattern found in solution parameter.
2016-11-10T08:05:00.2696176Z Found files: 1
2016-11-10T08:05:00.2696176Z --File: "E:\VsoAgents\agent2\_work\17\s\My.Project.Name\My.Project.Name.csproj"
2016-11-10T08:05:00.2696176Z Creating Nuget Arguments:
2016-11-10T08:05:00.2696176Z --ARGS: pack "E:\VsoAgents\agent2\_work\17\s\My.Project.Name\My.Project.Name.csproj" -OutputDirectory "E:\VsoAgents\agent2\_work\17\a\nuget" -Properties Configuration=Release
2016-11-10T08:05:00.2696176Z Invoking nuget with pack "E:\VsoAgents\agent2\_work\17\s\My.Project.Name\My.Project.Name.csproj" -OutputDirectory "E:\VsoAgents\agent2\_work\17\a\nuget" -Properties Configuration=Release on E:\VsoAgents\agent2\_work\17\s\My.Project.Name
2016-11-10T08:05:00.2852419Z E:\VsoAgents\agent2\agent\worker\tools\NuGet.exe pack "E:\VsoAgents\agent2\_work\17\s\My.Project.Name\My.Project.Name.csproj" -OutputDirectory "E:\VsoAgents\agent2\_work\17\a\nuget" -Properties Configuration=Release
2016-11-10T08:05:02.1915495Z MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
2016-11-10T08:05:02.1915495Z Attempting to build package from 'My.Project.Name.csproj'.
2016-11-10T08:05:03.1447051Z Packing files from 'E:\VsoAgents\agent2\_work\17\s\My.Project.Name\bin'.
2016-11-10T08:05:03.4103392Z Using 'My.Project.Name.nuspec' for metadata.
2016-11-10T08:05:04.6604008Z ##[error]'System.Collections' already has a dependency defined for 'Microsoft.NETCore.Platforms'.
2016-11-10T08:05:04.7385325Z ##[error]System.Exception: Unexpected exit code 1 returned from tool NuGet.exe
2016-11-10T08:05:04.7385325Z ##[error] at Microsoft.TeamFoundation.DistributedTask.Task.Internal.PowerShell.InvokeToolCmdlet.ProcessRecord()
2016-11-10T08:05:04.7385325Z ##[error] at System.Management.Automation.CommandProcessor.ProcessRecord()
Nuspec file
<package >
<metadata>
<id>My.Project.Name</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<projectUrl>http://www.example.com</projectUrl>
<iconUrl>http://www.example.com/logo.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<copyright>Copyright 2016</copyright>
</metadata>
</package>
回答1:
The solution was to upgrade NuGet. I did this by opening admin command prompt at C:\Program Files\Microsoft Team Foundation Server 14.0\Build\Agent\Worker\Tools
and running nuget update -self
, and then running it in the .\Agent\Worker\Tools
in each VSO Agent folder.
来源:https://stackoverflow.com/questions/40522843/tfs2015-nuget-packager-error-system-collections-already-has-a-dependency-de