diff --git a/Common/PowerShell3/VstsAzureHelpers/FindSqlPackagePath.ps1 b/Common/PowerShell3/VstsAzureHelpers/FindSqlPackagePath.ps1 index b6ae80d..7a0231c 100644 --- a/Common/PowerShell3/VstsAzureHelpers/FindSqlPackagePath.ps1 +++ b/Common/PowerShell3/VstsAzureHelpers/FindSqlPackagePath.ps1 @@ -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" diff --git a/Common/PowerShell3/VstsAzureHelpers/VstsAzureHelpers.psm1 b/Common/PowerShell3/VstsAzureHelpers/VstsAzureHelpers.psm1 index df5ad4b..281c6a6 100644 --- a/Common/PowerShell3/VstsAzureHelpers/VstsAzureHelpers.psm1 +++ b/Common/PowerShell3/VstsAzureHelpers/VstsAzureHelpers.psm1 @@ -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 {