2016-07-09 30 views
6

我遇到了一個包裝我自己的nuget包的問題,​​其中包括AutoMapper 5.0.2。這隻會在Visual Studio Team Services(VSTeam)構建服務器中產生錯誤。運行NuGet pack命令時出現錯誤:'AutoMapper'已經爲'NETStandard.Library'定義了一個依賴關係

我的項目是使用.NET 4.6.1

關於如何解決任何想法?

以下是錯誤:

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() 

我也GitHub上開設了一個問題:https://github.com/AutoMapper/AutoMapper/issues/1499

+1

您需要更新您使用的NuGet版本,如此處所述 - http://stackoverflow.com/questions/38247961/nuget-package-manager-automapper-already-has-a-dependency-defined-for- micros –

+0

我覺得是這樣。我只是不知道如何在Visual Studio Online的Hosted構建服務器上執行此操作。 – Phobis

+0

看起來Hosted Build Server正在運行NuGet 3.3.0.212 – Phobis

回答

4

我能夠把PowerShell腳本在下載最新的NuGet修復/解決辦法的問題。然後我將所有的Nu​​Get任務都指向了這個新的nuget.exe。優點:構建工作重新開始,缺點:每次構建都會再次下載NuGet,從而在NuGet.org上造成不必要的負載。

這裏是我的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 
+0

該腳本似乎不適用於我(我有'Build.SourcesDirectory'一詞不被識別爲cmdlet,函數,腳本文件或可操作程序的名稱。),但有效的只是簡單地下載https://dist.nuget.org/win-x86-commandline/latest/nuget.exe文件,替換我的項目中的文件,然後在VSO中將NuGet路徑設置爲「$(Build.SourcesDirectory)\。nuget \ nuget.exe「 –

+0

我沒有在每個版本上下載'nuget.exe',而是將它包含在源代碼管理中,並指出構建步驟來代替它。但同樣的問題 - nuget版本正在打破東西。 – trailmax

+0

@VictorF:對於獨立的Powershell腳本,可以使用'$ PSScriptRoot'(即'$ targetNugetExe =「$ PSScriptRoot/nuget.exe」') –

8

您需要安裝新的NuGet版本爲您的Visual Studio版本。

從這裏 Nuget gallery

+2

當然,這樣的事情會是修復。大聲笑謝謝,這對我有效。 – Nicholas

0

如果得到它的人使用Team市,你還需要使用/安裝的NuGet的新版本。

相關問題