Skip to content

Commit

Permalink
Update supporting files
Browse files Browse the repository at this point in the history
  • Loading branch information
rfennell committed Dec 9, 2024
1 parent 1913a9a commit 776a7f6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ $VersionRegex = Get-VstsInput -Name "VersionRegex"
$outputversion = Get-VstsInput -Name "outputversion"
$VSVersion = Get-VstsInput -Name "VSVersion"
$SDKVersion = Get-VstsInput -Name "SDKVersion"
$SkipDacPac = [System.Convert]::ToBoolean(Get-VstsInput -Name "SkipDacPac")

$SkipDacPac = Get-VstsInput -Name "SkipDacPac"

# check if we are in test mode i.e.
If ($VersionNumber -eq "" -and $path -eq "") { Exit }
Expand Down Expand Up @@ -246,23 +245,24 @@ $ToolPath = Get-Toolpath -ToolPath $ToolPath -VSVersion $VSVersion -SDKVersion $


$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 ($SkipDacPac -eq $false)) {
Write-Verbose "Found $($DacPacFiles.Count) dacpacs. Beginning to apply updated version number $NewVersion." -Verbose
if (($DacPacFiles.Count -gt 0) -and ([System.Convert]::ToBoolean($SkipDacPac) -eq $false)) {
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-Verbose "Found no dacpacs 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-Verbose "Found $($SqlProjFiles.Count) sqlproj files. Adding or updating DacVersion field." -Verbose
Write-Host "Found $($SqlProjFiles.Count) sqlproj files. Adding or updating DacVersion field." -Verbose

foreach ($SqlProj in $SqlProjFiles) {
Write-Verbose "Updating $($SqlProj.Basename) SQL Proj file."
Write-Host "Updating $($SqlProj.Basename) SQL Proj file."
Update-SqlProjVersion -Path $SqlProj.Fullname -VersionNumber ([System.Version]::Parse($NewVersion)) -RegexPattern $VersionRegex
}
}
Expand Down
9 changes: 9 additions & 0 deletions Extensions/Versioning/VersionDacpacTask/src/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@
"required": true,
"helpMarkDown": "The actual version number extracted and used from the build number.",
"groupName":"output"
},
{
"name": "SkipDacPac",
"type": "boolean",
"label": "Skip DACPAC files",
"defaultValue": "False",
"required": true,
"helpMarkDown": "Skip checking for DACPAC files, only consider .SQLPROJ files",
"groupName":"advanced"
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Describe "Issue 603 - Encoding of SQLproj files" {
Mock Get-VstsInput -ParameterFilter {$Name -eq "InjectVersion"} {return ""}
Mock Get-VstsInput -ParameterFilter {$Name -eq "VersionRegex"} {return ""}
Mock Get-VstsInput -ParameterFilter {$Name -eq "outputversion"} {return ""}
Mock Get-VstsInput -ParameterFilter {$Name -eq "SkipDacPac"} {return "true"}

# Load the script under test
import-module "$PSScriptRoot\..\src\Update-DacPacVersionNumber.ps1"
Expand Down
Empty file.
1 change: 1 addition & 0 deletions Extensions/Versioning/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The DACPAC versioner also takes the following Advanced option
* ToolPath: The path to the folder containing the files Microsoft.SqlServer.Dac.dll and Microsoft.SqlServer.Dac.Extensions.dll. This should be used if these files are not in the default location and hence cannot be found by the task. This value takes precedence over the automated means of finding the DLL
* VSVersion: A filter for the Visual Studio version to scan for the SQL DAC SDK e.g 2017, 2015, 2022. if not set will scan for all versions and the newest used.
* SDKVersion: A filter for the SQL DAC SDK e.g 130, 150. if not set will scan for all versions and the newest used.
* SkipDacPac: Skip checking for DACPAC files, only consider .SQLPROJ files (default false)

The VSIX versioner also takes the following parameters

Expand Down

0 comments on commit 776a7f6

Please sign in to comment.