From a425317f3e7069095eaa1f2f70d63728e387dcbe Mon Sep 17 00:00:00 2001 From: Michael McKechney Date: Wed, 14 Feb 2024 16:37:27 -0500 Subject: [PATCH] Scripting and container build fixes (#473) * Fixes #469 * Fixed GitHub action for container-build --- CHANGELOG.md | 4 ++++ scripts/templates/Modules/containerappenv.bicep | 13 ++++++++++--- scripts/templates/Modules/database.bicep | 2 ++ scripts/templates/azuredeploy_main.bicep | 2 +- src/AssemblyVersioning.cs | 8 ++++---- ...qlBuildManager.Console.Dependent.UnitTest.csproj | 6 +++--- .../SqlBuildManager.Console.ExternalTest.csproj | 8 ++++---- .../SqlBuildManager.Console.UnitTest.csproj | 6 +++--- src/SqlBuildManager.Console/sbm.csproj | 12 ++++++------ .../SqlBuildManager.Enterprise.UnitTest.csproj | 6 +++--- .../SqlBuildManager.Logging.csproj | 2 +- .../SqlBuildManager.ScriptHandling.UnitTest.csproj | 6 +++--- .../SqlSync.Connection.Dependent.UnitTest.csproj | 6 +++--- .../SqlSync.Connection.UnitTest.csproj | 6 +++--- src/SqlSync.Connection/SqlSync.Connection.csproj | 2 +- .../SqlSync.DbInformation.Dependent.UnitTest.csproj | 6 +++--- .../SqlSync.ObjectScript.Dependent.UnitTest.csproj | 6 +++--- .../SqlSync.ObjectScript.UnitTest.csproj | 6 +++--- src/SqlSync.SprocTest/SqlSync.SprocTest.csproj | 8 ++++---- .../SqlSync.SqlBuild.Dependent.UnitTest.csproj | 8 ++++---- .../SqlSync.SqlBuild.UnitTest.csproj | 8 ++++---- src/SqlSync.SqlBuild/DacPacHelper.cs | 10 +++++++++- src/SqlSync.SqlBuild/SQLSync.SqlBuild.csproj | 4 ++-- src/SqlSync.SqlBuild/SqlSync.SqlBuild.csproj | 4 ++-- src/SqlSync.TableScript/SqlSync.TableScript.csproj | 2 +- src/SqlSync/SQLSync.csproj | 2 +- 26 files changed, 87 insertions(+), 66 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71fa7492..4a09898c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # SQL Build Manager Change Log +### Version 15.6.1 +- *FIXED:* [GitHub Issue #469](https://github.com/mmckechney/SqlBuildManager/issues/469) - New tables with foreign key constraints not generating the CREATE TABLE statements +- *FIXED:* GitHub Action for container build + ### Version 15.6.0 - *UPDATED:* Now targets .NET 8.0 - *UPDATED:* Simplified data object classes and regenerated typed DataSet classes diff --git a/scripts/templates/Modules/containerappenv.bicep b/scripts/templates/Modules/containerappenv.bicep index 99df5b9c..d7626468 100644 --- a/scripts/templates/Modules/containerappenv.bicep +++ b/scripts/templates/Modules/containerappenv.bicep @@ -1,9 +1,15 @@ param containerAppEnvName string param logAnalyticsClientId string -param logAnalyticsKey string +param logAnalyticsWorkspaceName string param location string = resourceGroup().location param subnetId string = '' + +resource logAnalyticsWorkspaceResource 'Microsoft.OperationalInsights/workspaces@2021-06-01' existing = { + name:logAnalyticsWorkspaceName + +} + resource containerAppEnvWithSubnet 'Microsoft.App/managedEnvironments@2022-11-01-preview' = if(subnetId != '') { name: containerAppEnvName location: location @@ -12,7 +18,8 @@ resource containerAppEnvWithSubnet 'Microsoft.App/managedEnvironments@2022-11-01 destination: 'log-analytics' logAnalyticsConfiguration: { customerId: logAnalyticsClientId - sharedKey: logAnalyticsKey + sharedKey: logAnalyticsWorkspaceResource.listkeys().primarySharedKey + } } workloadProfiles: [ @@ -35,7 +42,7 @@ resource containerAppEnvNoSubnet 'Microsoft.App/managedEnvironments@2022-11-01-p destination: 'log-analytics' logAnalyticsConfiguration: { customerId: logAnalyticsClientId - sharedKey: logAnalyticsKey + sharedKey: logAnalyticsWorkspaceResource.listkeys().primarySharedKey } } workloadProfiles: [ diff --git a/scripts/templates/Modules/database.bicep b/scripts/templates/Modules/database.bicep index 3c4693ce..8b1e9fa0 100644 --- a/scripts/templates/Modules/database.bicep +++ b/scripts/templates/Modules/database.bicep @@ -56,6 +56,7 @@ resource sqlserverAResource 'Microsoft.Sql/servers@2021-11-01' = { administratorLoginPassword: sqladminpassword publicNetworkAccess: 'Enabled' restrictOutboundNetworkAccess: 'Disabled' + minimalTlsVersion: '1.2' administrators: { administratorType: 'ActiveDirectory' principalType: 'Application' @@ -136,6 +137,7 @@ resource sqlserverBResource 'Microsoft.Sql/servers@2021-11-01' = { administratorLoginPassword: sqladminpassword publicNetworkAccess: 'Enabled' restrictOutboundNetworkAccess: 'Disabled' + minimalTlsVersion: '1.2' administrators: { administratorType: 'ActiveDirectory' principalType: 'Application' diff --git a/scripts/templates/azuredeploy_main.bicep b/scripts/templates/azuredeploy_main.bicep index fa0d001e..18d7908c 100644 --- a/scripts/templates/azuredeploy_main.bicep +++ b/scripts/templates/azuredeploy_main.bicep @@ -133,7 +133,7 @@ module containerAppEnv './Modules/containerappenv.bicep' = if(deployContainerApp params: { containerAppEnvName: containerAppEnvNameVar logAnalyticsClientId: logAnalyticsWorkspaceResource.properties.customerId - logAnalyticsKey: logAnalyticsWorkspaceResource.listkeys().primarySharedKey + logAnalyticsWorkspaceName: logAnalyticsWorkspaceVar subnetId: networkResource.outputs.containerAppSubnetId location: location diff --git a/src/AssemblyVersioning.cs b/src/AssemblyVersioning.cs index 286ad276..e2a8d9e6 100644 --- a/src/AssemblyVersioning.cs +++ b/src/AssemblyVersioning.cs @@ -6,8 +6,8 @@ // associated with an assembly. // [assembly: AssemblyCompany("Michael McKechney - www.mckechney.com")] -[assembly: AssemblyCopyright("Copyright © Michael McKechney 2004-2023")] -[assembly: AssemblyTrademark("Copyright © Michael McKechney 2004-2023")] +[assembly: AssemblyCopyright("Copyright © Michael McKechney 2004-2024")] +[assembly: AssemblyTrademark("Copyright © Michael McKechney 2004-2024")] // // Version information for an assembly consists of the following four values: @@ -24,5 +24,5 @@ // 2) Update the installer version to match the AssemblyVersion below. // These can be found in SqlBuildManager.Setup -> Organize Your Setup -> General Information -[assembly: AssemblyVersion("15.6.0")] -[assembly: AssemblyFileVersion("15.6.0")] +[assembly: AssemblyVersion("15.6.1")] +[assembly: AssemblyFileVersion("15.6.1")] diff --git a/src/SqlBuildManager.Console.Dependent.UnitTest/SqlBuildManager.Console.Dependent.UnitTest.csproj b/src/SqlBuildManager.Console.Dependent.UnitTest/SqlBuildManager.Console.Dependent.UnitTest.csproj index 8ff050ef..fd4c07bc 100644 --- a/src/SqlBuildManager.Console.Dependent.UnitTest/SqlBuildManager.Console.Dependent.UnitTest.csproj +++ b/src/SqlBuildManager.Console.Dependent.UnitTest/SqlBuildManager.Console.Dependent.UnitTest.csproj @@ -62,9 +62,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/SqlBuildManager.Console.ExternalTest/SqlBuildManager.Console.ExternalTest.csproj b/src/SqlBuildManager.Console.ExternalTest/SqlBuildManager.Console.ExternalTest.csproj index 15f3f218..6d6eabf3 100644 --- a/src/SqlBuildManager.Console.ExternalTest/SqlBuildManager.Console.ExternalTest.csproj +++ b/src/SqlBuildManager.Console.ExternalTest/SqlBuildManager.Console.ExternalTest.csproj @@ -8,15 +8,15 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/SqlBuildManager.Console.UnitTest/SqlBuildManager.Console.UnitTest.csproj b/src/SqlBuildManager.Console.UnitTest/SqlBuildManager.Console.UnitTest.csproj index 6bf55508..6971dba9 100644 --- a/src/SqlBuildManager.Console.UnitTest/SqlBuildManager.Console.UnitTest.csproj +++ b/src/SqlBuildManager.Console.UnitTest/SqlBuildManager.Console.UnitTest.csproj @@ -32,9 +32,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/SqlBuildManager.Console/sbm.csproj b/src/SqlBuildManager.Console/sbm.csproj index 8d383505..aac167d3 100644 --- a/src/SqlBuildManager.Console/sbm.csproj +++ b/src/SqlBuildManager.Console/sbm.csproj @@ -29,10 +29,10 @@ - - - - + + + + @@ -64,9 +64,9 @@ - + - + diff --git a/src/SqlBuildManager.Enterprise.UnitTest/SqlBuildManager.Enterprise.UnitTest.csproj b/src/SqlBuildManager.Enterprise.UnitTest/SqlBuildManager.Enterprise.UnitTest.csproj index e1fe88cf..faf7b039 100644 --- a/src/SqlBuildManager.Enterprise.UnitTest/SqlBuildManager.Enterprise.UnitTest.csproj +++ b/src/SqlBuildManager.Enterprise.UnitTest/SqlBuildManager.Enterprise.UnitTest.csproj @@ -15,9 +15,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/SqlBuildManager.Logging/SqlBuildManager.Logging.csproj b/src/SqlBuildManager.Logging/SqlBuildManager.Logging.csproj index 03e903fa..5721addf 100644 --- a/src/SqlBuildManager.Logging/SqlBuildManager.Logging.csproj +++ b/src/SqlBuildManager.Logging/SqlBuildManager.Logging.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/SqlBuildManager.ScriptHandling.UnitTest/SqlBuildManager.ScriptHandling.UnitTest.csproj b/src/SqlBuildManager.ScriptHandling.UnitTest/SqlBuildManager.ScriptHandling.UnitTest.csproj index 93ac2f64..ee87b7d8 100644 --- a/src/SqlBuildManager.ScriptHandling.UnitTest/SqlBuildManager.ScriptHandling.UnitTest.csproj +++ b/src/SqlBuildManager.ScriptHandling.UnitTest/SqlBuildManager.ScriptHandling.UnitTest.csproj @@ -10,9 +10,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/SqlSync.Connection.Dependent.UnitTest/SqlSync.Connection.Dependent.UnitTest.csproj b/src/SqlSync.Connection.Dependent.UnitTest/SqlSync.Connection.Dependent.UnitTest.csproj index b6ce79ed..d29585ac 100644 --- a/src/SqlSync.Connection.Dependent.UnitTest/SqlSync.Connection.Dependent.UnitTest.csproj +++ b/src/SqlSync.Connection.Dependent.UnitTest/SqlSync.Connection.Dependent.UnitTest.csproj @@ -13,9 +13,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/SqlSync.Connection.UnitTest/SqlSync.Connection.UnitTest.csproj b/src/SqlSync.Connection.UnitTest/SqlSync.Connection.UnitTest.csproj index b6ce79ed..d29585ac 100644 --- a/src/SqlSync.Connection.UnitTest/SqlSync.Connection.UnitTest.csproj +++ b/src/SqlSync.Connection.UnitTest/SqlSync.Connection.UnitTest.csproj @@ -13,9 +13,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/SqlSync.Connection/SqlSync.Connection.csproj b/src/SqlSync.Connection/SqlSync.Connection.csproj index 5b54e767..ec253203 100644 --- a/src/SqlSync.Connection/SqlSync.Connection.csproj +++ b/src/SqlSync.Connection/SqlSync.Connection.csproj @@ -6,7 +6,7 @@ - + diff --git a/src/SqlSync.DbInformation.Dependent.UnitTest/SqlSync.DbInformation.Dependent.UnitTest.csproj b/src/SqlSync.DbInformation.Dependent.UnitTest/SqlSync.DbInformation.Dependent.UnitTest.csproj index d9e80b0d..d4f157cd 100644 --- a/src/SqlSync.DbInformation.Dependent.UnitTest/SqlSync.DbInformation.Dependent.UnitTest.csproj +++ b/src/SqlSync.DbInformation.Dependent.UnitTest/SqlSync.DbInformation.Dependent.UnitTest.csproj @@ -7,9 +7,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/SqlSync.ObjectScript.Dependent.UnitTest/SqlSync.ObjectScript.Dependent.UnitTest.csproj b/src/SqlSync.ObjectScript.Dependent.UnitTest/SqlSync.ObjectScript.Dependent.UnitTest.csproj index 5b73da3e..073122f5 100644 --- a/src/SqlSync.ObjectScript.Dependent.UnitTest/SqlSync.ObjectScript.Dependent.UnitTest.csproj +++ b/src/SqlSync.ObjectScript.Dependent.UnitTest/SqlSync.ObjectScript.Dependent.UnitTest.csproj @@ -7,9 +7,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/SqlSync.ObjectScript.UnitTest/SqlSync.ObjectScript.UnitTest.csproj b/src/SqlSync.ObjectScript.UnitTest/SqlSync.ObjectScript.UnitTest.csproj index c1574bdc..7e77e86c 100644 --- a/src/SqlSync.ObjectScript.UnitTest/SqlSync.ObjectScript.UnitTest.csproj +++ b/src/SqlSync.ObjectScript.UnitTest/SqlSync.ObjectScript.UnitTest.csproj @@ -7,9 +7,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/SqlSync.SprocTest/SqlSync.SprocTest.csproj b/src/SqlSync.SprocTest/SqlSync.SprocTest.csproj index 10c8d29d..315d3bd4 100644 --- a/src/SqlSync.SprocTest/SqlSync.SprocTest.csproj +++ b/src/SqlSync.SprocTest/SqlSync.SprocTest.csproj @@ -6,11 +6,11 @@ false - + - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/SqlSync.SqlBuild.Dependent.UnitTest/SqlSync.SqlBuild.Dependent.UnitTest.csproj b/src/SqlSync.SqlBuild.Dependent.UnitTest/SqlSync.SqlBuild.Dependent.UnitTest.csproj index 402787f5..a7e035de 100644 --- a/src/SqlSync.SqlBuild.Dependent.UnitTest/SqlSync.SqlBuild.Dependent.UnitTest.csproj +++ b/src/SqlSync.SqlBuild.Dependent.UnitTest/SqlSync.SqlBuild.Dependent.UnitTest.csproj @@ -31,11 +31,11 @@ - + - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/SqlSync.SqlBuild.UnitTest/SqlSync.SqlBuild.UnitTest.csproj b/src/SqlSync.SqlBuild.UnitTest/SqlSync.SqlBuild.UnitTest.csproj index 81cac1c0..c7c9a7ba 100644 --- a/src/SqlSync.SqlBuild.UnitTest/SqlSync.SqlBuild.UnitTest.csproj +++ b/src/SqlSync.SqlBuild.UnitTest/SqlSync.SqlBuild.UnitTest.csproj @@ -22,11 +22,11 @@ - + - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/SqlSync.SqlBuild/DacPacHelper.cs b/src/SqlSync.SqlBuild/DacPacHelper.cs index 3e0518dc..0578194f 100644 --- a/src/SqlSync.SqlBuild/DacPacHelper.cs +++ b/src/SqlSync.SqlBuild/DacPacHelper.cs @@ -240,7 +240,9 @@ internal static DacpacDeltasStatus CleanDacPacScript(string dacPacGeneratedScrip //look for the database settings header endMatchs = Regex.Matches(cleanedScript, Regex.Escape("$(DatabaseName)")); - endMatch = endMatchs.Cast().LastOrDefault(); + endMatch = endMatchs.Cast().FirstOrDefault(); + + //remove anything before the first match if (endMatch != null && endMatch.Index != -1) { matchFound = true; @@ -249,6 +251,12 @@ internal static DacpacDeltasStatus CleanDacPacScript(string dacPacGeneratedScrip cleanedScript = cleanedScript.Substring(index); } + //Just remove any remaining USE statements + if(endMatchs.Count > 0) + { + cleanedScript = cleanedScript.Replace("USE [$(DatabaseName)];", ""); + } + if (!matchFound) { log.LogInformation("Unable to find script headers, nothing to update?"); diff --git a/src/SqlSync.SqlBuild/SQLSync.SqlBuild.csproj b/src/SqlSync.SqlBuild/SQLSync.SqlBuild.csproj index 30653fa7..ece49e00 100644 --- a/src/SqlSync.SqlBuild/SQLSync.SqlBuild.csproj +++ b/src/SqlSync.SqlBuild/SQLSync.SqlBuild.csproj @@ -16,10 +16,10 @@ - + - + diff --git a/src/SqlSync.SqlBuild/SqlSync.SqlBuild.csproj b/src/SqlSync.SqlBuild/SqlSync.SqlBuild.csproj index 30653fa7..ece49e00 100644 --- a/src/SqlSync.SqlBuild/SqlSync.SqlBuild.csproj +++ b/src/SqlSync.SqlBuild/SqlSync.SqlBuild.csproj @@ -16,10 +16,10 @@ - + - + diff --git a/src/SqlSync.TableScript/SqlSync.TableScript.csproj b/src/SqlSync.TableScript/SqlSync.TableScript.csproj index 4432a867..dde5883b 100644 --- a/src/SqlSync.TableScript/SqlSync.TableScript.csproj +++ b/src/SqlSync.TableScript/SqlSync.TableScript.csproj @@ -49,7 +49,7 @@ - + diff --git a/src/SqlSync/SQLSync.csproj b/src/SqlSync/SQLSync.csproj index 3cae3a1c..f3623625 100644 --- a/src/SqlSync/SQLSync.csproj +++ b/src/SqlSync/SQLSync.csproj @@ -340,7 +340,7 @@ - +