Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions NugetTools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,14 @@ function Test-AssemblyIsDesiredVersion

$splitTargetVer = $DesiredVersion.Split('.')

$versionInfo = (Get-Item -Path $AssemblyPath).VersionInfo
$file = Get-Item -Path $AssemblyPath -ErrorVariable ev
if (($null -ne $ev) -and ($ev.Count -gt 0))
{
Write-Log "Problem accessing [$Path]: $($ev[0].Exception.Message)" -Level Warning
return $false
}

$versionInfo = $file.VersionInfo
$splitSourceVer = @(
$versionInfo.ProductMajorPart,
$versionInfo.ProductMinorPart,
Expand Down Expand Up @@ -300,7 +307,7 @@ function Get-NugetPackageDllPath

# First we'll check to see if the user has cached the assembly into the module's script directory
$moduleAssembly = Join-Path -Path $PSScriptRoot -ChildPath $AssemblyName
if (Test-Path -Path $moduleAssembly -PathType Leaf)
if (Test-Path -Path $moduleAssembly -PathType Leaf -ErrorAction Ignore)
{
if (Test-AssemblyIsDesiredVersion -AssemblyPath $moduleAssembly -DesiredVersion $NugetPackageVersion)
{
Expand All @@ -318,7 +325,7 @@ function Get-NugetPackageDllPath
if (-not [System.String]::IsNullOrEmpty($alternateAssemblyPath))
{
$assemblyPath = Join-Path -Path $alternateAssemblyPath -ChildPath $AssemblyName
if (Test-Path -Path $assemblyPath -PathType Leaf)
if (Test-Path -Path $assemblyPath -PathType Leaf -ErrorAction Ignore)
{
if (Test-AssemblyIsDesiredVersion -AssemblyPath $assemblyPath -DesiredVersion $NugetPackageVersion)
{
Expand All @@ -340,7 +347,7 @@ function Get-NugetPackageDllPath
else
{
$cachedAssemblyPath = Join-Path -Path $(Join-Path $script:tempAssemblyCacheDir $AssemblyPackageTailDirectory) $AssemblyName
if (Test-Path -Path $cachedAssemblyPath -PathType Leaf)
if (Test-Path -Path $cachedAssemblyPath -PathType Leaf -ErrorAction Ignore)
{
if (Test-AssemblyIsDesiredVersion -AssemblyPath $cachedAssemblyPath -DesiredVersion $NugetPackageVersion)
{
Expand All @@ -359,7 +366,7 @@ function Get-NugetPackageDllPath
Get-NugetPackage -PackageName $NugetPackageName -Version $NugetPackageVersion -TargetPath $script:tempAssemblyCacheDir -NoStatus:$NoStatus

$cachedAssemblyPath = Join-Path -Path $(Join-Path -Path $script:tempAssemblyCacheDir -ChildPath $AssemblyPackageTailDirectory) -ChildPath $AssemblyName
if (Test-Path -Path $cachedAssemblyPath -PathType Leaf)
if (Test-Path -Path $cachedAssemblyPath -PathType Leaf -ErrorAction Ignore)
{
Write-Log -Message @(
"To avoid this download delay in the future, copy the following file:",
Expand Down