Skip to content

Commit

Permalink
detect if sqlps. uses it if available switch to sqlServer otherwise
Browse files Browse the repository at this point in the history
  • Loading branch information
sandorfr committed Dec 11, 2017
1 parent 9c90cd9 commit 15791b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Common/PowerShell3/VstsAzureHelpers/FindSqlPackagePath.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
$archive = $env:BUILD_SOURCESDIRECTORY + "\dataTools.zip"
$dataToolsRoot = $env:BUILD_SOURCESDIRECTORY + "\dataTools"

$client.DownloadFile("https://www.nuget.org/api/v2/package/Microsoft.Data.Tools.Msbuild/10.0.61026", $archive);
$client.DownloadFile("https://www.nuget.org/api/v2/package/Microsoft.Data.Tools.Msbuild/10.0.61710.120", $archive);

Expand-Archive $archive -DestinationPath $dataToolsRoot

$dacPath = $dataToolsRoot + "\lib\net40\sqlpackage.exe"
$dacPath = $dataToolsRoot + "\lib\net46\sqlpackage.exe"

return $dacPath
#throw "Unable to find the location of Dac Framework (SqlPackage.exe) from registry on machine $env:COMPUTERNAME"
Expand Down
16 changes: 12 additions & 4 deletions Common/PowerShell3/VstsAzureHelpers/VstsAzureHelpers.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,20 @@ function Initialize-Sqlps {
Push-Location

$sqlModule = Get-Module -ListAvailable | where -Property Name -eq SqlServer
if(!$sqlModule) {
Install-module -Name SqlServer -Scope CurrentUser -Force
$sqlps = Get-Module -ListAvailable | where -Property Name -eq sqlps

if ($sqlps) {
Import-Module -Name sqlps -Global -PassThru -Cmdlet Invoke-Sqlcmd 3>&1 | Out-Null
Write-VstsTaskVerbose -Message "SQLPS Module Imported"
} else {
if(!$sqlModule) {
Install-module -Name SqlServer -Scope CurrentUser -Force
}

Import-Module -Name SqlServer -Global -PassThru -Cmdlet Invoke-Sqlcmd 3>&1 | Out-Null
Write-VstsTaskVerbose -Message "SqlServer Module Imported"
}

Import-Module -Name SqlServer -Global -PassThru -Cmdlet Invoke-Sqlcmd 3>&1 | Out-Null
Write-VstsTaskVerbose -Message "SqlServer Module Imported"
Pop-Location
}
finally {
Expand Down

0 comments on commit 15791b2

Please sign in to comment.