Skip to content

Commit 926208e

Browse files
committed
local build now broken...
1 parent e1ceb7d commit 926208e

File tree

4 files changed

+10
-47
lines changed

4 files changed

+10
-47
lines changed

Build/CommonFunctionsAndMethods.psm1

-42
Original file line numberDiff line numberDiff line change
@@ -116,48 +116,6 @@ $dddafter-$dddbefore
116116
}
117117
}
118118

119-
Function Get-SqlConnectionString
120-
{
121-
[CmdletBinding()]
122-
param(
123-
[Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string] $ServerName,
124-
[Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string] $Login,
125-
[Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string] $DatabaseName
126-
);
127-
128-
$ServerNameTrimmed = $ServerName.Trim();
129-
$LoginTrimmed = $Login.Trim();
130-
131-
<#
132-
☹️
133-
This is so questionable, but it looks like sqlpackage cannot handle valid connection strings that use a valid server alias.
134-
The following snippet is meant to spelunk through the registry and extract the actual server from the alias.
135-
☹️
136-
#>
137-
$resolvedServerName = $ServerNameTrimmed;
138-
$serverAlias = Get-Item -Path HKLM:\SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo -ErrorAction SilentlyContinue;
139-
if ($null -ne $serverAlias -And $serverAlias.GetValueNames() -contains $ServerNameTrimmed) {
140-
$aliasValue = $serverAlias.GetValue($ServerNameTrimmed)
141-
if ($aliasValue -match "DBMSSOCN[,](.*)"){
142-
$resolvedServerName = $Matches[1];
143-
}
144-
}
145-
146-
<# When using Windows Authentication, you must use "Integrated Security=SSPI" in the SqlConnectionString. Else use "User ID=<username>;Password=<password>;" #>
147-
if ($LoginTrimmed -match '((.*[-][uU])|(.*[-][pP]))+.*'){
148-
$AuthenticationString = $LoginTrimmed -replace '^((\s*[-][uU]\s+(?<user>\S+)\s*)|(\s*[-][pP]\s+)((?<quote>[''"])(?<password>.*?)\k<quote>|(?<password>\S+))\s*)+$', 'User Id=${user};Password="${password}"'
149-
}
150-
elseif ($LoginTrimmed -eq "-E"){
151-
$AuthenticationString = "Integrated Security=SSPI;";
152-
}
153-
else{
154-
throw $LoginTrimmed + " is not supported here."
155-
}
156-
157-
$SqlConnectionString = "Data Source="+$resolvedServerName+";"+$AuthenticationString+";Connect Timeout=60;Initial Catalog="+$DatabaseName+";TrustServerCertificate=true;";
158-
$SqlConnectionString;
159-
}
160-
161119
function Get-TempFileForQuery {
162120
[CmdletBinding()]
163121
[OutputType([string])]

Build/LocalBuild.ps1

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using module "./CommonFunctionsAndMethods.psm1";
2-
31
param(
42
[Parameter(Mandatory=$false)][ValidateNotNullOrEmpty()][string] $ServerName = 'localhost,1433',
53
[Parameter(Mandatory=$true, ParameterSetName = 'UserPass')][ValidateNotNullOrEmpty()][string] $UserName = "sa" ,
@@ -14,7 +12,14 @@ param(
1412
$PSDefaultParameterValues = $PSDefaultParameterValues.clone()
1513
$PSDefaultParameterValues += @{'*:ErrorAction' = 'Stop'}
1614

17-
Get-Module -Name CommonFunctionsAndMethods | Select-Object Name, Path, Version
15+
Write-Host "Starting execution of LocalBuild.ps1"
16+
$__=$__ #quiesce warnings
17+
$invocationDir = $PSScriptRoot
18+
Push-Location -Path $invocationDir
19+
$cfam = (Join-Path $invocationDir "CommonFunctionsAndMethods.psm1" | Resolve-Path)
20+
Write-Host "Attempting to load module from: $cfam"
21+
Import-Module "$cfam" -Force -Verbose
22+
. (Join-Path $invocationDir 'SQLServerConnection.ps1');
1823

1924
function CleanTemp {
2025
param (

Build/SQLServerConnection.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ if (-not ([System.Management.Automation.PSTypeName]'SqlServerConnection').Type)
66
hidden [System.Security.SecureString]$Password
77
hidden [bool]$TrustedConnection
88
hidden [string]$ApplicationName
9-
hidden [string]$BaseConnectionString = "Connect Timeout=60;TrustServerCertificate=true;"
9+
hidden [string]$BaseConnectionString = "Connect Timeout=60;Encrypt=false;TrustServerCertificate=true;"
1010

1111
SqlServerConnection([string]$ServerName, [string]$UserName, [System.Security.SecureString]$Password,[string]$ApplicationName) {
1212
$this.ServerName = $ServerName.Trim()

CI/Azure-DevOps/CreateSQLVM_azcli.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Param(
1919
[Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string] $VMPriority
2020
);
2121

22-
Write-Host "Starting execution of CreateSQLContainer.ps1"
22+
Write-Host "Starting execution of CreateSQLVM_azcli.ps1"
2323
$__=$__ #quiesce warnings
2424
$invocationDir = $PSScriptRoot
2525
Push-Location -Path $invocationDir

0 commit comments

Comments
 (0)