Skip to content

Commit

Permalink
test for existence first
Browse files Browse the repository at this point in the history
  • Loading branch information
potatoqualitee committed Feb 10, 2019
1 parent db1923a commit 2018b9d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions bin/library.ps1
Expand Up @@ -65,25 +65,27 @@ if ($ImportLibrary) {
}
}
# Else we prioritize user convenience
else {
else {
try {
$sln = (Resolve-Path -Path "$libraryBase\projects\dbatools\dbatools.sln" -ErrorAction Stop)
$hasProject = Test-Path -Path $sln -ErrorAction Stop
if ((Test-Path -Path "$libraryBase/projects/dbatools/dbatools.sln")) {
$sln = (Resolve-Path -Path "$libraryBase\projects\dbatools\dbatools.sln" -ErrorAction Stop)
$hasProject = Test-Path -Path $sln -ErrorAction Stop
}
} catch {
$null = 1
}

if (-not $dll) {
$hasCompiledDll = $false
} else {
$hasCompiledDll = Test-Path -Path $dll -ErrorAction Stop
}

$reslibdll = Resolve-Path -Path "$libraryBase\dbatools.dll"

if ((-not $script:alwaysBuildLibrary) -and $hasCompiledDll -and ([System.Diagnostics.FileVersionInfo]::GetVersionInfo($reslibdll).FileVersion -eq $currentLibraryVersion)) {
$start = Get-Date

try {
$libraryBase = Resolve-Path -Path "$libraryBase\"
$script:DllRoot = Resolve-Path -Path $script:DllRoot
Expand All @@ -104,7 +106,7 @@ else {
throw "No valid dbatools library found! Check your module integrity"
}
}

#region PowerShell TypeData
Update-TypeData -TypeName "Sqlcollaborative.Dbatools.dbaSystem.DbatoolsException" -SerializationDepth 2 -ErrorAction Ignore
Update-TypeData -TypeName "Sqlcollaborative.Dbatools.dbaSystem.DbatoolsExceptionRecord" -SerializationDepth 2 -ErrorAction Ignore
Expand Down

0 comments on commit 2018b9d

Please sign in to comment.