I'm creating new VSTS/TFS extension in azure build pipeline. In that extension one field accepts a file path and it is optional field. In powershell script, i want to validate the field, if no input is provided then i have to ignore, otherwise i have to check whether input is path of .config file or not.
$ConfigFileName = Get-VstsInput -Name 'ConfigFilePath'
if (!(Test-Path $ConfigFileName))
{
Write-Host "Configuration file doesn't exist."
"##vso[task.complete result=Failed]"
throw "Configuration file doesn't exist."
}
if([IO.Path]::GetExtension($ConfigFileName) -ne '.config')
{
Write-Host "Invalid configuration file.File type must be of .config"
"##vso[task.complete result=Failed]"
throw "Invalid configuration file.File type must be of .config"
}
I have validated like above, but when user not provided any input then also the $ConfigFileName variable filled with mapping path that is $ value. How to check if input provided to that field is empty or not?