Skip to content

Commit f316556

Browse files
committed
Merge pull request #1687 from stuartleeks/stuartleeks/NuGetInstallerDirectoryNameMessage
Check that solution file is a file
2 parents 6c32966 + 7a3c7bb commit f316556

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Tasks/NuGetInstaller/NuGetInstaller.ps1

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,16 @@ try
134134
{
135135
if($nuGetPath)
136136
{
137-
$slnFolder = $(Get-ItemProperty -Path $sf -Name 'DirectoryName').DirectoryName
138-
Write-Verbose "Running nuget package $restoreMode for $slnFolder"
139-
Invoke-Tool -Path $nugetPath -Arguments "$restoreMode `"$sf`" $args" -WorkingFolder $slnFolder
137+
if (-not (Test-Path $sf -PathType Leaf)) # check if the path is a file to give a friendly message if not
138+
{
139+
Write-Error (Get-LocalizedString -Key "Path '{0}' does not exist or is not a solution file. Check the 'path to solution or packages.config' property of the NuGetInstaller task " -ArgumentList $sf)
140+
}
141+
else
142+
{
143+
$slnFolder = $(Get-ItemProperty -Path $sf -Name 'DirectoryName').DirectoryName
144+
Write-Verbose "Running nuget package $restoreMode for $slnFolder"
145+
Invoke-Tool -Path $nugetPath -Arguments "$restoreMode `"$sf`" $args" -WorkingFolder $slnFolder
146+
}
140147
}
141148
}
142149
}

0 commit comments

Comments
 (0)