Skip to content

Commit

Permalink
Move the tool detection so only done if DACPACs found (#2052)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfennell authored Dec 20, 2024
1 parent c8d4244 commit 6b983a2
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,29 +240,27 @@ else {
}
Write-Verbose "Version: $NewVersion"


$ToolPath = Get-Toolpath -ToolPath $ToolPath -VSVersion $VSVersion -SDKVersion $SDKVersion


Write-Host "Scanning for DACPAC files under $PATH." -Verbose
$DacPacFiles = Get-ChildItem -Path $Path -Include *.dacpac -Exclude master.dacpac, msdb.dacpac -Recurse
Write-Host "Found $($DacPacFiles.Count) DACPAC files." -Verbose

if (($DacPacFiles.Count -gt 0) -and ([System.Convert]::ToBoolean($SkipDacPac) -eq $false)) {
Write-Host "Finding DACPAC Tools to process the $($DacPacFiles.Count) DACPAC files." -Verbose
$ToolPath = Get-Toolpath -ToolPath $ToolPath -VSVersion $VSVersion -SDKVersion $SDKVersion

Write-Host "Apply updated version number $NewVersion to each DACPAC file." -Verbose

Foreach ($DacPac in $DacPacFiles) {
Update-DacpacVerion -Path $DacPac.FullName -VersionNumber ([System.Version]::Parse($NewVersion)) -ToolPath $ToolPath
}
}
else {
Write-Host "Found no DACPAC files, or SkipDacPac parameter is set. Checking for sqlproj files to version instead" -Verbose
Write-Host "Found no DACPAC files, or SkipDacPac parameter is set. Checking for .SQLPROJ files to version instead" -Verbose
$SqlProjFiles = Get-ChildItem -Path $Path -Include *.sqlproj -Recurse

if ($SqlProjFiles) {
Write-Host "Found $($SqlProjFiles.Count) sqlproj files. Adding or updating DacVersion field." -Verbose

foreach ($SqlProj in $SqlProjFiles) {
Write-Host "Updating $($SqlProj.Basename) SQL Proj file."
Write-Host "Updating $($SqlProj.Basename) .SQLProj file."
Update-SqlProjVersion -Path $SqlProj.Fullname -VersionNumber ([System.Version]::Parse($NewVersion)) -RegexPattern $VersionRegex
}
}
Expand Down

0 comments on commit 6b983a2

Please sign in to comment.