Setting up a vNext Release in TFS 2015 and we are using powershell to get external web.config files. I've adapted this script from our old XAML builds:
[CmdletBinding()]
param([string]$TfsUrl, [string]$TfsConfigurationPath, [string]$ConfigurationDestination)
$tfs = $TfsUrl
if($tfs -ne $null)
{
$tfsItems = $tfs.vcs.GetItems($TfsConfigurationPath).Items
}
if ($tfsItems.Count -eq 0)
{
Write-Host "[DeployResources] WARNING: No configurations were found in TFS."
}
else
{
foreach ($tfsItem in $tfsItems)
{
$fileFound = $tfsItem.ServerItem -match '([^/]+)$'
if ($fileFound -ne $null)
{
$fileName = $matches[1]
$tfsItem.DownloadFile((Join-Path $ConfigurationDestination $fileName))
}
}
}
It fails on:
$tfsItems = $tfs.vcs.GetItems($TfsConfigurationPath).Items
with the error:
You cannot call a method on a null-valued expression.
At [Where I'm running the file from]\ExternalConfigs.ps1:54 char:9
+ $tfsItems = $tfs.vcs.GetItems($configurationSource).Items
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
For Parameters I'm handing it the URL of our TFS server as:
http://(server name):8080/tfs/(Collection name)
I then give it the full path to the configs folder inside the branch I'm targeting and for now I'm running it locally to put the file onto my desktop. The path to the files isn't null so I'm not at all sure why it's saying it's null. Where am i going wrong here?
Debugged locally based on your script, please try below script: