Nuget Package Restore Not Working In TFS 2015

无人久伴 提交于 2019-12-11 04:14:59

问题


Nuget package restore is not working at all for us with TFS 2015 RC2 and a build server with Visual Studio 2015. I have a Visual Studio Build task with "Restore Nuget Packages" checked but that step doesn't do any restore before starting the build, which then fails. There is no error or anything that gives me a hint what would be wrong. There is just no ouptut regarding the package restore. I also tried adding a nuget package restore step, despite it seeming redundant but that also doesn't do anything. No ouptut. The build agent log looks like this:

23:02:49.826405 PowerShellHandler.Execute - AddCommand(C:\TFSAgent\tasks\NuGetInstaller\0.1.11\NuGetInstaller.ps1)
23:02:49.826405 PowerShellHandler.Execute - Add inputParameters
23:02:49.826405 PowerShellHandler.Execute - AddParameter(solution=C:\TFSAgent\_work\9c9a7daa\HiFxApi\main\src\HiFX.Api.sln)
23:02:49.826405 PowerShellHandler.Execute - AddParameter(excludeVersion=false)
23:02:49.826405 PowerShellHandler.Execute - AddParameter(noCache=false)
23:02:49.826405 PowerShellHandler.Execute - AddParameter(nuGetRestoreArgs=)
23:02:49.826405 PowerShellHandler.Execute - AddParameter(nuGetPath=)
23:02:50.074443 PowerShellHandler.Execute - Invoke

23:02:50.275946 FindFiles.FindMatchingFiles(rootFolder = , matchPattern = C:\TFSAgent\_work\9c9a7daa\HiFxApi\main\src\**\packages.config, includeFiles = True, includeFolders = False
23:02:50.275946 FindFiles.GetMatchingItems(includePatterns.Count = 1, excludePatterns.Count = 0, includeFiles = True, includeFolders = False
23:02:50.291644 FindFiles.FindMatchingFiles - Found 0 matches
23:02:50.322449 BaseLogger.LogStatus(scope.JobId = e0495eb1-3867-4bdf-8c90-196620cc0e1d, scope.TimelineRecordId = 6ac5c739-f581-4081-9cab-1404f28bfcc3, record.Name = )
23:02:50.322449 BaseLogger.LogFile(scope.JobId = e0495eb1-3867-4bdf-8c90-196620cc0e1d, path = C:\TFSAgent\_diag\w2ec95c01-f3c6-4db4-b910-0d40c922051b.log)
23:02:50.322449 JobExtensionManager.OnAfterExecuteTask
23:02:50.322449 BaseLogger.LogStatus(scope.JobId = e0495eb1-3867-4bdf-8c90-196620cc0e1d, scope.TimelineRecordId = 6ac5c739-f581-4081-9cab-1404f28bfcc3, record.Name = )
23:02:50.322449 BaseLogger.LogConsoleMessage(scope.JobId = e0495eb1-3867-4bdf-8c90-196620cc0e1d, message = ##[section]Finishing task: NuGetInstaller)
23:02:50.322449 LoggingEventHandlerManager.LoadLoggingEventHandlers(pluginPath=)

Am I supposed to have a packages.config file checked in with my solution?


回答1:


You're right, you need to submit packages.config to your VCS. It contains a list of packages (+ their version & target framework) used in the solution.

FindFiles.FindMatchingFiles - Found 0 matches in your log hints that the build agent looked for packages.config files, found none and therefore assumed there is nothing to restore and exited without an error.




回答2:


There can be another reason of the described behavior. The nuget restore action, the way it is implemented in VSBuild task, searches for packages.config files underneath the solution file directory.

For example, if the solution layout resembles the one below, nuget restore won't find packages.config and will simply do nothing:

  • Folder A
    • Folder A1
    • Folder A2
      • Folder A21
    • a.csproj
    • a.sln
  • Folder B
    • b.csproj
    • packages.config

You can examine the code of VSBuild build task to find out more details:

$slnFolder = $(Get-ItemProperty -Path $sf -Name 'DirectoryName').DirectoryName

Write-Verbose "Searching for nuget package configuration files using pattern $slnFolder\**\packages.config"
$pkgConfig = Find-Files -SearchPattern "$slnFolder\**\packages.config"
if ($pkgConfig)
{
   Write-Verbose "Running nuget package restore for $slnFolder"
   Invoke-Tool -Path $nugetPath -Arguments "restore `"$sf`" -NonInteractive" -WorkingFolder $slnFolder
}
else
{
   Write-Verbose "No nuget package configuration files found for $sf"
}


来源:https://stackoverflow.com/questions/31551294/nuget-package-restore-not-working-in-tfs-2015

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!