From 8464662dfcf3a6e4fafc33440b33236773d96a65 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sat, 15 Dec 2018 22:40:06 -0600 Subject: Import code from old v4 repo --- src/wixext/SqlCompiler.cs | 793 +++++++++++++++++++++++++++++++++++++++++ src/wixext/SqlDecompiler.cs | 512 ++++++++++++++++++++++++++ src/wixext/SqlErrors.cs | 32 ++ src/wixext/SqlExtensionData.cs | 64 ++++ src/wixext/sql.xsd | 342 ++++++++++++++++++ src/wixext/tables.xml | 73 ++++ src/wixlib/SqlExtension.wxs | 46 +++ src/wixlib/de-de.wxl | 17 + src/wixlib/en-us.wxl | 17 + src/wixlib/es-es.wxl | 18 + src/wixlib/ja-jp.wxl | 17 + src/wixlib/pl-pl.wxl | 17 + src/wixlib/pt-br.wxl | 17 + src/wixlib/pt-pt.wxl | 17 + 14 files changed, 1982 insertions(+) create mode 100644 src/wixext/SqlCompiler.cs create mode 100644 src/wixext/SqlDecompiler.cs create mode 100644 src/wixext/SqlErrors.cs create mode 100644 src/wixext/SqlExtensionData.cs create mode 100644 src/wixext/sql.xsd create mode 100644 src/wixext/tables.xml create mode 100644 src/wixlib/SqlExtension.wxs create mode 100644 src/wixlib/de-de.wxl create mode 100644 src/wixlib/en-us.wxl create mode 100644 src/wixlib/es-es.wxl create mode 100644 src/wixlib/ja-jp.wxl create mode 100644 src/wixlib/pl-pl.wxl create mode 100644 src/wixlib/pt-br.wxl create mode 100644 src/wixlib/pt-pt.wxl (limited to 'src') diff --git a/src/wixext/SqlCompiler.cs b/src/wixext/SqlCompiler.cs new file mode 100644 index 00000000..eecfbba0 --- /dev/null +++ b/src/wixext/SqlCompiler.cs @@ -0,0 +1,793 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Extensions +{ + using System; + using System.Collections.Generic; + using System.Xml.Linq; + using WixToolset.Data; + using WixToolset.Extensibility; + + /// + /// The compiler for the WiX Toolset SQL Server Extension. + /// + public sealed class SqlCompiler : CompilerExtension + { + // sql database attributes definitions (from sca.h) + internal const int DbCreateOnInstall = 0x00000001; + internal const int DbDropOnUninstall = 0x00000002; + internal const int DbContinueOnError = 0x00000004; + internal const int DbDropOnInstall = 0x00000008; + internal const int DbCreateOnUninstall = 0x00000010; + internal const int DbConfirmOverwrite = 0x00000020; + internal const int DbCreateOnReinstall = 0x00000040; + internal const int DbDropOnReinstall = 0x00000080; + + // sql string/script attributes definitions (from sca.h) + internal const int SqlExecuteOnInstall = 0x00000001; + internal const int SqlExecuteOnUninstall = 0x00000002; + internal const int SqlContinueOnError = 0x00000004; + internal const int SqlRollback = 0x00000008; + internal const int SqlExecuteOnReinstall = 0x00000010; + + /// + /// Instantiate a new SqlCompiler. + /// + public SqlCompiler() + { + this.Namespace = "http://wixtoolset.org/schemas/v4/wxs/sql"; + } + + /// + /// Processes an element for the Compiler. + /// + /// Source line number for the parent element. + /// Parent element of element to process. + /// Element to process. + /// Extra information about the context in which this element is being parsed. + public override void ParseElement(XElement parentElement, XElement element, IDictionary context) + { + switch (parentElement.Name.LocalName) + { + case "Component": + string componentId = context["ComponentId"]; + string directoryId = context["DirectoryId"]; + + switch (element.Name.LocalName) + { + case "SqlDatabase": + this.ParseSqlDatabaseElement(element, componentId); + break; + case "SqlScript": + this.ParseSqlScriptElement(element, componentId, null); + break; + case "SqlString": + this.ParseSqlStringElement(element, componentId, null); + break; + default: + this.Core.UnexpectedElement(parentElement, element); + break; + } + break; + case "Fragment": + case "Module": + case "Product": + switch (element.Name.LocalName) + { + case "SqlDatabase": + this.ParseSqlDatabaseElement(element, null); + break; + default: + this.Core.UnexpectedElement(parentElement, element); + break; + } + break; + default: + this.Core.UnexpectedElement(parentElement, element); + break; + } + } + + /// + /// Parses a sql database element + /// + /// Element to parse. + /// Identifier for parent component. + private void ParseSqlDatabaseElement(XElement node, string componentId) + { + SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + string id = null; + int attributes = 0; + string database = null; + string fileSpec = null; + string instance = null; + string logFileSpec = null; + string server = null; + string user = null; + + foreach (XAttribute attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "ConfirmOverwrite": + if (null == componentId) + { + this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + } + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= DbConfirmOverwrite; + } + break; + case "ContinueOnError": + if (null == componentId) + { + this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + } + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= DbContinueOnError; + } + break; + case "CreateOnInstall": + if (null == componentId) + { + this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + } + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= DbCreateOnInstall; + } + break; + case "CreateOnReinstall": + if (null == componentId) + { + this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + } + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= DbCreateOnReinstall; + } + break; + case "CreateOnUninstall": + if (null == componentId) + { + this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + } + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= DbCreateOnUninstall; + } + break; + case "Database": + database = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "DropOnInstall": + if (null == componentId) + { + this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + } + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= DbDropOnInstall; + } + break; + case "DropOnReinstall": + if (null == componentId) + { + this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + } + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= DbDropOnReinstall; + } + break; + + case "DropOnUninstall": + if (null == componentId) + { + this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + } + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= DbDropOnUninstall; + } + break; + case "Instance": + instance = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Server": + server = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "User": + user = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (!this.Core.ContainsProperty(user)) + { + user = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "User", user); + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; + } + } + else + { + this.Core.ParseExtensionAttribute(node, attrib); + } + } + + if (null == id) + { + this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); + } + + if (null == database) + { + this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Database")); + } + else if (128 < database.Length) + { + this.Core.OnMessage(WixErrors.IdentifierTooLongError(sourceLineNumbers, node.Name.LocalName, "Database", database, 128)); + } + + if (null == server) + { + this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Server")); + } + + if (0 == attributes && null != componentId) + { + this.Core.OnMessage(SqlErrors.OneOfAttributesRequiredUnderComponent(sourceLineNumbers, node.Name.LocalName, "CreateOnInstall", "CreateOnUninstall", "DropOnInstall", "DropOnUninstall")); + } + + foreach (XElement child in node.Elements()) + { + if (this.Namespace == child.Name.Namespace) + { + SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + switch (child.Name.LocalName) + { + case "SqlScript": + if (null == componentId) + { + this.Core.OnMessage(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); + } + + this.ParseSqlScriptElement(child, componentId, id); + break; + case "SqlString": + if (null == componentId) + { + this.Core.OnMessage(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); + } + + this.ParseSqlStringElement(child, componentId, id); + break; + case "SqlFileSpec": + if (null == componentId) + { + this.Core.OnMessage(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); + } + else if (null != fileSpec) + { + this.Core.OnMessage(WixErrors.TooManyElements(sourceLineNumbers, node.Name.LocalName, child.Name.LocalName, 1)); + } + + fileSpec = this.ParseSqlFileSpecElement(child); + break; + case "SqlLogFileSpec": + if (null == componentId) + { + this.Core.OnMessage(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); + } + else if (null != logFileSpec) + { + this.Core.OnMessage(WixErrors.TooManyElements(sourceLineNumbers, node.Name.LocalName, child.Name.LocalName, 1)); + } + + logFileSpec = this.ParseSqlFileSpecElement(child); + break; + default: + this.Core.UnexpectedElement(node, child); + break; + } + } + else + { + this.Core.ParseExtensionElement(node, child); + } + } + + if (null != componentId) + { + // Reference InstallSqlData and UninstallSqlData since nothing will happen without it + this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "InstallSqlData"); + this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "UninstallSqlData"); + } + + if (!this.Core.EncounteredError) + { + Row row = this.Core.CreateRow(sourceLineNumbers, "SqlDatabase"); + row[0] = id; + row[1] = server; + row[2] = instance; + row[3] = database; + row[4] = componentId; + row[5] = user; + row[6] = fileSpec; + row[7] = logFileSpec; + if (0 != attributes) + { + row[8] = attributes; + } + } + } + + /// + /// Parses a sql file specification element. + /// + /// Element to parse. + /// Identifier of sql file specification. + private string ParseSqlFileSpecElement(XElement node) + { + SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + string id = null; + string fileName = null; + string growthSize = null; + string maxSize = null; + string name = null; + string size = null; + + foreach (XAttribute attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Filename": + fileName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Size": + size = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "MaxSize": + maxSize = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "GrowthSize": + growthSize = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; + } + } + else + { + this.Core.ParseExtensionAttribute(node, attrib); + } + } + + if (null == id) + { + this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); + } + + if (null == name) + { + this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name")); + } + + if (null == fileName) + { + this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Filename")); + } + + this.Core.ParseForExtensionElements(node); + + if (!this.Core.EncounteredError) + { + Row row = this.Core.CreateRow(sourceLineNumbers, "SqlFileSpec"); + row[0] = id; + row[1] = name; + row[2] = fileName; + if (null != size) + { + row[3] = size; + } + + if (null != maxSize) + { + row[4] = maxSize; + } + + if (null != growthSize) + { + row[5] = growthSize; + } + } + + return id; + } + + /// + /// Parses a sql script element. + /// + /// Element to parse. + /// Identifier for parent component. + /// Optional database to execute script against. + private void ParseSqlScriptElement(XElement node, string componentId, string sqlDb) + { + SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + string id = null; + int attributes = 0; + bool rollbackAttribute = false; + bool nonRollbackAttribute = false; + string binary = null; + int sequence = CompilerConstants.IntegerNotSet; + string user = null; + + foreach (XAttribute attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "BinaryKey": + binary = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "Binary", binary); + break; + case "Sequence": + sequence = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); + break; + case "SqlDb": + if (null != sqlDb) + { + this.Core.OnMessage(WixErrors.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, node.Parent.Name.LocalName)); + } + sqlDb = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "SqlDatabase", sqlDb); + break; + case "User": + user = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "User", user); + break; + + // Flag-setting attributes + case "ContinueOnError": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlContinueOnError; + } + break; + case "ExecuteOnInstall": + if (rollbackAttribute) + { + this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + } + nonRollbackAttribute = true; + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnInstall; + } + break; + case "ExecuteOnReinstall": + if (rollbackAttribute) + { + this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + } + nonRollbackAttribute = true; + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnReinstall; + } + break; + case "ExecuteOnUninstall": + if (rollbackAttribute) + { + this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + } + nonRollbackAttribute = true; + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnUninstall; + } + break; + case "RollbackOnInstall": + if (nonRollbackAttribute) + { + this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); + } + rollbackAttribute = true; + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnInstall; + attributes |= SqlRollback; + } + break; + case "RollbackOnReinstall": + if (nonRollbackAttribute) + { + this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); + } + rollbackAttribute = true; + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnReinstall; + attributes |= SqlRollback; + } + break; + case "RollbackOnUninstall": + if (nonRollbackAttribute) + { + this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); + } + rollbackAttribute = true; + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnUninstall; + attributes |= SqlRollback; + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; + } + } + else + { + this.Core.ParseExtensionAttribute(node, attrib); + } + } + + if (null == id) + { + this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); + } + + if (null == binary) + { + this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "BinaryKey")); + } + + if (null == sqlDb) + { + this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "SqlDb")); + } + + if (0 == attributes) + { + this.Core.OnMessage(WixErrors.ExpectedAttributes(sourceLineNumbers, node.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall", "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + } + + this.Core.ParseForExtensionElements(node); + + // Reference InstallSqlData and UninstallSqlData since nothing will happen without it + this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "InstallSqlData"); + this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "UninstallSqlData"); + + if (!this.Core.EncounteredError) + { + Row row = this.Core.CreateRow(sourceLineNumbers, "SqlScript"); + row[0] = id; + row[1] = sqlDb; + row[2] = componentId; + row[3] = binary; + row[4] = user; + row[5] = attributes; + if (CompilerConstants.IntegerNotSet != sequence) + { + row[6] = sequence; + } + } + } + + /// + /// Parses a sql string element. + /// + /// Element to parse. + /// Identifier for parent component. + /// Optional database to execute string against. + private void ParseSqlStringElement(XElement node, string componentId, string sqlDb) + { + SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + string id = null; + int attributes = 0; + bool rollbackAttribute = false; + bool nonRollbackAttribute = false; + int sequence = CompilerConstants.IntegerNotSet; + string sql = null; + string user = null; + + foreach (XAttribute attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "ContinueOnError": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlContinueOnError; + } + break; + case "ExecuteOnInstall": + if (rollbackAttribute) + { + this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + } + nonRollbackAttribute = true; + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnInstall; + } + break; + case "ExecuteOnReinstall": + if (rollbackAttribute) + { + this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + } + nonRollbackAttribute = true; + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnReinstall; + } + break; + case "ExecuteOnUninstall": + if (rollbackAttribute) + { + this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + } + nonRollbackAttribute = true; + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnUninstall; + } + break; + case "RollbackOnInstall": + if (nonRollbackAttribute) + { + this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); + } + rollbackAttribute = true; + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnInstall; + attributes |= SqlRollback; + } + break; + case "RollbackOnReinstall": + if (nonRollbackAttribute) + { + this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); + } + rollbackAttribute = true; + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnReinstall; + attributes |= SqlRollback; + } + break; + case "RollbackOnUninstall": + if (nonRollbackAttribute) + { + this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); + } + rollbackAttribute = true; + + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnUninstall; + attributes |= SqlRollback; + } + break; + case "Sequence": + sequence = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); + break; + case "SQL": + sql = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "SqlDb": + if (null != sqlDb) + { + this.Core.OnMessage(WixErrors.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, "SqlDb", "SqlDatabase")); + } + + sqlDb = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "SqlDatabase", sqlDb); + break; + case "User": + user = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "User", user); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; + } + } + else + { + this.Core.ParseExtensionAttribute(node, attrib); + } + } + + if (null == id) + { + this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); + } + + if (null == sql) + { + this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "SQL")); + } + + if (null == sqlDb) + { + this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "SqlDb")); + } + + if (0 == attributes) + { + this.Core.OnMessage(WixErrors.ExpectedAttributes(sourceLineNumbers, node.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall", "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + } + + this.Core.ParseForExtensionElements(node); + + // Reference InstallSqlData and UninstallSqlData since nothing will happen without it + this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "InstallSqlData"); + this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "UninstallSqlData"); + + if (!this.Core.EncounteredError) + { + Row row = this.Core.CreateRow(sourceLineNumbers, "SqlString"); + row[0] = id; + row[1] = sqlDb; + row[2] = componentId; + row[3] = sql; + row[4] = user; + row[5] = attributes; + if (CompilerConstants.IntegerNotSet != sequence) + { + row[6] = sequence; + } + } + } + } +} diff --git a/src/wixext/SqlDecompiler.cs b/src/wixext/SqlDecompiler.cs new file mode 100644 index 00000000..64192e84 --- /dev/null +++ b/src/wixext/SqlDecompiler.cs @@ -0,0 +1,512 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Extensions +{ + using System.Collections; + using WixToolset.Data; + using WixToolset.Extensibility; + using Sql = WixToolset.Extensions.Serialize.Sql; + using Wix = WixToolset.Data.Serialize; + + /// + /// The decompiler for the WiX Toolset SQL Server Extension. + /// + public sealed class SqlDecompiler : DecompilerExtension + { + /// + /// Creates a decompiler for SQL Extension. + /// + public SqlDecompiler() + { + this.TableDefinitions = SqlExtensionData.GetExtensionTableDefinitions(); + } + + /// + /// Get the extensions library to be removed. + /// + /// Table definitions for library. + /// Library to remove from decompiled output. + public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions) + { + return SqlExtensionData.GetExtensionLibrary(tableDefinitions); + } + + /// + /// Decompiles an extension table. + /// + /// The table to decompile. + public override void DecompileTable(Table table) + { + switch (table.Name) + { + case "SqlDatabase": + this.DecompileSqlDatabaseTable(table); + break; + case "SqlFileSpec": + // handled in FinalizeSqlFileSpecTable + break; + case "SqlScript": + this.DecompileSqlScriptTable(table); + break; + case "SqlString": + this.DecompileSqlStringTable(table); + break; + default: + base.DecompileTable(table); + break; + } + } + + /// + /// Finalize decompilation. + /// + /// The collection of all tables. + public override void Finish(TableIndexedCollection tables) + { + this.FinalizeSqlFileSpecTable(tables); + this.FinalizeSqlScriptAndSqlStringTables(tables); + } + + /// + /// Decompile the SqlDatabase table. + /// + /// The table to decompile. + private void DecompileSqlDatabaseTable(Table table) + { + foreach (Row row in table.Rows) + { + Sql.SqlDatabase sqlDatabase = new Sql.SqlDatabase(); + + sqlDatabase.Id = (string)row[0]; + + if (null != row[1]) + { + sqlDatabase.Server = (string)row[1]; + } + + if (null != row[2]) + { + sqlDatabase.Instance = (string)row[2]; + } + + sqlDatabase.Database = (string)row[3]; + + if (null != row[5]) + { + sqlDatabase.User = (string)row[5]; + } + + // the FileSpec_ and FileSpec_Log columns will be handled in FinalizeSqlFileSpecTable + + if (null != row[8]) + { + int attributes = (int)row[8]; + + if (SqlCompiler.DbCreateOnInstall == (attributes & SqlCompiler.DbCreateOnInstall)) + { + sqlDatabase.CreateOnInstall = Sql.YesNoType.yes; + } + + if (SqlCompiler.DbDropOnUninstall == (attributes & SqlCompiler.DbDropOnUninstall)) + { + sqlDatabase.DropOnUninstall = Sql.YesNoType.yes; + } + + if (SqlCompiler.DbContinueOnError == (attributes & SqlCompiler.DbContinueOnError)) + { + sqlDatabase.ContinueOnError = Sql.YesNoType.yes; + } + + if (SqlCompiler.DbDropOnInstall == (attributes & SqlCompiler.DbDropOnInstall)) + { + sqlDatabase.DropOnInstall = Sql.YesNoType.yes; + } + + if (SqlCompiler.DbCreateOnUninstall == (attributes & SqlCompiler.DbCreateOnUninstall)) + { + sqlDatabase.CreateOnUninstall = Sql.YesNoType.yes; + } + + if (SqlCompiler.DbConfirmOverwrite == (attributes & SqlCompiler.DbConfirmOverwrite)) + { + sqlDatabase.ConfirmOverwrite = Sql.YesNoType.yes; + } + + if (SqlCompiler.DbCreateOnReinstall == (attributes & SqlCompiler.DbCreateOnReinstall)) + { + sqlDatabase.CreateOnReinstall = Sql.YesNoType.yes; + } + + if (SqlCompiler.DbDropOnReinstall == (attributes & SqlCompiler.DbDropOnReinstall)) + { + sqlDatabase.DropOnReinstall = Sql.YesNoType.yes; + } + } + + if (null != row[4]) + { + Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[4]); + + if (null != component) + { + component.AddChild(sqlDatabase); + } + else + { + this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[4], "Component")); + } + } + else + { + this.Core.RootElement.AddChild(sqlDatabase); + } + this.Core.IndexElement(row, sqlDatabase); + } + } + + /// + /// Decompile the SqlScript table. + /// + /// The table to decompile. + private void DecompileSqlScriptTable(Table table) + { + foreach (Row row in table.Rows) + { + Sql.SqlScript sqlScript = new Sql.SqlScript(); + + sqlScript.Id = (string)row[0]; + + // the Db_ and Component_ columns are handled in FinalizeSqlScriptAndSqlStringTables + + sqlScript.BinaryKey = (string)row[3]; + + if (null != row[4]) + { + sqlScript.User = (string)row[4]; + } + + int attributes = (int)row[5]; + + if (SqlCompiler.SqlContinueOnError == (attributes & SqlCompiler.SqlContinueOnError)) + { + sqlScript.ContinueOnError = Sql.YesNoType.yes; + } + + if (SqlCompiler.SqlExecuteOnInstall == (attributes & SqlCompiler.SqlExecuteOnInstall)) + { + sqlScript.ExecuteOnInstall = Sql.YesNoType.yes; + } + + if (SqlCompiler.SqlExecuteOnReinstall == (attributes & SqlCompiler.SqlExecuteOnReinstall)) + { + sqlScript.ExecuteOnReinstall = Sql.YesNoType.yes; + } + + if (SqlCompiler.SqlExecuteOnUninstall == (attributes & SqlCompiler.SqlExecuteOnUninstall)) + { + sqlScript.ExecuteOnUninstall = Sql.YesNoType.yes; + } + + if ((SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnInstall) == (attributes & (SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnInstall))) + { + sqlScript.RollbackOnInstall = Sql.YesNoType.yes; + } + + if ((SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnReinstall) == (attributes & (SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnReinstall))) + { + sqlScript.RollbackOnReinstall = Sql.YesNoType.yes; + } + + if ((SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnUninstall) == (attributes & (SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnUninstall))) + { + sqlScript.RollbackOnUninstall = Sql.YesNoType.yes; + } + + if (null != row[6]) + { + sqlScript.Sequence = (int)row[6]; + } + + this.Core.IndexElement(row, sqlScript); + } + } + + /// + /// Decompile the SqlString table. + /// + /// The table to decompile. + private void DecompileSqlStringTable(Table table) + { + foreach (Row row in table.Rows) + { + Sql.SqlString sqlString = new Sql.SqlString(); + + sqlString.Id = (string)row[0]; + + // the Db_ and Component_ columns are handled in FinalizeSqlScriptAndSqlStringTables + + sqlString.SQL = (string)row[3]; + + if (null != row[4]) + { + sqlString.User = (string)row[4]; + } + + int attributes = (int)row[5]; + + if (SqlCompiler.SqlContinueOnError == (attributes & SqlCompiler.SqlContinueOnError)) + { + sqlString.ContinueOnError = Sql.YesNoType.yes; + } + + if (SqlCompiler.SqlExecuteOnInstall == (attributes & SqlCompiler.SqlExecuteOnInstall)) + { + sqlString.ExecuteOnInstall = Sql.YesNoType.yes; + } + + if (SqlCompiler.SqlExecuteOnReinstall == (attributes & SqlCompiler.SqlExecuteOnReinstall)) + { + sqlString.ExecuteOnReinstall = Sql.YesNoType.yes; + } + + if (SqlCompiler.SqlExecuteOnUninstall == (attributes & SqlCompiler.SqlExecuteOnUninstall)) + { + sqlString.ExecuteOnUninstall = Sql.YesNoType.yes; + } + + if ((SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnInstall) == (attributes & (SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnInstall))) + { + sqlString.RollbackOnInstall = Sql.YesNoType.yes; + } + + if ((SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnReinstall) == (attributes & (SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnReinstall))) + { + sqlString.RollbackOnReinstall = Sql.YesNoType.yes; + } + + if ((SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnUninstall) == (attributes & (SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnUninstall))) + { + sqlString.RollbackOnUninstall = Sql.YesNoType.yes; + } + + if (null != row[6]) + { + sqlString.Sequence = (int)row[6]; + } + + this.Core.IndexElement(row, sqlString); + } + } + + /// + /// Finalize the SqlFileSpec table. + /// + /// The collection of all tables. + /// + /// Since rows of the SqlFileSpec table are represented by either + /// the SqlFileSpec or SqlLogFileSpec depending upon the context in + /// which they are used in the SqlDatabase table, decompilation of this + /// table must occur after the SqlDatbase parents are decompiled. + /// + private void FinalizeSqlFileSpecTable(TableIndexedCollection tables) + { + Table sqlDatabaseTable = tables["SqlDatabase"]; + Table sqlFileSpecTable = tables["SqlFileSpec"]; + + if (null != sqlDatabaseTable && null != sqlFileSpecTable) + { + Hashtable sqlFileSpecRows = new Hashtable(); + + // index each SqlFileSpec row by its primary key + foreach (Row row in sqlFileSpecTable.Rows) + { + sqlFileSpecRows.Add(row[0], row); + } + + // create the necessary SqlFileSpec and SqlLogFileSpec elements for each row + foreach (Row row in sqlDatabaseTable.Rows) + { + Sql.SqlDatabase sqlDatabase = (Sql.SqlDatabase)this.Core.GetIndexedElement(row); + + if (null != row[6]) + { + Row sqlFileSpecRow = (Row)sqlFileSpecRows[row[6]]; + + if (null != sqlFileSpecRow) + { + Sql.SqlFileSpec sqlFileSpec = new Sql.SqlFileSpec(); + + sqlFileSpec.Id = (string)sqlFileSpecRow[0]; + + if (null != sqlFileSpecRow[1]) + { + sqlFileSpec.Name = (string)sqlFileSpecRow[1]; + } + + sqlFileSpec.Filename = (string)sqlFileSpecRow[2]; + + if (null != sqlFileSpecRow[3]) + { + sqlFileSpec.Size = (string)sqlFileSpecRow[3]; + } + + if (null != sqlFileSpecRow[4]) + { + sqlFileSpec.MaxSize = (string)sqlFileSpecRow[4]; + } + + if (null != sqlFileSpecRow[5]) + { + sqlFileSpec.GrowthSize = (string)sqlFileSpecRow[5]; + } + + sqlDatabase.AddChild(sqlFileSpec); + } + else + { + this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, sqlDatabaseTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "FileSpec_", (string)row[6], "SqlFileSpec")); + } + } + + if (null != row[7]) + { + Row sqlFileSpecRow = (Row)sqlFileSpecRows[row[7]]; + + if (null != sqlFileSpecRow) + { + Sql.SqlLogFileSpec sqlLogFileSpec = new Sql.SqlLogFileSpec(); + + sqlLogFileSpec.Id = (string)sqlFileSpecRow[0]; + + if (null != sqlFileSpecRow[1]) + { + sqlLogFileSpec.Name = (string)sqlFileSpecRow[1]; + } + + sqlLogFileSpec.Filename = (string)sqlFileSpecRow[2]; + + if (null != sqlFileSpecRow[3]) + { + sqlLogFileSpec.Size = (string)sqlFileSpecRow[3]; + } + + if (null != sqlFileSpecRow[4]) + { + sqlLogFileSpec.MaxSize = (string)sqlFileSpecRow[4]; + } + + if (null != sqlFileSpecRow[5]) + { + sqlLogFileSpec.GrowthSize = (string)sqlFileSpecRow[5]; + } + + sqlDatabase.AddChild(sqlLogFileSpec); + } + else + { + this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, sqlDatabaseTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "FileSpec_Log", (string)row[7], "SqlFileSpec")); + } + } + } + } + } + + /// + /// Finalize the SqlScript table. + /// + /// The collection of all tables. + /// + /// The SqlScript and SqlString tables contain a foreign key into the SqlDatabase + /// and Component tables. Depending upon the parent of the SqlDatabase + /// element, the SqlScript and SqlString elements are nested under either the + /// SqlDatabase or the Component element. + /// + private void FinalizeSqlScriptAndSqlStringTables(TableIndexedCollection tables) + { + Table sqlDatabaseTable = tables["SqlDatabase"]; + Table sqlScriptTable = tables["SqlScript"]; + Table sqlStringTable = tables["SqlString"]; + + Hashtable sqlDatabaseRows = new Hashtable(); + + // index each SqlDatabase row by its primary key + if (null != sqlDatabaseTable) + { + foreach (Row row in sqlDatabaseTable.Rows) + { + sqlDatabaseRows.Add(row[0], row); + } + } + + if (null != sqlScriptTable) + { + foreach (Row row in sqlScriptTable.Rows) + { + Sql.SqlScript sqlScript = (Sql.SqlScript)this.Core.GetIndexedElement(row); + + Row sqlDatabaseRow = (Row)sqlDatabaseRows[row[1]]; + string databaseComponent = (string)sqlDatabaseRow[4]; + + // determine if the SqlScript element should be nested under the database or another component + if (null != databaseComponent && databaseComponent == (string)row[2]) + { + Sql.SqlDatabase sqlDatabase = (Sql.SqlDatabase)this.Core.GetIndexedElement(sqlDatabaseRow); + + sqlDatabase.AddChild(sqlScript); + } + else // nest under the component of the SqlDatabase row + { + Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[2]); + + // set the Database value + sqlScript.SqlDb = (string)row[1]; + + if (null != component) + { + component.AddChild(sqlScript); + } + else + { + this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, sqlScriptTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[2], "Component")); + } + } + } + } + + if (null != sqlStringTable) + { + foreach (Row row in sqlStringTable.Rows) + { + Sql.SqlString sqlString = (Sql.SqlString)this.Core.GetIndexedElement(row); + + Row sqlDatabaseRow = (Row)sqlDatabaseRows[row[1]]; + string databaseComponent = (string)sqlDatabaseRow[4]; + + // determine if the SqlScript element should be nested under the database or another component + if (null != databaseComponent && databaseComponent == (string)row[2]) + { + Sql.SqlDatabase sqlDatabase = (Sql.SqlDatabase)this.Core.GetIndexedElement(sqlDatabaseRow); + + sqlDatabase.AddChild(sqlString); + } + else // nest under the component of the SqlDatabase row + { + Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[2]); + + // set the Database value + sqlString.SqlDb = (string)row[1]; + + if (null != component) + { + component.AddChild(sqlString); + } + else + { + this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, sqlStringTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[2], "Component")); + } + } + } + } + } + } +} diff --git a/src/wixext/SqlErrors.cs b/src/wixext/SqlErrors.cs new file mode 100644 index 00000000..2043b658 --- /dev/null +++ b/src/wixext/SqlErrors.cs @@ -0,0 +1,32 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Extensions +{ + public sealed class SqlErrors + { + + private SqlErrors() + { + } + + public static MessageEventArgs IllegalAttributeWithoutComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName) + { + return new SqlErrorEventArgs(sourceLineNumbers, 5100, "SqlErrors_IllegalAttributeWithoutComponent_1", elementName, attributeName); + } + + public static MessageEventArgs IllegalElementWithoutComponent(SourceLineNumber sourceLineNumbers, string elementName) + { + return new SqlErrorEventArgs(sourceLineNumbers, 5101, "SqlErrors_IllegalElementWithoutComponent_1", elementName); + } + + public static MessageEventArgs OneOfAttributesRequiredUnderComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName1, string attributeName2, string attributeName3, string attributeName4) + { + return new SqlErrorEventArgs(sourceLineNumbers, 5102, "SqlErrors_OneOfAttributesRequiredUnderComponent_1", elementName, attributeName1, attributeName2, attributeName3, attributeName4); + } + + public static MessageEventArgs DeprecatedBinaryChildElement(SourceLineNumber sourceLineNumbers, string elementName) + { + return new SqlErrorEventArgs(sourceLineNumbers, 5103, "SqlErrors_DeprecatedBinaryChildElement_1", elementName); + } + } +} \ No newline at end of file diff --git a/src/wixext/SqlExtensionData.cs b/src/wixext/SqlExtensionData.cs new file mode 100644 index 00000000..b43b0341 --- /dev/null +++ b/src/wixext/SqlExtensionData.cs @@ -0,0 +1,64 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Extensions +{ + using System; + using System.Reflection; + using WixToolset.Data; + using WixToolset.Extensibility; + + /// + /// The WiX Toolset SQL Server Extension. + /// + public sealed class SqlExtensionData : ExtensionData + { + /// + /// Gets the default culture. + /// + /// The default culture. + public override string DefaultCulture + { + get { return "en-us"; } + } + + /// + /// Gets the optional table definitions for this extension. + /// + /// The optional table definitions for this extension. + public override TableDefinitionCollection TableDefinitions + { + get + { + return SqlExtensionData.GetExtensionTableDefinitions(); + } + } + + /// + /// Gets the library associated with this extension. + /// + /// The table definitions to use while loading the library. + /// The loaded library. + public override Library GetLibrary(TableDefinitionCollection tableDefinitions) + { + return SqlExtensionData.GetExtensionLibrary(tableDefinitions); + } + + /// + /// Internal mechanism to access the extension's table definitions. + /// + /// Extension's table definitions. + internal static TableDefinitionCollection GetExtensionTableDefinitions() + { + return ExtensionData.LoadTableDefinitionHelper(Assembly.GetExecutingAssembly(), "WixToolset.Extensions.Data.tables.xml"); + } + + /// + /// Internal mechanism to access the extension's library. + /// + /// Extension's library. + internal static Library GetExtensionLibrary(TableDefinitionCollection tableDefinitions) + { + return ExtensionData.LoadLibraryHelper(Assembly.GetExecutingAssembly(), "WixToolset.Extensions.Data.sql.wixlib", tableDefinitions); + } + } +} diff --git a/src/wixext/sql.xsd b/src/wixext/sql.xsd new file mode 100644 index 00000000..161607c9 --- /dev/null +++ b/src/wixext/sql.xsd @@ -0,0 +1,342 @@ + + + + + + + + The source code schema for the WiX Toolset SQL Server Extension. + + + + + + + + + + + + + + + Nesting SqlDatabase under a Component element will result in a SqlDatabase being installed to the machine as the package is installed. + + Nesting SqlDatabase under Product, Fragment, or Module + results in a database "locator" record being created in + the SqlDatabase table. This means that the database + itself is neither installed nor uninstalled by the MSI + package. It does make the database available for referencing + from a SqlString or SqlScript record. This allows MSI to install + SqlScripts or SqlStrings to already existing databases on the machine. + The install will fail if the database does not exist in these cases. + + + The User attribute references credentials specified in a User element. + If a user is not specified then Windows Authentication will be used by default + using the credentials of the user performing the install to execute sql + strings, etc. + + + + + + SQL Database + + + + + + + + + + + + + + + + + + + The name of the database. The value can be a literal value or derived from a + Property element using the Formatted + syntax. + + + + + + + + + + + Specifies whether to create the database when the associated component is reinstalled. Setting CreateOnInstall to yes does not imply CreateOnReinstall is set to yes. CreateOnReinstall must be set in addition to CreateOnInstall for it to be created during both install and reinstall. + + + + + + + + + + + Specifies whether to drop the database when the associated component is reinstalled. Setting DropOnInstall to yes does not imply DropOnReinstall is set to yes. DropOnReinstall must be set in addition to DropOnInstall for it to be dropped during both install and reinstall. + + + + + + + + + + + + + + + File specification for a Sql database. + + + + + ID of the file specification. + + + + + Specifies the logical name for the database file. + + + + + Specifies the operating-system file name for the database file. + + + + + + Specifies the size of the database file. The GB, MB and KB suffixes can be used to specify gigabytes, + megabytes or kilobytes. The default is megabytes if no suffix is specified. When a Size is not + supplied for a database file, SQL Server uses the size of the primary file in the model database. + + + + + + + Specifies the maximum size to which the database file can grow. The GB, MB and KB suffixes can be used to + to specify gigabytes, megabytes or kilobytes. The default is megabytes if no suffix is specified. If + MaxSize is not specified, the file will grow until the disk is full. + + + + + + + Specifies the growth increment of the database file. The GB, MB and KB and % suffixes can be used to + specify gigabytes, megabytes, kilobytes or a percentage of the current file size to grow. The default is + megabytes if no suffix is specified. The default value is 10% if GrowthSize is not specified, and the + minimum value is 64 KB. The GrowthSize setting for a file cannot exceed the MaxSize setting. + + + + + + + + + File specification for a Sql database. + + + + + ID of the log file specification. + + + + + Specifies the logical name for the log file. + + + + + Specifies the operating-system file name for the log file. + + + + + + Specifies the size of the log file. The GB, MB and KB suffixes can be used to specify gigabytes, + megabytes or kilobytes. The default is megabytes if no suffix is specified. When a Size is not + supplied for a log file, SQL Server makes the file 1 MB. + + + + + + + Specifies the maximum size to which the log file can grow. The GB, MB and KB suffixes can be used to + to specify gigabytes, megabytes or kilobytes. The default is megabytes if no suffix is specified. If + MaxSize is not specified, the file will grow until the disk is full. + + + + + + + Specifies the growth increment of the log file. The GB, MB and KB and % suffixes can be used to + specify gigabytes, megabytes, kilobytes or a percentage of the current file size to grow. The default is + megabytes if no suffix is specified. The default value is 10% if GrowthSize is not specified, and the + minimum value is 64 KB. The GrowthSize setting for a file cannot exceed the MaxSize setting. + + + + + + + + + + + + SQL Script + + + + + + required when not child of SqlDatabase + + + + + + + Reference to Binary stream that contains the SQL script to execute. + + + + + Specifies to execute the script when the associated component is installed. This attribute is mutually exclusive with the RollbackOnInstall, RollbackOnReinstall and RollbackOnUninstall attributes. + + + + + Specifies whether to execute the script when the associated component is reinstalled. Setting ExecuteOnInstall to yes does not imply ExecuteOnReinstall is set to yes. ExecuteOnReinstall must be set in addition to ExecuteOnInstall for it to be executed during both install and reinstall. This attribute is mutually exclusive with the RollbackOnInstall, RollbackOnReinstall and RollbackOnUninstall attributes. + + + + + Specifies to execute the script when the associated component is uninstalled. This attribute is mutually exclusive with the RollbackOnInstall, RollbackOnReinstall and RollbackOnUninstall attributes. + + + + + Specifies whether to execute the script on rollback if an attempt is made to install the associated component. This attribute is mutually exclusive with the ExecuteOnInstall, ExecuteOnReinstall and ExecuteOnUninstall attributes. + + + + + Specifies whether to execute the script on rollback if an attempt is made to reinstall the associated component. This attribute is mutually exclusive with the ExecuteOnInstall, ExecuteOnReinstall and ExecuteOnUninstall attributes. + + + + + Specifies whether to execute the script on rollback if an attempt is made to uninstall the associated component. This attribute is mutually exclusive with the ExecuteOnInstall, ExecuteOnReinstall and ExecuteOnUninstall attributes. + + + + + Continue executing scripts even if this one fails. + + + + + Specifes the order to run the SQL Scripts. It is recommended that rollback scripts be scheduled before their complementary execution script. This order is also relative across the SqlString element. + + + + + + + + + + + SQL String + + + + + + + + + + + + + Specifies to execute the string when the associated component is installed. This attribute is mutually exclusive with the RollbackOnInstall, RollbackOnReinstall and RollbackOnUninstall attributes. + + + + + + Specifies whether to execute the string when the associated component is reinstalled. Setting ExecuteOnInstall to yes does not imply ExecuteOnReinstall is set to yes. ExecuteOnReinstall must be set in addition to ExecuteOnInstall for it to be executed during both install and reinstall. This attribute is mutually exclusive with the RollbackOnInstall, RollbackOnReinstall and RollbackOnUninstall attributes. + + + + + + Specifies to execute the string when the associated component is uninstalled. This attribute is mutually exclusive with the RollbackOnInstall, RollbackOnReinstall and RollbackOnUninstall attributes. + + + + + Specifies whether to execute the string on rollback if an attempt is made to install the associated component. This attribute is mutually exclusive with the ExecuteOnInstall, ExecuteOnReinstall and ExecuteOnUninstall attributes. + + + + + Specifies whether to execute the string on rollback if an attempt is made to reinstall the associated component. This attribute is mutually exclusive with the ExecuteOnInstall, ExecuteOnReinstall and ExecuteOnUninstall attributes. + + + + + Specifies whether to execute the string on rollback if an attempt is made to uninstall the associated component. This attribute is mutually exclusive with the ExecuteOnInstall, ExecuteOnReinstall and ExecuteOnUninstall attributes. + + + + + Continue executing strings even if this one fails. + + + + + Specifes the order to run the SQL Strings. It is recommended that rollback strings be scheduled before their complementary execution string. This order is also relative across the SqlScript element. + + + + + + + + Values of this type will either be "yes" or "no". + + + + + + + + diff --git a/src/wixext/tables.xml b/src/wixext/tables.xml new file mode 100644 index 00000000..a8b6c3a1 --- /dev/null +++ b/src/wixext/tables.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/wixlib/SqlExtension.wxs b/src/wixlib/SqlExtension.wxs new file mode 100644 index 00000000..2ee9a3ab --- /dev/null +++ b/src/wixlib/SqlExtension.wxs @@ -0,0 +1,46 @@ + + + + + + + + + + + + !(loc.msierrSQLFailedCreateDatabase) + !(loc.msierrSQLFailedDropDatabase) + !(loc.msierrSQLFailedConnectDatabase) + !(loc.msierrSQLFailedExecString) + !(loc.msierrSQLDatabaseAlreadyExists) + + !(loc.ConfigureSql) + !(loc.ConfigureSql) + !(loc.CreateDatabase) + !(loc.DropDatabase) + !(loc.ExecuteSqlStrings) + !(loc.RollbackExecuteSqlStrings) + + + + + + + + + + + + + NOT SKIPUNINSTALLSQLDATA AND VersionNT > 400 + NOT SKIPINSTALLSQLDATA AND VersionNT > 400 + + + + + + + + + diff --git a/src/wixlib/de-de.wxl b/src/wixlib/de-de.wxl new file mode 100644 index 00000000..39a73e8c --- /dev/null +++ b/src/wixlib/de-de.wxl @@ -0,0 +1,17 @@ + + + + + + Fehler [2]: Erstellen der SQL-Datenbank fehlgeschlagen: [3], Fehlerbeschreibung: [4]. + Fehler [2]: Löschen der SQL-Datenbank fehlgeschlagen: [3], Fehlerbeschreibung: [4]. + Verbinden mit der SQL-Datenbank fehlgeschlagen. ([2] [3] [4] [5]) + Fehler [2]: Das Erstellen der SQL Zeichenfolge ist fehlgeschlagen, Fehlerbeschreibung: [3], SQL-Schlüssel: [4] SQL-Zeichenfolge: [5] + Die Datenbank [3] existiert bereits. Wollen Sie fortfahren? + + Konfiguriere SQL Server + Erstelle Datenbanken + Lösche Datenbanken + SQL-Zeichenfolgen werden erstellt + SQL-Zeichenfolgen werden zurückgesetzt + diff --git a/src/wixlib/en-us.wxl b/src/wixlib/en-us.wxl new file mode 100644 index 00000000..d89b1c6c --- /dev/null +++ b/src/wixlib/en-us.wxl @@ -0,0 +1,17 @@ + + + + + + Error [2]: failed to create SQL database: [3], error detail: [4]. + Error [2]: failed to drop SQL database: [3], error detail: [4]. + Failed to connect to SQL database. ([2] [3] [4] [5]) + Error [2]: failed to execute SQL string, error detail: [3], SQL key: [4] SQL string: [5] + The database [3] already exists. Do you want to continue? + + Configuring SQL Server + Creating Databases + Dropping Databases + Executing SQL Strings + Rolling back SQL Strings + diff --git a/src/wixlib/es-es.wxl b/src/wixlib/es-es.wxl new file mode 100644 index 00000000..bc5d0582 --- /dev/null +++ b/src/wixlib/es-es.wxl @@ -0,0 +1,18 @@ + + + + + + Error [2]: falla al crear la base de datos SQL: [3], detalle del error: [4]. + Error [2]: falla al poner la base de datos SQL: [3], detalle del error: [4]. + Falla al conectarse con la base de datos SQL. ([2] [3] [4] [5]) + Error [2]: falla al ejecutar la cadena SQL, detalle del error: [3], Clave SQL: [4] Cadena SQL: [5] + La base de datos [3] ya existe. ¿Desea continuar? + + Configurando SQL Server + Creando Bases de Datos + Colocando Bases de Datos + Ejecutando cadenas SQL + Revirtiendo cadenas SQL + + diff --git a/src/wixlib/ja-jp.wxl b/src/wixlib/ja-jp.wxl new file mode 100644 index 00000000..23c9aebe --- /dev/null +++ b/src/wixlib/ja-jp.wxl @@ -0,0 +1,17 @@ + + + + + + エラー [2]: SQL データベース [3] 作成に失敗しました、エラー詳細: [4]。 + エラー [2]: SQL データベース [3] の削除に失敗しました、エラー詳細: [4]。 + SQL データベースへ接続できませんでした。 ([2] [3] [4] [5]) + エラー [2]: SQL ストリングの実行に失敗しました、エラー詳細: [3]、 SQL キー: [4] SQL ストリング: [5] + データベース [3] は既に存在します。続行しますか? + + SQL サーバーを構成しています + データベースを作成しています + データベースを削除しています + SQL ストリングを実行しています + SQL ストリングをロールバックしています + diff --git a/src/wixlib/pl-pl.wxl b/src/wixlib/pl-pl.wxl new file mode 100644 index 00000000..4f0c7f75 --- /dev/null +++ b/src/wixlib/pl-pl.wxl @@ -0,0 +1,17 @@ + + + + + + Błąd [2]: nie udało się utworzyć bazy danych: [3]. Szczegóły błędu: [4]. + Błąd [2]: nie udało się usunąć bazy danych: [3]. Szczegóły błędu: [4]. + Nie udało się połączyć z bazą danych. ([2] [3] [4] [5]) + Błąd [2]: nie udało się wykonać zapytania SQL. Szczegóły błędu: [3], klucz: [4] zapytanie SQL: [5] + Baza danych [3] już istnieje. Czy chcesz kontynuować? + + Konfigurowanie programu SQL Server + Tworzenie baz danych + Usuwanie baz danych + Wykonywanie zapytań SQL + Cofanie zapytań SQL + diff --git a/src/wixlib/pt-br.wxl b/src/wixlib/pt-br.wxl new file mode 100644 index 00000000..63bbc21e --- /dev/null +++ b/src/wixlib/pt-br.wxl @@ -0,0 +1,17 @@ + + + + + + Error [2]: falha ao criar o Banco de Dados: [3], detalhes: [4]. + Error [2]: falha ao remover o Banco de Dados: [3], detalhes: [4]. + Falhou a ligação ao Banco de Dados. ([2] [3] [4] [5]) + Erro [2]: falha ao executar o comando de SQL, detalhes: [3], Comando: [4] Conteúdo: [5] + O Banco de Dados [3] já existe. Deseja continuar? + + Configurando o Servidor de SQL + Criando os Bancos de Dados + Removendo os Bancos de Dados + Executando comandos de SQL + Revertendo os comandos de SQL + diff --git a/src/wixlib/pt-pt.wxl b/src/wixlib/pt-pt.wxl new file mode 100644 index 00000000..28c43878 --- /dev/null +++ b/src/wixlib/pt-pt.wxl @@ -0,0 +1,17 @@ + + + + + + Error [2]: falha ao criar a Base de Dados: [3], detalhes: [4]. + Error [2]: falha ao remover a Base de Dados: [3], detalhes: [4]. + Falhou a ligação à Base de Dados. ([2] [3] [4] [5]) + Erro [2]: falha ao executar o comando de SQL, detalhes: [3], Comando: [4] Conteúdo: [5] + A Base de Dados [3] já existe. Deseja continuar? + + Configurar o Servidor de SQL + Criar as Bases de Dados + Remover as Bases de Dados + Executar comandos de SQL + Reverter os comandos de SQL + -- cgit v1.2.3-55-g6feb From 1b7a9d3734119e658c91ebd9742ab5a3ce94cce4 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 16 Dec 2018 11:57:53 -0600 Subject: Integrate into latest v4. Still needs TupleDefinitions. --- Sql.wixext.sln | 58 +++ appveyor.cmd | 13 + appveyor.yml | 29 ++ nuget.config | 16 + src/Cpp.Build.props | 100 ++++++ src/Directory.Build.props | 29 ++ src/FindLocalWix.props | 8 + src/ca/dllmain.cpp | 26 ++ src/ca/packages.config | 6 + src/ca/precomp.h | 13 + src/ca/sqlca.cpp | 3 + src/ca/sqlca.def | 7 + src/ca/sqlca.vcxproj | 70 ++++ src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs | 32 ++ .../TestData/UsingSql/Package.en-us.wxl | 11 + .../TestData/UsingSql/Package.wxs | 22 ++ .../TestData/UsingSql/PackageComponents.wxs | 14 + .../TestData/UsingSql/example.txt | 1 + .../WixToolsetTest.Sql/WixToolsetTest.Sql.csproj | 42 +++ src/wixext/SqlCompiler.cs | 391 ++++++++++----------- src/wixext/SqlDecompiler.cs | 4 +- src/wixext/SqlErrors.cs | 42 ++- src/wixext/SqlExtensionData.cs | 50 +-- src/wixext/SqlExtensionFactory.cs | 18 + src/wixext/SqlWindowsInstallerBackendExtension.cs | 31 ++ src/wixext/WixToolset.Sql.wixext.csproj | 36 ++ src/wixext/WixToolset.Sql.wixext.targets | 11 + src/wixlib/SqlExtension.wxs | 17 +- src/wixlib/caerr.wxi | 96 +++++ src/wixlib/packages.config | 5 + src/wixlib/sql.v3.ncrunchproject | 5 + src/wixlib/sql.wixproj | 46 +++ version.json | 11 + 33 files changed, 1000 insertions(+), 263 deletions(-) create mode 100644 Sql.wixext.sln create mode 100644 appveyor.cmd create mode 100644 appveyor.yml create mode 100644 nuget.config create mode 100644 src/Cpp.Build.props create mode 100644 src/Directory.Build.props create mode 100644 src/FindLocalWix.props create mode 100644 src/ca/dllmain.cpp create mode 100644 src/ca/packages.config create mode 100644 src/ca/precomp.h create mode 100644 src/ca/sqlca.cpp create mode 100644 src/ca/sqlca.def create mode 100644 src/ca/sqlca.vcxproj create mode 100644 src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs create mode 100644 src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.en-us.wxl create mode 100644 src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs create mode 100644 src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs create mode 100644 src/test/WixToolsetTest.Sql/TestData/UsingSql/example.txt create mode 100644 src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj create mode 100644 src/wixext/SqlExtensionFactory.cs create mode 100644 src/wixext/SqlWindowsInstallerBackendExtension.cs create mode 100644 src/wixext/WixToolset.Sql.wixext.csproj create mode 100644 src/wixext/WixToolset.Sql.wixext.targets create mode 100644 src/wixlib/caerr.wxi create mode 100644 src/wixlib/packages.config create mode 100644 src/wixlib/sql.v3.ncrunchproject create mode 100644 src/wixlib/sql.wixproj create mode 100644 version.json (limited to 'src') diff --git a/Sql.wixext.sln b/Sql.wixext.sln new file mode 100644 index 00000000..f033987f --- /dev/null +++ b/Sql.wixext.sln @@ -0,0 +1,58 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2016 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlca", "src\ca\sqlca.vcxproj", "{4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}" +EndProject +Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "sql", "src\wixlib\sql.wixproj", "{9ACF1A20-D801-45CC-A463-F9D13E506AA3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Sql.wixext", "src\wixext\WixToolset.Sql.wixext.csproj", "{0E05519A-0045-4AEC-BD0C-D9205FF1468F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.Sql", "src\test\WixToolsetTest.Sql\WixToolsetTest.Sql.csproj", "{FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Debug|x86.ActiveCfg = Debug|Win32 + {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Debug|x86.Build.0 = Debug|Win32 + {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Release|Any CPU.ActiveCfg = Release|Win32 + {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Release|x86.ActiveCfg = Release|Win32 + {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Release|x86.Build.0 = Release|Win32 + {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Debug|Any CPU.ActiveCfg = Debug|x86 + {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Debug|Any CPU.Build.0 = Debug|x86 + {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Debug|x86.ActiveCfg = Debug|x86 + {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Debug|x86.Build.0 = Debug|x86 + {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Release|Any CPU.ActiveCfg = Release|x86 + {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Release|x86.ActiveCfg = Release|x86 + {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Release|x86.Build.0 = Release|x86 + {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Debug|x86.ActiveCfg = Debug|Any CPU + {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Debug|x86.Build.0 = Debug|Any CPU + {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Release|Any CPU.Build.0 = Release|Any CPU + {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Release|x86.ActiveCfg = Release|Any CPU + {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Release|x86.Build.0 = Release|Any CPU + {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Debug|x86.ActiveCfg = Debug|Any CPU + {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Debug|x86.Build.0 = Debug|Any CPU + {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Release|Any CPU.Build.0 = Release|Any CPU + {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Release|x86.ActiveCfg = Release|Any CPU + {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DEFEE3BB-E557-4B77-A85C-ECA19D6F5DF5} + EndGlobalSection +EndGlobal diff --git a/appveyor.cmd b/appveyor.cmd new file mode 100644 index 00000000..192b3ba5 --- /dev/null +++ b/appveyor.cmd @@ -0,0 +1,13 @@ +@setlocal +@pushd %~dp0 + +nuget restore + +msbuild -p:Configuration=Release -t:Restore + +msbuild -p:Configuration=Release src\test\WixToolsetTest.Sql\WixToolsetTest.Sql.csproj + +msbuild -p:Configuration=Release -t:Pack src\wixext\WixToolset.Sql.wixext.csproj + +@popd +@endlocal \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..0c74d54b --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,29 @@ +image: Visual Studio 2017 + +version: 0.0.0.{build} +configuration: Release + +environment: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + NUGET_XMLDOC_MODE: skip + +build_script: + - appveyor.cmd + +pull_requests: + do_not_increment_build_number: true + +nuget: + disable_publish_on_pr: true + +skip_tags: true + +artifacts: +- path: build\Release\**\*.nupkg + name: nuget + +notifications: +- provider: Slack + incoming_webhook: + secure: p5xuu+4x2JHfwGDMDe5KcG1k7gZxqYc4jWVwvyNZv5cvkubPD2waJs5yXMAXZNN7Z63/3PWHb7q4KoY/99AjauYa1nZ4c5qYqRPFRBKTHfA= diff --git a/nuget.config b/nuget.config new file mode 100644 index 00000000..aaee3228 --- /dev/null +++ b/nuget.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props new file mode 100644 index 00000000..296b36ca --- /dev/null +++ b/src/Cpp.Build.props @@ -0,0 +1,100 @@ + + + + + + Win32 + $(BaseIntermediateOutputPath)$(Configuration)\$(Platform)\ + $(OutputPath)$(Platform)\ + + + + + $(DisableSpecificCompilerWarnings) + Level4 + $(ProjectDir)inc;$(MSBuildProjectDirectory);$(IntDir);$(SqlCESdkIncludePath);$(ProjectAdditionalIncludeDirectories);%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + Use + precomp.h + StdCall + true + false + -YlprecompDefine + /Zc:threadSafeInit- %(AdditionalOptions) + true + + + $(ArmPreprocessorDefinitions);%(PreprocessorDefinitions) + $(ProjectAdditionalResourceIncludeDirectories);%(AdditionalIncludeDirectories) + + + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ProjectAdditionalLibraryDirectories);%(AdditionalLibraryDirectories) + + + $(ProjectSubSystem) + $(ProjectModuleDefinitionFile) + $(ResourceOnlyDll) + true + $(ProjectAdditionalLinkLibraries);advapi32.lib;comdlg32.lib;user32.lib;oleaut32.lib;gdi32.lib;shell32.lib;ole32.lib;version.lib;%(AdditionalDependencies) + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ArmLibraryDirectories);$(ProjectAdditionalLinkLibraryDirectories);%(AdditionalLibraryDirectories) + /IGNORE:4099 %(AdditionalOptions) + + + + + + NoExtensions + + + + + CDecl + + + + + OldStyle + true + true + + + + + Disabled + EnableFastChecks + _DEBUG;DEBUG;%(PreprocessorDefinitions) + MultiThreadedDebug + + + + + + MultiThreadedDebugDll + + + + + MinSpace + NDEBUG;%(PreprocessorDefinitions) + true + true + MultiThreaded + + + true + true + + + + + + MultiThreadedDll + + + + + $(LinkKeyFile) + $(LinkDelaySign) + + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 00000000..9eacf3f5 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,29 @@ + + + + + + Debug + false + + $(MSBuildProjectName) + $(MSBuildThisFileDirectory)..\build\ + $(BaseOutputPath)obj\$(ProjectName)\ + $(BaseOutputPath)$(Configuration)\ + + WiX Toolset Team + WiX Toolset + Copyright (c) .NET Foundation and contributors. All rights reserved. + WiX Toolset + + + + $(MSBuildThisFileDirectory)..\..\ + + + + + diff --git a/src/FindLocalWix.props b/src/FindLocalWix.props new file mode 100644 index 00000000..a784e352 --- /dev/null +++ b/src/FindLocalWix.props @@ -0,0 +1,8 @@ + + + + + + $(MSBuildThisFileDirectory)..\..\Tools\build\Debug\net461\wix.targets + + diff --git a/src/ca/dllmain.cpp b/src/ca/dllmain.cpp new file mode 100644 index 00000000..35ae6d1c --- /dev/null +++ b/src/ca/dllmain.cpp @@ -0,0 +1,26 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +/******************************************************************** +DllMain - standard entry point for all WiX custom actions + +********************************************************************/ +extern "C" BOOL WINAPI DllMain( + IN HINSTANCE hInst, + IN ULONG ulReason, + IN LPVOID) +{ + switch(ulReason) + { + case DLL_PROCESS_ATTACH: + WcaGlobalInitialize(hInst); + break; + + case DLL_PROCESS_DETACH: + WcaGlobalFinalize(); + break; + } + + return TRUE; +} diff --git a/src/ca/packages.config b/src/ca/packages.config new file mode 100644 index 00000000..b74ff5d0 --- /dev/null +++ b/src/ca/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/ca/precomp.h b/src/ca/precomp.h new file mode 100644 index 00000000..3edad7ed --- /dev/null +++ b/src/ca/precomp.h @@ -0,0 +1,13 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +#include +#include + +#define MAXUINT USHRT_MAX +#include + +#include "wcautil.h" +#include "fileutil.h" +#include "strutil.h" diff --git a/src/ca/sqlca.cpp b/src/ca/sqlca.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/ca/sqlca.cpp @@ -0,0 +1,3 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" diff --git a/src/ca/sqlca.def b/src/ca/sqlca.def new file mode 100644 index 00000000..e16626b3 --- /dev/null +++ b/src/ca/sqlca.def @@ -0,0 +1,7 @@ +; Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +LIBRARY "sqlca" + +EXPORTS + diff --git a/src/ca/sqlca.vcxproj b/src/ca/sqlca.vcxproj new file mode 100644 index 00000000..3d638f6e --- /dev/null +++ b/src/ca/sqlca.vcxproj @@ -0,0 +1,70 @@ + + + + + + + + + + Debug + Win32 + + + Release + Win32 + + + + + {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935} + DynamicLibrary + sqlca + v141 + Unicode + sqlca.def + WiX Toolset Sql CustomAction + $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) + + + + + + + + + + + + + + msi.lib + + + + + Create + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + diff --git a/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs b/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs new file mode 100644 index 00000000..831bcd83 --- /dev/null +++ b/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs @@ -0,0 +1,32 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolsetTest.Sql +{ + using System.Linq; + using WixBuildTools.TestSupport; + using WixToolset.Core.TestPackage; + using WixToolset.Sql; + using Xunit; + + public class SqlExtensionFixture + { + [Fact] + public void CanBuildUsingSqlString() + { + var folder = TestData.Get(@"TestData\UsingSql"); + var build = new Builder(folder, typeof(SqlExtensionFactory), new[] { folder }); + + var results = build.BuildAndQuery(Build, "SqlString"); + Assert.Equal(new[] + { + "SqlString:", + }, results.OrderBy(s => s).ToArray()); + } + + private static void Build(string[] args) + { + var result = WixRunner.Execute(args) + .AssertSuccess(); + } + } +} diff --git a/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.en-us.wxl b/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs b/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs new file mode 100644 index 00000000..68ff98fd --- /dev/null +++ b/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs b/src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs new file mode 100644 index 00000000..d2572659 --- /dev/null +++ b/src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.Sql/TestData/UsingSql/example.txt b/src/test/WixToolsetTest.Sql/TestData/UsingSql/example.txt new file mode 100644 index 00000000..1b4ffe8a --- /dev/null +++ b/src/test/WixToolsetTest.Sql/TestData/UsingSql/example.txt @@ -0,0 +1 @@ +This is example.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj b/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj new file mode 100644 index 00000000..6efa50a3 --- /dev/null +++ b/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj @@ -0,0 +1,42 @@ + + + + + + netcoreapp2.1 + false + + + + NU1701 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/wixext/SqlCompiler.cs b/src/wixext/SqlCompiler.cs index eecfbba0..c789f3bd 100644 --- a/src/wixext/SqlCompiler.cs +++ b/src/wixext/SqlCompiler.cs @@ -1,6 +1,6 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -namespace WixToolset.Extensions +namespace WixToolset.Sql { using System; using System.Collections.Generic; @@ -11,7 +11,7 @@ namespace WixToolset.Extensions /// /// The compiler for the WiX Toolset SQL Server Extension. /// - public sealed class SqlCompiler : CompilerExtension + public sealed class SqlCompiler : BaseCompilerExtension { // sql database attributes definitions (from sca.h) internal const int DbCreateOnInstall = 0x00000001; @@ -30,22 +30,17 @@ namespace WixToolset.Extensions internal const int SqlRollback = 0x00000008; internal const int SqlExecuteOnReinstall = 0x00000010; - /// - /// Instantiate a new SqlCompiler. - /// - public SqlCompiler() - { - this.Namespace = "http://wixtoolset.org/schemas/v4/wxs/sql"; - } + public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/sql"; /// /// Processes an element for the Compiler. /// - /// Source line number for the parent element. + /// + /// /// Parent element of element to process. /// Element to process. - /// Extra information about the context in which this element is being parsed. - public override void ParseElement(XElement parentElement, XElement element, IDictionary context) + /// Extra information about the context in which this element is being parsed. + public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) { switch (parentElement.Name.LocalName) { @@ -56,16 +51,16 @@ namespace WixToolset.Extensions switch (element.Name.LocalName) { case "SqlDatabase": - this.ParseSqlDatabaseElement(element, componentId); + this.ParseSqlDatabaseElement(intermediate, section, element, componentId); break; case "SqlScript": - this.ParseSqlScriptElement(element, componentId, null); + this.ParseSqlScriptElement(intermediate, section, element, componentId, null); break; case "SqlString": - this.ParseSqlStringElement(element, componentId, null); + this.ParseSqlStringElement(intermediate, section, element, componentId, null); break; default: - this.Core.UnexpectedElement(parentElement, element); + this.ParseHelper.UnexpectedElement(parentElement, element); break; } break; @@ -75,15 +70,15 @@ namespace WixToolset.Extensions switch (element.Name.LocalName) { case "SqlDatabase": - this.ParseSqlDatabaseElement(element, null); + this.ParseSqlDatabaseElement(intermediate, section, element, null); break; default: - this.Core.UnexpectedElement(parentElement, element); + this.ParseHelper.UnexpectedElement(parentElement, element); break; } break; default: - this.Core.UnexpectedElement(parentElement, element); + this.ParseHelper.UnexpectedElement(parentElement, element); break; } } @@ -91,36 +86,38 @@ namespace WixToolset.Extensions /// /// Parses a sql database element /// - /// Element to parse. + /// + /// + /// Element to parse. /// Identifier for parent component. - private void ParseSqlDatabaseElement(XElement node, string componentId) + private void ParseSqlDatabaseElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - string id = null; + SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + Identifier id = null; int attributes = 0; string database = null; - string fileSpec = null; + Identifier fileSpec = null; string instance = null; - string logFileSpec = null; + Identifier logFileSpec = null; string server = null; string user = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (XAttribute attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "ConfirmOverwrite": if (null == componentId) { - this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); } - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DbConfirmOverwrite; } @@ -128,10 +125,10 @@ namespace WixToolset.Extensions case "ContinueOnError": if (null == componentId) { - this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); } - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DbContinueOnError; } @@ -139,10 +136,10 @@ namespace WixToolset.Extensions case "CreateOnInstall": if (null == componentId) { - this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); } - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DbCreateOnInstall; } @@ -150,10 +147,10 @@ namespace WixToolset.Extensions case "CreateOnReinstall": if (null == componentId) { - this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); } - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DbCreateOnReinstall; } @@ -161,24 +158,24 @@ namespace WixToolset.Extensions case "CreateOnUninstall": if (null == componentId) { - this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); } - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DbCreateOnUninstall; } break; case "Database": - database = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + database = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "DropOnInstall": if (null == componentId) { - this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); } - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DbDropOnInstall; } @@ -186,10 +183,10 @@ namespace WixToolset.Extensions case "DropOnReinstall": if (null == componentId) { - this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); } - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DbDropOnReinstall; } @@ -198,142 +195,141 @@ namespace WixToolset.Extensions case "DropOnUninstall": if (null == componentId) { - this.Core.OnMessage(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); } - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= DbDropOnUninstall; } break; case "Instance": - instance = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + instance = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Server": - server = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + server = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "User": - user = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (!this.Core.ContainsProperty(user)) + user = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + if (!this.ParseHelper.ContainsProperty(user)) { - user = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "User", user); + user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "User", user); } break; default: - this.Core.UnexpectedAttribute(node, attrib); + this.ParseHelper.UnexpectedAttribute(element, attrib); break; } } else { - this.Core.ParseExtensionAttribute(node, attrib); + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); } } if (null == id) { - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); } if (null == database) { - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Database")); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Database")); } else if (128 < database.Length) { - this.Core.OnMessage(WixErrors.IdentifierTooLongError(sourceLineNumbers, node.Name.LocalName, "Database", database, 128)); + this.Messaging.Write(ErrorMessages.IdentifierTooLongError(sourceLineNumbers, element.Name.LocalName, "Database", database, 128)); } if (null == server) { - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Server")); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Server")); } if (0 == attributes && null != componentId) { - this.Core.OnMessage(SqlErrors.OneOfAttributesRequiredUnderComponent(sourceLineNumbers, node.Name.LocalName, "CreateOnInstall", "CreateOnUninstall", "DropOnInstall", "DropOnUninstall")); + this.Messaging.Write(SqlErrors.OneOfAttributesRequiredUnderComponent(sourceLineNumbers, element.Name.LocalName, "CreateOnInstall", "CreateOnUninstall", "DropOnInstall", "DropOnUninstall")); } - foreach (XElement child in node.Elements()) + foreach (XElement child in element.Elements()) { if (this.Namespace == child.Name.Namespace) { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + SourceLineNumber childSourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(child); switch (child.Name.LocalName) { case "SqlScript": if (null == componentId) { - this.Core.OnMessage(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); + this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); } - this.ParseSqlScriptElement(child, componentId, id); + this.ParseSqlScriptElement(intermediate, section, child, componentId, id.Id); break; case "SqlString": if (null == componentId) { - this.Core.OnMessage(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); + this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); } - this.ParseSqlStringElement(child, componentId, id); + this.ParseSqlStringElement(intermediate, section, child, componentId, id.Id); break; case "SqlFileSpec": if (null == componentId) { - this.Core.OnMessage(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); + this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); } else if (null != fileSpec) { - this.Core.OnMessage(WixErrors.TooManyElements(sourceLineNumbers, node.Name.LocalName, child.Name.LocalName, 1)); + this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, element.Name.LocalName, child.Name.LocalName, 1)); } - fileSpec = this.ParseSqlFileSpecElement(child); + fileSpec = this.ParseSqlFileSpecElement(intermediate, section, child); break; case "SqlLogFileSpec": if (null == componentId) { - this.Core.OnMessage(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); + this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); } else if (null != logFileSpec) { - this.Core.OnMessage(WixErrors.TooManyElements(sourceLineNumbers, node.Name.LocalName, child.Name.LocalName, 1)); + this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, element.Name.LocalName, child.Name.LocalName, 1)); } - logFileSpec = this.ParseSqlFileSpecElement(child); + logFileSpec = this.ParseSqlFileSpecElement(intermediate, section, child); break; default: - this.Core.UnexpectedElement(node, child); + this.ParseHelper.UnexpectedElement(element, child); break; } } else { - this.Core.ParseExtensionElement(node, child); + this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, element, child); } } if (null != componentId) { // Reference InstallSqlData and UninstallSqlData since nothing will happen without it - this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "InstallSqlData"); - this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "UninstallSqlData"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "InstallSqlData"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "UninstallSqlData"); } - if (!this.Core.EncounteredError) + if (!this.Messaging.EncounteredError) { - Row row = this.Core.CreateRow(sourceLineNumbers, "SqlDatabase"); - row[0] = id; - row[1] = server; - row[2] = instance; - row[3] = database; - row[4] = componentId; - row[5] = user; - row[6] = fileSpec; - row[7] = logFileSpec; + var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlDatabase", id); + row.Set(1, server); + row.Set(2, instance); + row.Set(3, database); + row.Set(4, componentId); + row.Set(5, user); + row.Set(6, fileSpec.Id); + row.Set(7, logFileSpec.Id); if (0 != attributes) { - row[8] = attributes; + row.Set(8, attributes); } } } @@ -341,89 +337,90 @@ namespace WixToolset.Extensions /// /// Parses a sql file specification element. /// - /// Element to parse. + /// + /// + /// Element to parse. /// Identifier of sql file specification. - private string ParseSqlFileSpecElement(XElement node) + private Identifier ParseSqlFileSpecElement(Intermediate intermediate, IntermediateSection section, XElement element) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - string id = null; + SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + Identifier id = null; string fileName = null; string growthSize = null; string maxSize = null; string name = null; string size = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (XAttribute attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "Name": - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + name = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Filename": - fileName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + fileName = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "Size": - size = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + size = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "MaxSize": - maxSize = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + maxSize = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "GrowthSize": - growthSize = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + growthSize = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; default: - this.Core.UnexpectedAttribute(node, attrib); + this.ParseHelper.UnexpectedAttribute(element, attrib); break; } } else { - this.Core.ParseExtensionAttribute(node, attrib); + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); } } if (null == id) { - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); } if (null == name) { - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name")); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Name")); } if (null == fileName) { - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Filename")); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Filename")); } - this.Core.ParseForExtensionElements(node); + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); - if (!this.Core.EncounteredError) + if (!this.Messaging.EncounteredError) { - Row row = this.Core.CreateRow(sourceLineNumbers, "SqlFileSpec"); - row[0] = id; - row[1] = name; - row[2] = fileName; + var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlFileSpec", id); + row.Set(1, name); + row.Set(2, fileName); if (null != size) { - row[3] = size; + row.Set(3, size); } if (null != maxSize) { - row[4] = maxSize; + row.Set(4, maxSize); } if (null != growthSize) { - row[5] = growthSize; + row.Set(5, growthSize); } } @@ -433,13 +430,13 @@ namespace WixToolset.Extensions /// /// Parses a sql script element. /// - /// Element to parse. + /// Element to parse. /// Identifier for parent component. /// Optional database to execute script against. - private void ParseSqlScriptElement(XElement node, string componentId, string sqlDb) + private void ParseSqlScriptElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string sqlDb) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - string id = null; + SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + Identifier id = null; int attributes = 0; bool rollbackAttribute = false; bool nonRollbackAttribute = false; @@ -447,38 +444,38 @@ namespace WixToolset.Extensions int sequence = CompilerConstants.IntegerNotSet; string user = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (XAttribute attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "BinaryKey": - binary = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "Binary", binary); + binary = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "Binary", binary); break; case "Sequence": - sequence = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); + sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); break; case "SqlDb": if (null != sqlDb) { - this.Core.OnMessage(WixErrors.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, node.Parent.Name.LocalName)); + this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, element.Parent.Name.LocalName)); } - sqlDb = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "SqlDatabase", sqlDb); + sqlDb = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "SqlDatabase", sqlDb); break; case "User": - user = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "User", user); + user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "User", user); break; // Flag-setting attributes case "ContinueOnError": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlContinueOnError; } @@ -486,11 +483,11 @@ namespace WixToolset.Extensions case "ExecuteOnInstall": if (rollbackAttribute) { - this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); } nonRollbackAttribute = true; - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlExecuteOnInstall; } @@ -498,11 +495,11 @@ namespace WixToolset.Extensions case "ExecuteOnReinstall": if (rollbackAttribute) { - this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); } nonRollbackAttribute = true; - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlExecuteOnReinstall; } @@ -510,11 +507,11 @@ namespace WixToolset.Extensions case "ExecuteOnUninstall": if (rollbackAttribute) { - this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); } nonRollbackAttribute = true; - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlExecuteOnUninstall; } @@ -522,11 +519,11 @@ namespace WixToolset.Extensions case "RollbackOnInstall": if (nonRollbackAttribute) { - this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); } rollbackAttribute = true; - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlExecuteOnInstall; attributes |= SqlRollback; @@ -535,11 +532,11 @@ namespace WixToolset.Extensions case "RollbackOnReinstall": if (nonRollbackAttribute) { - this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); } rollbackAttribute = true; - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlExecuteOnReinstall; attributes |= SqlRollback; @@ -548,65 +545,64 @@ namespace WixToolset.Extensions case "RollbackOnUninstall": if (nonRollbackAttribute) { - this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); } rollbackAttribute = true; - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlExecuteOnUninstall; attributes |= SqlRollback; } break; default: - this.Core.UnexpectedAttribute(node, attrib); + this.ParseHelper.UnexpectedAttribute(element, attrib); break; } } else { - this.Core.ParseExtensionAttribute(node, attrib); + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); } } if (null == id) { - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); } if (null == binary) { - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "BinaryKey")); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "BinaryKey")); } if (null == sqlDb) { - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "SqlDb")); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "SqlDb")); } if (0 == attributes) { - this.Core.OnMessage(WixErrors.ExpectedAttributes(sourceLineNumbers, node.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall", "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + this.Messaging.Write(ErrorMessages.ExpectedAttributes(sourceLineNumbers, element.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall", "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); } - this.Core.ParseForExtensionElements(node); + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); // Reference InstallSqlData and UninstallSqlData since nothing will happen without it - this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "InstallSqlData"); - this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "UninstallSqlData"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "InstallSqlData"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "UninstallSqlData"); - if (!this.Core.EncounteredError) + if (!this.Messaging.EncounteredError) { - Row row = this.Core.CreateRow(sourceLineNumbers, "SqlScript"); - row[0] = id; - row[1] = sqlDb; - row[2] = componentId; - row[3] = binary; - row[4] = user; - row[5] = attributes; + var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlScript", id); + row.Set(1, sqlDb); + row.Set(2, componentId); + row.Set(3, binary); + row.Set(4, user); + row.Set(5, attributes); if (CompilerConstants.IntegerNotSet != sequence) { - row[6] = sequence; + row.Set(6, sequence); } } } @@ -614,13 +610,13 @@ namespace WixToolset.Extensions /// /// Parses a sql string element. /// - /// Element to parse. + /// Element to parse. /// Identifier for parent component. /// Optional database to execute string against. - private void ParseSqlStringElement(XElement node, string componentId, string sqlDb) + private void ParseSqlStringElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string sqlDb) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - string id = null; + SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + Identifier id = null; int attributes = 0; bool rollbackAttribute = false; bool nonRollbackAttribute = false; @@ -628,17 +624,17 @@ namespace WixToolset.Extensions string sql = null; string user = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (XAttribute attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; case "ContinueOnError": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlContinueOnError; } @@ -646,11 +642,11 @@ namespace WixToolset.Extensions case "ExecuteOnInstall": if (rollbackAttribute) { - this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); } nonRollbackAttribute = true; - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlExecuteOnInstall; } @@ -658,11 +654,11 @@ namespace WixToolset.Extensions case "ExecuteOnReinstall": if (rollbackAttribute) { - this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); } nonRollbackAttribute = true; - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlExecuteOnReinstall; } @@ -670,11 +666,11 @@ namespace WixToolset.Extensions case "ExecuteOnUninstall": if (rollbackAttribute) { - this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); } nonRollbackAttribute = true; - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlExecuteOnUninstall; } @@ -682,11 +678,11 @@ namespace WixToolset.Extensions case "RollbackOnInstall": if (nonRollbackAttribute) { - this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); } rollbackAttribute = true; - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlExecuteOnInstall; attributes |= SqlRollback; @@ -695,11 +691,11 @@ namespace WixToolset.Extensions case "RollbackOnReinstall": if (nonRollbackAttribute) { - this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); } rollbackAttribute = true; - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlExecuteOnReinstall; attributes |= SqlRollback; @@ -708,84 +704,83 @@ namespace WixToolset.Extensions case "RollbackOnUninstall": if (nonRollbackAttribute) { - this.Core.OnMessage(WixErrors.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); } rollbackAttribute = true; - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) { attributes |= SqlExecuteOnUninstall; attributes |= SqlRollback; } break; case "Sequence": - sequence = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); + sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); break; case "SQL": - sql = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + sql = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); break; case "SqlDb": if (null != sqlDb) { - this.Core.OnMessage(WixErrors.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, "SqlDb", "SqlDatabase")); + this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, "SqlDb", "SqlDatabase")); } - sqlDb = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "SqlDatabase", sqlDb); + sqlDb = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "SqlDatabase", sqlDb); break; case "User": - user = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "User", user); + user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "User", user); break; default: - this.Core.UnexpectedAttribute(node, attrib); + this.ParseHelper.UnexpectedAttribute(element, attrib); break; } } else { - this.Core.ParseExtensionAttribute(node, attrib); + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); } } if (null == id) { - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); } if (null == sql) { - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "SQL")); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "SQL")); } if (null == sqlDb) { - this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "SqlDb")); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "SqlDb")); } if (0 == attributes) { - this.Core.OnMessage(WixErrors.ExpectedAttributes(sourceLineNumbers, node.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall", "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + this.Messaging.Write(ErrorMessages.ExpectedAttributes(sourceLineNumbers, element.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall", "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); } - this.Core.ParseForExtensionElements(node); + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); // Reference InstallSqlData and UninstallSqlData since nothing will happen without it - this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "InstallSqlData"); - this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "UninstallSqlData"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "InstallSqlData"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "UninstallSqlData"); - if (!this.Core.EncounteredError) + if (!this.Messaging.EncounteredError) { - Row row = this.Core.CreateRow(sourceLineNumbers, "SqlString"); - row[0] = id; - row[1] = sqlDb; - row[2] = componentId; - row[3] = sql; - row[4] = user; - row[5] = attributes; + var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlString", id); + row.Set(1, sqlDb); + row.Set(2, componentId); + row.Set(3, sql); + row.Set(4, user); + row.Set(5, attributes); if (CompilerConstants.IntegerNotSet != sequence) { - row[6] = sequence; + row.Set(6, sequence); } } } diff --git a/src/wixext/SqlDecompiler.cs b/src/wixext/SqlDecompiler.cs index 64192e84..52436b87 100644 --- a/src/wixext/SqlDecompiler.cs +++ b/src/wixext/SqlDecompiler.cs @@ -1,7 +1,8 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -namespace WixToolset.Extensions +namespace WixToolset.Sql { +#if TODO_CONSIDER_DECOMPILER using System.Collections; using WixToolset.Data; using WixToolset.Extensibility; @@ -509,4 +510,5 @@ namespace WixToolset.Extensions } } } +#endif } diff --git a/src/wixext/SqlErrors.cs b/src/wixext/SqlErrors.cs index 2043b658..f25728bd 100644 --- a/src/wixext/SqlErrors.cs +++ b/src/wixext/SqlErrors.cs @@ -1,32 +1,48 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -namespace WixToolset.Extensions +namespace WixToolset.Sql { - public sealed class SqlErrors + using System.Resources; + using WixToolset.Data; + + public static class SqlErrors { - - private SqlErrors() + public static Message IllegalAttributeWithoutComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName) { + return Message(sourceLineNumbers, Ids.IllegalAttributeWithoutComponent, "The {0}/@{1} attribute cannot be specified unless the element has a Component as an ancestor. A {0} that does not have a Component ancestor is not installed.", elementName, attributeName); } - public static MessageEventArgs IllegalAttributeWithoutComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName) + public static Message IllegalElementWithoutComponent(SourceLineNumber sourceLineNumbers, string elementName) { - return new SqlErrorEventArgs(sourceLineNumbers, 5100, "SqlErrors_IllegalAttributeWithoutComponent_1", elementName, attributeName); + return Message(sourceLineNumbers, Ids.IllegalElementWithoutComponent, "The {0} element cannot be specified unless the element has a Component as an ancestor. A {0} that does not have a Component ancestor is not installed.", elementName); } - public static MessageEventArgs IllegalElementWithoutComponent(SourceLineNumber sourceLineNumbers, string elementName) + public static Message OneOfAttributesRequiredUnderComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName1, string attributeName2, string attributeName3, string attributeName4) { - return new SqlErrorEventArgs(sourceLineNumbers, 5101, "SqlErrors_IllegalElementWithoutComponent_1", elementName); + return Message(sourceLineNumbers, Ids.OneOfAttributesRequiredUnderComponent, "When nested under a Component, the {0} element must have one of the following attributes specified: {1}, {2}, {3} or {4}.", elementName, attributeName1, attributeName2, attributeName3, attributeName4); } - public static MessageEventArgs OneOfAttributesRequiredUnderComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName1, string attributeName2, string attributeName3, string attributeName4) + public static Message DeprecatedBinaryChildElement(SourceLineNumber sourceLineNumbers, string elementName) { - return new SqlErrorEventArgs(sourceLineNumbers, 5102, "SqlErrors_OneOfAttributesRequiredUnderComponent_1", elementName, attributeName1, attributeName2, attributeName3, attributeName4); + return Message(sourceLineNumbers, Ids.DeprecatedBinaryChildElement, "The {0} element contains a deprecated child Binary element. Please move the Binary element under a Fragment, Module, or Product element and set the {0}/@BinaryKey attribute to the value of the Binary/@Id attribute.", elementName); } - - public static MessageEventArgs DeprecatedBinaryChildElement(SourceLineNumber sourceLineNumbers, string elementName) + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Error, (int)id, resourceManager, resourceName, args); + } + + public enum Ids { - return new SqlErrorEventArgs(sourceLineNumbers, 5103, "SqlErrors_DeprecatedBinaryChildElement_1", elementName); + IllegalAttributeWithoutComponent = 5100, + IllegalElementWithoutComponent = 5101, + OneOfAttributesRequiredUnderComponent = 5102, + DeprecatedBinaryChildElement = 5103, } } } \ No newline at end of file diff --git a/src/wixext/SqlExtensionData.cs b/src/wixext/SqlExtensionData.cs index b43b0341..a1b24b07 100644 --- a/src/wixext/SqlExtensionData.cs +++ b/src/wixext/SqlExtensionData.cs @@ -1,64 +1,30 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -namespace WixToolset.Extensions +namespace WixToolset.Sql { - using System; - using System.Reflection; using WixToolset.Data; using WixToolset.Extensibility; /// /// The WiX Toolset SQL Server Extension. /// - public sealed class SqlExtensionData : ExtensionData + public sealed class SqlExtensionData : BaseExtensionData { /// /// Gets the default culture. /// /// The default culture. - public override string DefaultCulture - { - get { return "en-us"; } - } - - /// - /// Gets the optional table definitions for this extension. - /// - /// The optional table definitions for this extension. - public override TableDefinitionCollection TableDefinitions - { - get - { - return SqlExtensionData.GetExtensionTableDefinitions(); - } - } - - /// - /// Gets the library associated with this extension. - /// - /// The table definitions to use while loading the library. - /// The loaded library. - public override Library GetLibrary(TableDefinitionCollection tableDefinitions) - { - return SqlExtensionData.GetExtensionLibrary(tableDefinitions); - } + public override string DefaultCulture => "en-US"; - /// - /// Internal mechanism to access the extension's table definitions. - /// - /// Extension's table definitions. - internal static TableDefinitionCollection GetExtensionTableDefinitions() + public override bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) { - return ExtensionData.LoadTableDefinitionHelper(Assembly.GetExecutingAssembly(), "WixToolset.Extensions.Data.tables.xml"); + tupleDefinition = null; + return tupleDefinition != null; } - /// - /// Internal mechanism to access the extension's library. - /// - /// Extension's library. - internal static Library GetExtensionLibrary(TableDefinitionCollection tableDefinitions) + public override Intermediate GetLibrary(ITupleDefinitionCreator tupleDefinitions) { - return ExtensionData.LoadLibraryHelper(Assembly.GetExecutingAssembly(), "WixToolset.Extensions.Data.sql.wixlib", tableDefinitions); + return Intermediate.Load(typeof(SqlExtensionData).Assembly, "WixToolset.Sql.sql.wixlib", tupleDefinitions); } } } diff --git a/src/wixext/SqlExtensionFactory.cs b/src/wixext/SqlExtensionFactory.cs new file mode 100644 index 00000000..e7fafed2 --- /dev/null +++ b/src/wixext/SqlExtensionFactory.cs @@ -0,0 +1,18 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using System; + using System.Collections.Generic; + using WixToolset.Extensibility; + + public class SqlExtensionFactory : BaseExtensionFactory + { + protected override IEnumerable ExtensionTypes => new[] + { + typeof(SqlCompiler), + typeof(SqlExtensionData), + typeof(SqlWindowsInstallerBackendBinderExtension), + }; + } +} diff --git a/src/wixext/SqlWindowsInstallerBackendExtension.cs b/src/wixext/SqlWindowsInstallerBackendExtension.cs new file mode 100644 index 00000000..56bdbb1f --- /dev/null +++ b/src/wixext/SqlWindowsInstallerBackendExtension.cs @@ -0,0 +1,31 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using System.Linq; + using System.Xml; + using WixToolset.Data.WindowsInstaller; + using WixToolset.Extensibility; + + public class SqlWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension + { + public SqlWindowsInstallerBackendBinderExtension() + { + + } + + private static readonly TableDefinition[] Tables = LoadTables(); + + protected override TableDefinition[] TableDefinitionsForTuples => Tables; + + private static TableDefinition[] LoadTables() + { + using (var resourceStream = typeof(SqlWindowsInstallerBackendBinderExtension).Assembly.GetManifestResourceStream("WixToolset.Sql.tables.xml")) + using (var reader = XmlReader.Create(resourceStream)) + { + var tables = TableDefinitionCollection.Load(reader); + return tables.ToArray(); + } + } + } +} diff --git a/src/wixext/WixToolset.Sql.wixext.csproj b/src/wixext/WixToolset.Sql.wixext.csproj new file mode 100644 index 00000000..a782ea8f --- /dev/null +++ b/src/wixext/WixToolset.Sql.wixext.csproj @@ -0,0 +1,36 @@ + + + + + + netstandard2.0 + WixToolset.Sql + WiX Toolset Sql Extension + WiX Toolset Sql Extension + true + build + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/wixext/WixToolset.Sql.wixext.targets b/src/wixext/WixToolset.Sql.wixext.targets new file mode 100644 index 00000000..4950e119 --- /dev/null +++ b/src/wixext/WixToolset.Sql.wixext.targets @@ -0,0 +1,11 @@ + + + + + + $(MSBuildThisFileDirectory)..\tools\WixToolset.Sql.wixext.dll + + + + + diff --git a/src/wixlib/SqlExtension.wxs b/src/wixlib/SqlExtension.wxs index 2ee9a3ab..6e08b7fa 100644 --- a/src/wixlib/SqlExtension.wxs +++ b/src/wixlib/SqlExtension.wxs @@ -24,13 +24,13 @@ - - - - - - - + + + + + + + NOT SKIPUNINSTALLSQLDATA AND VersionNT > 400 @@ -40,7 +40,6 @@ - - + diff --git a/src/wixlib/caerr.wxi b/src/wixlib/caerr.wxi new file mode 100644 index 00000000..141942f2 --- /dev/null +++ b/src/wixlib/caerr.wxi @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config new file mode 100644 index 00000000..f3d424e1 --- /dev/null +++ b/src/wixlib/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/wixlib/sql.v3.ncrunchproject b/src/wixlib/sql.v3.ncrunchproject new file mode 100644 index 00000000..319cd523 --- /dev/null +++ b/src/wixlib/sql.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/src/wixlib/sql.wixproj b/src/wixlib/sql.wixproj new file mode 100644 index 00000000..8a775f8f --- /dev/null +++ b/src/wixlib/sql.wixproj @@ -0,0 +1,46 @@ + + + + + + + {9ACF1A20-D801-45CC-A463-F9D13E506AA3} + sql + Library + true + true + en-us + + + + + + + + + + + + + + + + + sqlca + {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935} + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/version.json b/version.json new file mode 100644 index 00000000..5f857771 --- /dev/null +++ b/version.json @@ -0,0 +1,11 @@ +{ + "version": "4.0", + "publicReleaseRefSpec": [ + "^refs/heads/master$" + ], + "cloudBuild": { + "buildNumber": { + "enabled": true + } + } +} -- cgit v1.2.3-55-g6feb From 7d813eaad8eaca04a687d1bb942316232d1c54fd Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 16 Dec 2018 13:53:48 -0600 Subject: Import implementation of SqlCA from old repo's scasched/scaexec. --- src/ca/CustomMsiErrors.h | 10 + src/ca/precomp.h | 14 + src/ca/sca.h | 33 +++ src/ca/scacost.h | 7 + src/ca/scadb.cpp | 587 ++++++++++++++++++++++++++++++++++++++ src/ca/scadb.h | 55 ++++ src/ca/scaexec.cpp | 393 +++++++++++++++++++++++++ src/ca/scasql.cpp | 113 ++++++++ src/ca/scasqlstr.cpp | 728 +++++++++++++++++++++++++++++++++++++++++++++++ src/ca/scasqlstr.h | 51 ++++ src/ca/scauser.cpp | 82 ++++++ src/ca/scauser.h | 40 +++ src/ca/sqlca.def | 8 +- src/ca/sqlca.vcxproj | 11 + 14 files changed, 2131 insertions(+), 1 deletion(-) create mode 100644 src/ca/CustomMsiErrors.h create mode 100644 src/ca/sca.h create mode 100644 src/ca/scacost.h create mode 100644 src/ca/scadb.cpp create mode 100644 src/ca/scadb.h create mode 100644 src/ca/scaexec.cpp create mode 100644 src/ca/scasql.cpp create mode 100644 src/ca/scasqlstr.cpp create mode 100644 src/ca/scasqlstr.h create mode 100644 src/ca/scauser.cpp create mode 100644 src/ca/scauser.h (limited to 'src') diff --git a/src/ca/CustomMsiErrors.h b/src/ca/CustomMsiErrors.h new file mode 100644 index 00000000..b568d01c --- /dev/null +++ b/src/ca/CustomMsiErrors.h @@ -0,0 +1,10 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#define msierrSQLFailedCreateDatabase 26201 +#define msierrSQLFailedDropDatabase 26202 +#define msierrSQLFailedConnectDatabase 26203 +#define msierrSQLFailedExecString 26204 +#define msierrSQLDatabaseAlreadyExists 26205 + +//Last available is 26250 \ No newline at end of file diff --git a/src/ca/precomp.h b/src/ca/precomp.h index 3edad7ed..7a5074b3 100644 --- a/src/ca/precomp.h +++ b/src/ca/precomp.h @@ -2,12 +2,26 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +#if _WIN32_MSI < 150 +#define _WIN32_MSI 150 +#endif + #include #include +#include + #define MAXUINT USHRT_MAX #include #include "wcautil.h" #include "fileutil.h" +#include "memutil.h" #include "strutil.h" +#include "wiutil.h" + +#include "CustomMsiErrors.h" + +#include "sca.h" +#include "scacost.h" +#include "scasqlstr.h" diff --git a/src/ca/sca.h b/src/ca/sca.h new file mode 100644 index 00000000..bc36344e --- /dev/null +++ b/src/ca/sca.h @@ -0,0 +1,33 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +// Generic action enum. +enum SCA_ACTION +{ + SCA_ACTION_NONE, + SCA_ACTION_INSTALL, + SCA_ACTION_UNINSTALL +}; + +// sql database attributes definitions +enum SCADB_ATTRIBUTES +{ + SCADB_CREATE_ON_INSTALL = 0x00000001, + SCADB_DROP_ON_UNINSTALL = 0x00000002, + SCADB_CONTINUE_ON_ERROR = 0x00000004, + SCADB_DROP_ON_INSTALL = 0x00000008, + SCADB_CREATE_ON_UNINSTALL = 0x00000010, + SCADB_CONFIRM_OVERWRITE = 0x00000020, + SCADB_CREATE_ON_REINSTALL = 0x00000040, + SCADB_DROP_ON_REINSTALL = 0x00000080, +}; + +// sql string/script attributes definitions +enum SCASQL_ATTRIBUTES +{ + SCASQL_EXECUTE_ON_INSTALL = 0x00000001, + SCASQL_EXECUTE_ON_UNINSTALL = 0x00000002, + SCASQL_CONTINUE_ON_ERROR = 0x00000004, + SCASQL_ROLLBACK = 0x00000008, + SCASQL_EXECUTE_ON_REINSTALL = 0x00000010, +}; diff --git a/src/ca/scacost.h b/src/ca/scacost.h new file mode 100644 index 00000000..6ea7e465 --- /dev/null +++ b/src/ca/scacost.h @@ -0,0 +1,7 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +const UINT COST_SQL_CREATEDB = 10000; +const UINT COST_SQL_DROPDB = 5000; +const UINT COST_SQL_CONNECTDB = 5000; +const UINT COST_SQL_STRING = 5000; diff --git a/src/ca/scadb.cpp b/src/ca/scadb.cpp new file mode 100644 index 00000000..9f9efca2 --- /dev/null +++ b/src/ca/scadb.cpp @@ -0,0 +1,587 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +// sql queries +LPCWSTR vcsSqlDatabaseQuery = L"SELECT `SqlDb`, `Server`, `Instance`, `Database`, " + L"`Component_`, `User_`, `FileSpec_`, `FileSpec_Log`, `Attributes` " + L"FROM `SqlDatabase`"; +enum eSqlDatabaseQuery { sdqSqlDb = 1, sdqServer, sdqInstance, sdqDatabase, + sdqComponent, sdqUser, sdqDbFileSpec, sdqLogFileSpec, sdqAttributes }; + +LPCWSTR vcsSqlFileSpecQuery = L"SELECT `FileSpec`, `Name`, `Filename`, `Size`, " + L"`MaxSize`, `GrowthSize` FROM `SqlFileSpec` WHERE `FileSpec`=?"; +enum eSqlFileSpecQuery { sfsqFileSpec = 1, sfsqName, sfsqFilename, sfsqSize, + sfsqMaxSize, sfsqGrowth }; + + +// prototypes for private helper functions +static HRESULT NewDb( + __out SCA_DB** ppsd + ); + +static SCA_DB* AddDbToList( + __in SCA_DB* psdList, + __in SCA_DB* psd + ); + +static HRESULT SchedCreateDatabase( + __in SCA_DB* psd + ); + +static HRESULT SchedDropDatabase( + __in LPCWSTR wzKey, LPCWSTR wzServer, + __in LPCWSTR wzInstance, + __in LPCWSTR wzDatabase, + __in int iAttributes, + __in BOOL fIntegratedAuth, + __in LPCWSTR wzUser, + __in LPCWSTR wzPassword + ); + +static HRESULT GetFileSpec( + __in MSIHANDLE hViewFileSpec, + __in LPCWSTR wzKey, + __in SQL_FILESPEC* psf + ); + + +HRESULT ScaDbsRead( + __inout SCA_DB** ppsdList, + __in SCA_ACTION saAction + ) +{ + HRESULT hr = S_OK; + UINT er = ERROR_SUCCESS; + PMSIHANDLE hView; + PMSIHANDLE hRec; + PMSIHANDLE hViewFileSpec = NULL; + + LPWSTR pwzData = NULL; + LPWSTR pwzId = NULL; + LPWSTR pwzComponent = NULL; + + SCA_DB* psd = NULL; + + if (S_OK != WcaTableExists(L"SqlDatabase")) + { + WcaLog(LOGMSG_VERBOSE, "Skipping ScaCreateDatabase() - SqlDatabase table not present"); + ExitFunction1(hr = S_FALSE); + } + + if (S_OK == WcaTableExists(L"SqlFileSpec")) + { + hr = WcaOpenView(vcsSqlFileSpecQuery, &hViewFileSpec); + ExitOnFailure(hr, "failed to open view on SqlFileSpec table"); + } + + // loop through all the sql databases + hr = WcaOpenExecuteView(vcsSqlDatabaseQuery, &hView); + ExitOnFailure(hr, "Failed to open view on SqlDatabase table"); + while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) + { + BOOL fHasComponent = FALSE; + INSTALLSTATE isInstalled = INSTALLSTATE_UNKNOWN; + INSTALLSTATE isAction = INSTALLSTATE_UNKNOWN; + + hr = WcaGetRecordString(hRec, sdqSqlDb, &pwzId); + ExitOnFailure(hr, "Failed to get SqlDatabase.SqlDb"); + + hr = WcaGetRecordString(hRec, sdqComponent, &pwzComponent); + ExitOnFailure(hr, "Failed to get Component for database: '%ls'", psd->wzKey); + if (pwzComponent && *pwzComponent) + { + fHasComponent = TRUE; + + er = ::MsiGetComponentStateW(WcaGetInstallHandle(), pwzComponent, &isInstalled, &isAction); + hr = HRESULT_FROM_WIN32(er); + ExitOnFailure(hr, "Failed to get state for component: %ls", pwzComponent); + + // If we're doing install but the Component is not being installed or we're doing + // uninstall but the Component is not being uninstalled, skip it. + if ((WcaIsInstalling(isInstalled, isAction) && SCA_ACTION_INSTALL != saAction) || + (WcaIsUninstalling(isInstalled, isAction) && SCA_ACTION_UNINSTALL != saAction)) + { + continue; + } + } + + hr = NewDb(&psd); + ExitOnFailure(hr, "Failed to allocate memory for new database: %D", pwzId); + + hr = ::StringCchCopyW(psd->wzKey, countof(psd->wzKey), pwzId); + ExitOnFailure(hr, "Failed to copy SqlDatabase.SqlDbL: %ls", pwzId); + + hr = ::StringCchCopyW(psd->wzComponent, countof(psd->wzComponent), pwzComponent); + ExitOnFailure(hr, "Failed to copy SqlDatabase.Component_: %ls", pwzComponent); + + psd->fHasComponent = fHasComponent; + psd->isInstalled = isInstalled; + psd->isAction = isAction; + + hr = WcaGetRecordFormattedString(hRec, sdqServer, &pwzData); + ExitOnFailure(hr, "Failed to get Server for database: '%ls'", psd->wzKey); + hr = ::StringCchCopyW(psd->wzServer, countof(psd->wzServer), pwzData); + ExitOnFailure(hr, "Failed to copy server string to database object:%ls", pwzData); + + hr = WcaGetRecordFormattedString(hRec, sdqInstance, &pwzData); + ExitOnFailure(hr, "Failed to get Instance for database: '%ls'", psd->wzKey); + hr = ::StringCchCopyW(psd->wzInstance, countof(psd->wzInstance), pwzData); + ExitOnFailure(hr, "Failed to copy instance string to database object:%ls", pwzData); + + hr = WcaGetRecordFormattedString(hRec, sdqDatabase, &pwzData); + ExitOnFailure(hr, "Failed to get Database for database: '%ls'", psd->wzKey); + hr = ::StringCchCopyW(psd->wzDatabase, countof(psd->wzDatabase), pwzData); + ExitOnFailure(hr, "Failed to copy database string to database object:%ls", pwzData); + + hr = WcaGetRecordInteger(hRec, sdqAttributes, &psd->iAttributes); + ExitOnFailure(hr, "Failed to get SqlDatabase.Attributes"); + + hr = WcaGetRecordFormattedString(hRec, sdqUser, &pwzData); + ExitOnFailure(hr, "Failed to get User record for database: '%ls'", psd->wzKey); + + // if a user was specified + if (*pwzData) + { + psd->fUseIntegratedAuth = FALSE; + hr = ScaGetUser(pwzData, &psd->scau); + ExitOnFailure(hr, "Failed to get user information for database: '%ls'", psd->wzKey); + } + else + { + psd->fUseIntegratedAuth = TRUE; + // integrated authorization doesn't have a User record + } + + hr = WcaGetRecordString(hRec, sdqDbFileSpec, &pwzData); + ExitOnFailure(hr, "Failed to get Database FileSpec for database: '%ls'", psd->wzKey); + + // if a database filespec was specified + if (*pwzData) + { + hr = GetFileSpec(hViewFileSpec, pwzData, &psd->sfDb); + ExitOnFailure(hr, "failed to get FileSpec for: %ls", pwzData); + if (S_OK == hr) + { + psd->fHasDbSpec = TRUE; + } + } + + hr = WcaGetRecordString(hRec, sdqLogFileSpec, &pwzData); + ExitOnFailure(hr, "Failed to get Log FileSpec for database: '%ls'", psd->wzKey); + + // if a log filespec was specified + if (*pwzData) + { + hr = GetFileSpec(hViewFileSpec, pwzData, &psd->sfLog); + ExitOnFailure(hr, "failed to get FileSpec for: %ls", pwzData); + if (S_OK == hr) + { + psd->fHasLogSpec = TRUE; + } + } + + *ppsdList = AddDbToList(*ppsdList, psd); + psd = NULL; // set the db NULL so it doesn't accidentally get freed below + } + + if (E_NOMOREITEMS == hr) + { + hr = S_OK; + } + ExitOnFailure(hr, "Failure occured while processing SqlDatabase table"); + +LExit: + if (psd) + { + ScaDbsFreeList(psd); + } + + ReleaseStr(pwzComponent); + ReleaseStr(pwzId); + ReleaseStr(pwzData); + return hr; +} + + +SCA_DB* ScaDbsFindDatabase( + __in LPCWSTR wzSqlDb, + __in SCA_DB* psdList + ) +{ + SCA_DB* psd = NULL; + + for (psd = psdList; psd; psd = psd->psdNext) + { + if (0 == lstrcmpW(wzSqlDb, psd->wzKey)) + { + break; + } + } + + return psd; +} + + +HRESULT ScaDbsInstall( + __in SCA_DB* psdList + ) +{ + HRESULT hr = S_FALSE; // assume nothing will be done + SCA_DB* psd = NULL; + + for (psd = psdList; psd; psd = psd->psdNext) + { + if (psd->fHasComponent) + { + // if we need to drop, do that first + if (((psd->iAttributes & SCADB_DROP_ON_INSTALL) && WcaIsInstalling(psd->isInstalled, psd->isAction) && !WcaIsReInstalling(psd->isInstalled, psd->isAction)) || + ((psd->iAttributes & SCADB_DROP_ON_REINSTALL) && WcaIsReInstalling(psd->isInstalled, psd->isAction))) + { + hr = SchedDropDatabase(psd->wzKey, psd->wzServer, psd->wzInstance, psd->wzDatabase, psd->iAttributes, psd->fUseIntegratedAuth, psd->scau.wzName, psd->scau.wzPassword); + ExitOnFailure(hr, "Failed to drop database %ls", psd->wzKey); + } + + // if installing this component + if (((psd->iAttributes & SCADB_CREATE_ON_INSTALL) && WcaIsInstalling(psd->isInstalled, psd->isAction) && !WcaIsReInstalling(psd->isInstalled, psd->isAction)) || + ((psd->iAttributes & SCADB_CREATE_ON_REINSTALL) && WcaIsReInstalling(psd->isInstalled, psd->isAction))) + { + hr = SchedCreateDatabase(psd); + ExitOnFailure(hr, "Failed to ensure database %ls exists", psd->wzKey); + } + } + } + +LExit: + return hr; +} + + +HRESULT ScaDbsUninstall( + __in SCA_DB* psdList + ) +{ + HRESULT hr = S_FALSE; // assume nothing will be done + SCA_DB* psd = NULL; + + for (psd = psdList; psd; psd = psd->psdNext) + { + if (psd->fHasComponent) + { + // if we need to drop do that first + if ((psd->iAttributes & SCADB_DROP_ON_UNINSTALL) && WcaIsUninstalling(psd->isInstalled, psd->isAction)) + { + hr = SchedDropDatabase(psd->wzKey, psd->wzServer, psd->wzInstance, psd->wzDatabase, psd->iAttributes, psd->fUseIntegratedAuth, psd->scau.wzName, psd->scau.wzPassword); + ExitOnFailure(hr, "Failed to drop database %ls", psd->wzKey); + } + + // install the db + if ((psd->iAttributes & SCADB_CREATE_ON_UNINSTALL) && WcaIsUninstalling(psd->isInstalled, psd->isAction)) + { + hr = SchedCreateDatabase(psd); + ExitOnFailure(hr, "Failed to ensure database %ls exists", psd->wzKey); + } + } + } + +LExit: + return hr; +} + + +void ScaDbsFreeList( + __in SCA_DB* psdList + ) +{ + SCA_DB* psdDelete = psdList; + while (psdList) + { + psdDelete = psdList; + psdList = psdList->psdNext; + + MemFree(psdDelete); + } +} + + +// private helper functions + +static HRESULT NewDb( + __out SCA_DB** ppsd + ) +{ + HRESULT hr = S_OK; + SCA_DB* psd = static_cast(MemAlloc(sizeof(SCA_DB), TRUE)); + ExitOnNull(psd, hr, E_OUTOFMEMORY, "failed to allocate memory for new database element"); + + *ppsd = psd; + +LExit: + return hr; +} + + +static SCA_DB* AddDbToList( + __in SCA_DB* psdList, + __in SCA_DB* psd + ) +{ + if (psdList) + { + SCA_DB* psdT = psdList; + while (psdT->psdNext) + { + psdT = psdT->psdNext; + } + + psdT->psdNext = psd; + } + else + { + psdList = psd; + } + + return psdList; +} + + +static HRESULT SchedCreateDatabase( + __in SCA_DB* psd + ) +{ + HRESULT hr = S_OK; + WCHAR* pwzCustomActionData = NULL; + + hr = WcaWriteStringToCaData(psd->wzKey, &pwzCustomActionData); + ExitOnFailure(hr, "failed to add DBKey to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->wzServer, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add server name to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->wzInstance, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add server instance to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->wzDatabase, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add database name to CustomActionData"); + + hr = WcaWriteIntegerToCaData(psd->iAttributes, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add Sql attributes to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->fUseIntegratedAuth ? L"1" : L"0", &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add if integrated connection to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->scau.wzName, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add server user to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->scau.wzPassword, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add user password to CustomActionData"); + + // Check to see if the database exists, if it does not then schedule a rollback + // so we clean up after ourselves if the creation of the database fails or is + // aborted. It is interesting to note that we can do this check here because the + // deferred CustomActions are Impersonated. That means this scheduling action and + // the execution actions all run with the same user context, so it is safe to + // to do the check. + hr = SqlDatabaseExists(psd->wzServer, psd->wzInstance, psd->wzDatabase, psd->fUseIntegratedAuth, psd->scau.wzName, psd->scau.wzPassword, NULL); + if (S_FALSE == hr) + { + hr = WcaDoDeferredAction(L"RollbackCreateDatabase", pwzCustomActionData, COST_SQL_CREATEDB); + ExitOnFailure(hr, "Failed to schedule RollbackCreateDatabase action"); + } + + // database filespec + if (psd->fHasDbSpec) + { + hr = WcaWriteStringToCaData(L"1", &pwzCustomActionData); + ExitOnFailure(hr, "failed to specify that do have db.filespec to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfDb.wzName, &pwzCustomActionData); + ExitOnFailure(hr, "failed to add FileSpec.Name to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfDb.wzFilename, &pwzCustomActionData); + ExitOnFailure(hr, "failed to add FileSpec.Filename to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfDb.wzSize, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add FileSpec.Size to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfDb.wzMaxSize, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add FileSpec.MaxSize to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfDb.wzGrow, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add FileSpec.GrowthSize to CustomActionData"); + } + else + { + hr = WcaWriteStringToCaData(L"0", &pwzCustomActionData); + ExitOnFailure(hr, "failed to specify that do not have db.filespec to CustomActionData"); + } + + // log filespec + if (psd->fHasLogSpec) + { + hr = WcaWriteStringToCaData(L"1", &pwzCustomActionData); + ExitOnFailure(hr, "failed to specify that do have log.filespec to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfLog.wzName, &pwzCustomActionData); + ExitOnFailure(hr, "failed to add FileSpec.Name to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfLog.wzFilename, &pwzCustomActionData); + ExitOnFailure(hr, "failed to add FileSpec.Filename to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfLog.wzSize, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add FileSpec.Size to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfLog.wzMaxSize, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add FileSpec.MaxSize to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfLog.wzGrow, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add FileSpec.GrowthSize to CustomActionData"); + } + else + { + hr = WcaWriteStringToCaData(L"0", &pwzCustomActionData); + ExitOnFailure(hr, "failed to specify that do not have log.filespec to CustomActionData"); + } + + // schedule the CreateDatabase action + hr = WcaDoDeferredAction(L"CreateDatabase", pwzCustomActionData, COST_SQL_CREATEDB); + ExitOnFailure(hr, "Failed to schedule CreateDatabase action"); + +LExit: + ReleaseStr(pwzCustomActionData); + return hr; +} + + +HRESULT SchedDropDatabase( + __in LPCWSTR wzKey, + __in LPCWSTR wzServer, + __in LPCWSTR wzInstance, + __in LPCWSTR wzDatabase, + __in int iAttributes, + __in BOOL fIntegratedAuth, + __in LPCWSTR wzUser, + __in LPCWSTR wzPassword + ) +{ + HRESULT hr = S_OK; + WCHAR* pwzCustomActionData = NULL; + + hr = WcaWriteStringToCaData(wzKey, &pwzCustomActionData); + ExitOnFailure(hr, "failed to add DBKey to CustomActionData"); + + hr = WcaWriteStringToCaData(wzServer, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add server name to CustomActionData"); + + hr = WcaWriteStringToCaData(wzInstance, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add server instance to CustomActionData"); + + hr = WcaWriteStringToCaData(wzDatabase, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add database name to CustomActionData"); + + hr = WcaWriteIntegerToCaData(iAttributes, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add server name to CustomActionData"); + + hr = WcaWriteStringToCaData(fIntegratedAuth ? L"1" : L"0", &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add server name to CustomActionData"); + + hr = WcaWriteStringToCaData(wzUser, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add server user to CustomActionData"); + + hr = WcaWriteStringToCaData(wzPassword, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add user password to CustomActionData"); + + hr = WcaDoDeferredAction(L"DropDatabase", pwzCustomActionData, COST_SQL_DROPDB); + ExitOnFailure(hr, "Failed to schedule DropDatabase action"); + +LExit: + ReleaseStr(pwzCustomActionData); + return hr; +} + + +HRESULT GetFileSpec( + __in MSIHANDLE hViewFileSpec, + __in LPCWSTR wzKey, + __in SQL_FILESPEC* psf + ) +{ + HRESULT hr = S_OK; + PMSIHANDLE hRecFileSpec, hRec; + LPWSTR pwzData = NULL; + + // create a record to do the fetch + hRecFileSpec = ::MsiCreateRecord(1); + if (!hRecFileSpec) + { + ExitOnFailure(hr = E_UNEXPECTED, "failed to create record for filespec: %ls", wzKey); + } + hr = WcaSetRecordString(hRecFileSpec, 1, wzKey); + ExitOnFailure(hr, "failed to set record string for filespec: %ls", wzKey); + + // get the FileSpec record + hr = WcaExecuteView(hViewFileSpec, hRecFileSpec); + ExitOnFailure(hr, "failed to execute view on SqlFileSpec table for filespec: %ls", wzKey); + hr = WcaFetchSingleRecord(hViewFileSpec, &hRec); + ExitOnFailure(hr, "failed to get record for filespec: %ls", wzKey); + + // read the data out of the filespec record + hr = WcaGetRecordFormattedString(hRec, sfsqName, &pwzData); + ExitOnFailure(hr, "Failed to get SqlFileSpec.Name for filespec: %ls", wzKey); + hr = ::StringCchCopyW(psf->wzName, countof(psf->wzName), pwzData); + ExitOnFailure(hr, "Failed to copy SqlFileSpec.Name string: %ls", pwzData); + + hr = WcaGetRecordFormattedString(hRec, sfsqFilename, &pwzData); + ExitOnFailure(hr, "Failed to get SqlFileSpec.Filename for filespec: %ls", wzKey); + if (*pwzData) + { + hr = ::StringCchCopyW(psf->wzFilename, countof(psf->wzFilename), pwzData); + ExitOnFailure(hr, "Failed to copy filename to filespec object: %ls", pwzData); + } + else // if there is no file, skip this FILESPEC + { + WcaLog(LOGMSG_VERBOSE, "No filename specified, skipping FileSpec: %ls", psf->wzName); + ExitFunction1(hr = S_FALSE); + } + + hr = WcaGetRecordFormattedString(hRec, sfsqSize, &pwzData); + ExitOnFailure(hr, "Failed to get SqlFileSpec.Size for filespec: %ls", wzKey); + if (*pwzData) + { + hr = ::StringCchCopyW(psf->wzSize, countof(psf->wzSize), pwzData); + ExitOnFailure(hr, "Failed to copy size to filespec object: %ls", pwzData); + } + else + { + psf->wzSize[0] = 0; + } + + hr = WcaGetRecordFormattedString(hRec, sfsqMaxSize, &pwzData); + ExitOnFailure(hr, "Failed to get SqlFileSpec.MaxSize for filespec: %ls", wzKey); + if (*pwzData) + { + hr = ::StringCchCopyW(psf->wzMaxSize, countof(psf->wzMaxSize), pwzData); + ExitOnFailure(hr, "Failed to copy max size to filespec object: %ls", pwzData); + } + else + { + psf->wzMaxSize[0] = 0; + } + + hr = WcaGetRecordFormattedString(hRec, sfsqGrowth, &pwzData); + ExitOnFailure(hr, "Failed to get SqlFileSpec.GrowthSize for filespec: %ls", wzKey); + if (*pwzData) + { + hr = ::StringCchCopyW(psf->wzGrow, countof(psf->wzGrow), pwzData); + ExitOnFailure(hr, "Failed to copy growth size to filespec object: %ls", pwzData); + } + else + { + psf->wzGrow[0] = 0; + } + + hr = S_OK; +LExit: + ReleaseStr(pwzData); + return hr; +} diff --git a/src/ca/scadb.h b/src/ca/scadb.h new file mode 100644 index 00000000..885e84c2 --- /dev/null +++ b/src/ca/scadb.h @@ -0,0 +1,55 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +#include "scauser.h" +#include "sqlutil.h" + +struct SCA_DB +{ + // darwin information + WCHAR wzKey[MAX_DARWIN_KEY + 1]; + BOOL fHasComponent; + WCHAR wzComponent[MAX_DARWIN_KEY + 1]; + INSTALLSTATE isInstalled, isAction; + + WCHAR wzServer[MAX_DARWIN_COLUMN + 1]; + WCHAR wzInstance[MAX_DARWIN_COLUMN + 1]; + WCHAR wzDatabase[MAX_DARWIN_COLUMN + 1]; + + int iAttributes; + + BOOL fUseIntegratedAuth; + SCA_USER scau; + + BOOL fHasDbSpec; + SQL_FILESPEC sfDb; + BOOL fHasLogSpec; + SQL_FILESPEC sfLog; + + SCA_DB* psdNext; +}; + + +// prototypes +HRESULT ScaDbsRead( + __inout SCA_DB** ppsdList, + __in SCA_ACTION saAction + ); + +SCA_DB* ScaDbsFindDatabase( + __in LPCWSTR wzSqlDb, + __in SCA_DB* psdList + ); + +HRESULT ScaDbsInstall( + __in SCA_DB* psdList + ); + +HRESULT ScaDbsUninstall( + __in SCA_DB* psdList + ); + +void ScaDbsFreeList( + __in SCA_DB* psdList + ); diff --git a/src/ca/scaexec.cpp b/src/ca/scaexec.cpp new file mode 100644 index 00000000..7a30f52a --- /dev/null +++ b/src/ca/scaexec.cpp @@ -0,0 +1,393 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + + +/******************************************************************** + * CreateDatabase - CUSTOM ACTION ENTRY POINT for creating databases + * + * Input: deferred CustomActionData - DbKey\tServer\tInstance\tDatabase\tAttributes\tIntegratedAuth\tUser\tPassword + * ****************************************************************/ +extern "C" UINT __stdcall CreateDatabase(MSIHANDLE hInstall) +{ +//AssertSz(FALSE, "debug CreateDatabase here"); + UINT er = ERROR_SUCCESS; + HRESULT hr = S_OK; + + LPWSTR pwzData = NULL; + IDBCreateSession* pidbSession = NULL; + BSTR bstrErrorDescription = NULL; + LPWSTR pwz = NULL; + LPWSTR pwzDatabaseKey = NULL; + LPWSTR pwzServer = NULL; + LPWSTR pwzInstance = NULL; + LPWSTR pwzDatabase = NULL; + LPWSTR pwzTemp = NULL; + int iAttributes; + BOOL fIntegratedAuth; + LPWSTR pwzUser = NULL; + LPWSTR pwzPassword = NULL; + BOOL fHaveDbFileSpec = FALSE; + SQL_FILESPEC sfDb; + BOOL fHaveLogFileSpec = FALSE; + SQL_FILESPEC sfLog; + BOOL fInitializedCom = FALSE; + + memset(&sfDb, 0, sizeof(sfDb)); + memset(&sfLog, 0, sizeof(sfLog)); + + hr = WcaInitialize(hInstall, "CreateDatabase"); + ExitOnFailure(hr, "failed to initialize"); + + hr = ::CoInitialize(NULL); + ExitOnFailure(hr, "failed to intialize COM"); + fInitializedCom = TRUE; + + hr = WcaGetProperty( L"CustomActionData", &pwzData); + ExitOnFailure(hr, "failed to get CustomActionData"); + + WcaLog(LOGMSG_TRACEONLY, "CustomActionData: %ls", pwzData); + + pwz = pwzData; + hr = WcaReadStringFromCaData(&pwz, &pwzDatabaseKey); // SQL Server + ExitOnFailure(hr, "failed to read database key from custom action data: %ls", pwz); + hr = WcaReadStringFromCaData(&pwz, &pwzServer); // SQL Server + ExitOnFailure(hr, "failed to read server from custom action data: %ls", pwz); + hr = WcaReadStringFromCaData(&pwz, &pwzInstance); // SQL Server Instance + ExitOnFailure(hr, "failed to read server instance from custom action data: %ls", pwz); + hr = WcaReadStringFromCaData(&pwz, &pwzDatabase); // SQL Database + ExitOnFailure(hr, "failed to read server instance from custom action data: %ls", pwz); + hr = WcaReadIntegerFromCaData(&pwz, &iAttributes); + ExitOnFailure(hr, "failed to read attributes from custom action data: %ls", pwz); + hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast(&fIntegratedAuth)); // Integrated Windows Authentication? + ExitOnFailure(hr, "failed to read integrated auth flag from custom action data: %ls", pwz); + hr = WcaReadStringFromCaData(&pwz, &pwzUser); // SQL User + ExitOnFailure(hr, "failed to read user from custom action data: %ls", pwz); + hr = WcaReadStringFromCaData(&pwz, &pwzPassword); // SQL User Password + ExitOnFailure(hr, "failed to read user from custom action data: %ls", pwz); + + // db file spec + hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast(&fHaveDbFileSpec)); + ExitOnFailure(hr, "failed to read db file spec from custom action data: %ls", pwz); + + if (fHaveDbFileSpec) + { + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read db file spec name from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfDb.wzName, countof(sfDb.wzName), pwzTemp); + ExitOnFailure(hr, "failed to copy db file spec name: %ls", pwzTemp); + + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read db file spec filename from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfDb.wzFilename, countof(sfDb.wzFilename), pwzTemp); + ExitOnFailure(hr, "failed to copy db file spec filename: %ls", pwzTemp); + + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read db file spec size from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfDb.wzSize, countof(sfDb.wzSize), pwzTemp); + ExitOnFailure(hr, "failed to copy db file spec size value: %ls", pwzTemp); + + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read db file spec max size from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfDb.wzMaxSize, countof(sfDb.wzMaxSize), pwzTemp); + ExitOnFailure(hr, "failed to copy db file spec max size: %ls", pwzTemp); + + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read db file spec grow from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfDb.wzGrow, countof(sfDb.wzGrow), pwzTemp); + ExitOnFailure(hr, "failed to copy db file spec grow value: %ls", pwzTemp); + } + + // log file spec + hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast(&fHaveLogFileSpec)); + ExitOnFailure(hr, "failed to read log file spec from custom action data: %ls", pwz); + if (fHaveLogFileSpec) + { + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read log file spec name from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfLog.wzName, countof(sfDb.wzName), pwzTemp); + ExitOnFailure(hr, "failed to copy log file spec name: %ls", pwzTemp); + + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read log file spec filename from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfLog.wzFilename, countof(sfDb.wzFilename), pwzTemp); + ExitOnFailure(hr, "failed to copy log file spec filename: %ls", pwzTemp); + + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read log file spec size from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfLog.wzSize, countof(sfDb.wzSize), pwzTemp); + ExitOnFailure(hr, "failed to copy log file spec size value: %ls", pwzTemp); + + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read log file spec max size from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfLog.wzMaxSize, countof(sfDb.wzMaxSize), pwzTemp); + ExitOnFailure(hr, "failed to copy log file spec max size: %ls", pwzTemp); + + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read log file spec grow from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfLog.wzGrow, countof(sfDb.wzGrow), pwzTemp); + ExitOnFailure(hr, "failed to copy log file spec grow value: %ls", pwzTemp); + } + + if (iAttributes & SCADB_CONFIRM_OVERWRITE) + { + // Check if the database already exists + hr = SqlDatabaseExists(pwzServer, pwzInstance, pwzDatabase, fIntegratedAuth, pwzUser, pwzPassword, &bstrErrorDescription); + MessageExitOnFailure(hr, msierrSQLFailedCreateDatabase, "failed to check if database exists: '%ls', error: %ls", pwzDatabase, NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription); + + if (S_OK == hr) // found an existing database, confirm that they don't want to stop before it gets trampled, in no UI case just continue anyways + { + hr = HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS); + if (IDNO == WcaErrorMessage(msierrSQLDatabaseAlreadyExists, hr, MB_YESNO, 1, pwzDatabase)) + ExitOnFailure(hr, "failed to initialize"); + } + } + + hr = SqlDatabaseEnsureExists(pwzServer, pwzInstance, pwzDatabase, fIntegratedAuth, pwzUser, pwzPassword, fHaveDbFileSpec ? &sfDb : NULL, fHaveLogFileSpec ? &sfLog : NULL, &bstrErrorDescription); + if ((iAttributes & SCADB_CONTINUE_ON_ERROR) && FAILED(hr)) + { + WcaLog(LOGMSG_STANDARD, "Error 0x%x: failed to create SQL database but continuing, error: %ls, Database: %ls", hr, NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription, pwzDatabase); + hr = S_OK; + } + MessageExitOnFailure(hr, msierrSQLFailedCreateDatabase, "failed to create to database: '%ls', error: %ls", pwzDatabase, NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription); + + hr = WcaProgressMessage(COST_SQL_CONNECTDB, FALSE); +LExit: + ReleaseStr(pwzDatabaseKey); + ReleaseStr(pwzServer); + ReleaseStr(pwzInstance); + ReleaseStr(pwzDatabase); + ReleaseStr(pwzUser); + ReleaseStr(pwzPassword); + ReleaseObject(pidbSession); + ReleaseBSTR(bstrErrorDescription); + + if (fInitializedCom) + { + ::CoUninitialize(); + } + + if (FAILED(hr)) + { + er = ERROR_INSTALL_FAILURE; + } + return WcaFinalize(er); +} + + +/******************************************************************** + DropDatabase - CUSTOM ACTION ENTRY POINT for removing databases + + Input: deferred CustomActionData - DbKey\tServer\tInstance\tDatabase\tAttributes\tIntegratedAuth\tUser\tPassword + * ****************************************************************/ +extern "C" UINT __stdcall DropDatabase(MSIHANDLE hInstall) +{ +//Assert(FALSE); + UINT er = ERROR_SUCCESS; + HRESULT hr = S_OK; + + LPWSTR pwzData = NULL; + IDBCreateSession* pidbSession = NULL; + BSTR bstrErrorDescription = NULL; + LPWSTR pwz = NULL; + LPWSTR pwzDatabaseKey = NULL; + LPWSTR pwzServer = NULL; + LPWSTR pwzInstance = NULL; + LPWSTR pwzDatabase = NULL; + long lAttributes; + BOOL fIntegratedAuth; + LPWSTR pwzUser = NULL; + LPWSTR pwzPassword = NULL; + BOOL fInitializedCom = TRUE; + + hr = WcaInitialize(hInstall, "DropDatabase"); + ExitOnFailure(hr, "failed to initialize"); + + hr = ::CoInitialize(NULL); + ExitOnFailure(hr, "failed to intialize COM"); + fInitializedCom = TRUE; + + hr = WcaGetProperty( L"CustomActionData", &pwzData); + ExitOnFailure(hr, "failed to get CustomActionData"); + + WcaLog(LOGMSG_TRACEONLY, "CustomActionData: %ls", pwzData); + + pwz = pwzData; + hr = WcaReadStringFromCaData(&pwz, &pwzDatabaseKey); + ExitOnFailure(hr, "failed to read database key"); + hr = WcaReadStringFromCaData(&pwz, &pwzServer); + ExitOnFailure(hr, "failed to read server"); + hr = WcaReadStringFromCaData(&pwz, &pwzInstance); + ExitOnFailure(hr, "failed to read instance"); + hr = WcaReadStringFromCaData(&pwz, &pwzDatabase); + ExitOnFailure(hr, "failed to read database"); + hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast(&lAttributes)); + ExitOnFailure(hr, "failed to read attributes"); + hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast(&fIntegratedAuth)); // Integrated Windows Authentication? + ExitOnFailure(hr, "failed to read integrated auth flag"); + hr = WcaReadStringFromCaData(&pwz, &pwzUser); + ExitOnFailure(hr, "failed to read user"); + hr = WcaReadStringFromCaData(&pwz, &pwzPassword); + ExitOnFailure(hr, "failed to read password"); + + hr = SqlDropDatabase(pwzServer, pwzInstance, pwzDatabase, fIntegratedAuth, pwzUser, pwzPassword, &bstrErrorDescription); + if ((lAttributes & SCADB_CONTINUE_ON_ERROR) && FAILED(hr)) + { + WcaLog(LOGMSG_STANDARD, "Error 0x%x: failed to drop SQL database but continuing, error: %ls, Database: %ls", hr, NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription, pwzDatabase); + hr = S_OK; + } + MessageExitOnFailure(hr, msierrSQLFailedDropDatabase, "failed to drop to database: '%ls', error: %ls", pwzDatabase, NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription); + + hr = WcaProgressMessage(COST_SQL_CONNECTDB, FALSE); + +LExit: + ReleaseStr(pwzDatabaseKey); + ReleaseStr(pwzServer); + ReleaseStr(pwzInstance); + ReleaseStr(pwzDatabase); + ReleaseStr(pwzUser); + ReleaseStr(pwzPassword); + ReleaseStr(pwzData); + ReleaseObject(pidbSession); + ReleaseBSTR(bstrErrorDescription); + + if (fInitializedCom) + { + ::CoUninitialize(); + } + + if (FAILED(hr)) + { + er = ERROR_INSTALL_FAILURE; + } + return WcaFinalize(er); +} + + +/******************************************************************** + ExecuteSqlStrings - CUSTOM ACTION ENTRY POINT for running SQL strings + + Input: deferred CustomActionData - DbKey\tServer\tInstance\tDatabase\tAttributes\tIntegratedAuth\tUser\tPassword\tSQLKey1\tSQLString1\tSQLKey2\tSQLString2\tSQLKey3\tSQLString3\t... + rollback CustomActionData - same as above + * ****************************************************************/ +extern "C" UINT __stdcall ExecuteSqlStrings(MSIHANDLE hInstall) +{ +//Assert(FALSE); + UINT er = ERROR_SUCCESS; + HRESULT hr = S_OK; + HRESULT hrDB = S_OK; + + LPWSTR pwzData = NULL; + IDBCreateSession* pidbSession = NULL; + BSTR bstrErrorDescription = NULL; + + LPWSTR pwz = NULL; + LPWSTR pwzDatabaseKey = NULL; + LPWSTR pwzServer = NULL; + LPWSTR pwzInstance = NULL; + LPWSTR pwzDatabase = NULL; + int iAttributesDB; + int iAttributesSQL; + BOOL fIntegratedAuth; + LPWSTR pwzUser = NULL; + LPWSTR pwzPassword = NULL; + LPWSTR pwzSqlKey = NULL; + LPWSTR pwzSql = NULL; + BOOL fInitializedCom = FALSE; + + hr = WcaInitialize(hInstall, "ExecuteSqlStrings"); + ExitOnFailure(hr, "failed to initialize"); + + hr = ::CoInitialize(NULL); + ExitOnFailure(hr, "failed to intialize COM"); + fInitializedCom = TRUE; + + hr = WcaGetProperty( L"CustomActionData", &pwzData); + ExitOnFailure(hr, "failed to get CustomActionData"); + + WcaLog(LOGMSG_TRACEONLY, "CustomActionData: %ls", pwzData); + + pwz = pwzData; + hr = WcaReadStringFromCaData(&pwz, &pwzDatabaseKey); + ExitOnFailure(hr, "failed to read database key"); + hr = WcaReadStringFromCaData(&pwz, &pwzServer); + ExitOnFailure(hr, "failed to read server"); + hr = WcaReadStringFromCaData(&pwz, &pwzInstance); + ExitOnFailure(hr, "failed to read instance"); + hr = WcaReadStringFromCaData(&pwz, &pwzDatabase); + ExitOnFailure(hr, "failed to read database"); + hr = WcaReadIntegerFromCaData(&pwz, &iAttributesDB); + ExitOnFailure(hr, "failed to read attributes"); + hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast(&fIntegratedAuth)); // Integrated Windows Authentication? + ExitOnFailure(hr, "failed to read integrated auth flag"); + hr = WcaReadStringFromCaData(&pwz, &pwzUser); + ExitOnFailure(hr, "failed to read user"); + hr = WcaReadStringFromCaData(&pwz, &pwzPassword); + ExitOnFailure(hr, "failed to read password"); + + // Store off the result of the connect, only exit if we don't care if the database connection succeeds + // Wait to fail until later to see if we actually have work to do that is not set to continue on error + hrDB = SqlConnectDatabase(pwzServer, pwzInstance, pwzDatabase, fIntegratedAuth, pwzUser, pwzPassword, &pidbSession); + if ((iAttributesDB & SCADB_CONTINUE_ON_ERROR) && FAILED(hrDB)) + { + WcaLog(LOGMSG_STANDARD, "Error 0x%x: continuing after failure to connect to database: %ls", hrDB, pwzDatabase); + ExitFunction1(hr = S_OK); + } + + while (S_OK == hr && S_OK == (hr = WcaReadStringFromCaData(&pwz, &pwzSqlKey))) + { + hr = WcaReadIntegerFromCaData(&pwz, &iAttributesSQL); + ExitOnFailure(hr, "failed to read attributes for SQL string: %ls", pwzSqlKey); + + hr = WcaReadStringFromCaData(&pwz, &pwzSql); + ExitOnFailure(hr, "failed to read SQL string for key: %ls", pwzSqlKey); + + // If the SqlString row is set to continue on error and the DB connection failed, skip attempting to execute + if ((iAttributesSQL & SCASQL_CONTINUE_ON_ERROR) && FAILED(hrDB)) + { + WcaLog(LOGMSG_STANDARD, "Error 0x%x: continuing after failure to connect to database: %ls", hrDB, pwzDatabase); + continue; + } + + // Now check if the DB connection succeeded + MessageExitOnFailure(hr = hrDB, msierrSQLFailedConnectDatabase, "failed to connect to database: '%ls'", pwzDatabase); + + WcaLog(LOGMSG_VERBOSE, "Executing SQL string: %ls", pwzSql); + hr = SqlSessionExecuteQuery(pidbSession, pwzSql, NULL, NULL, &bstrErrorDescription); + if ((iAttributesSQL & SCASQL_CONTINUE_ON_ERROR) && FAILED(hr)) + { + WcaLog(LOGMSG_STANDARD, "Error 0x%x: failed to execute SQL string but continuing, error: %ls, SQL key: %ls SQL string: %ls", hr, NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription, pwzSqlKey, pwzSql); + hr = S_OK; + } + MessageExitOnFailure(hr, msierrSQLFailedExecString, "failed to execute SQL string, error: %ls, SQL key: %ls SQL string: %ls", NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription, pwzSqlKey, pwzSql); + + WcaProgressMessage(COST_SQL_STRING, FALSE); + } + if (E_NOMOREITEMS == hr) + { + hr = S_OK; + } + +LExit: + ReleaseStr(pwzDatabaseKey); + ReleaseStr(pwzServer); + ReleaseStr(pwzInstance); + ReleaseStr(pwzDatabase); + ReleaseStr(pwzUser); + ReleaseStr(pwzPassword); + ReleaseStr(pwzData); + + ReleaseBSTR(bstrErrorDescription); + ReleaseObject(pidbSession); + + if (fInitializedCom) + { + ::CoUninitialize(); + } + + if (FAILED(hr)) + { + er = ERROR_INSTALL_FAILURE; + } + return WcaFinalize(er); +} diff --git a/src/ca/scasql.cpp b/src/ca/scasql.cpp new file mode 100644 index 00000000..5e3edd1c --- /dev/null +++ b/src/ca/scasql.cpp @@ -0,0 +1,113 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +// prototypes +static HRESULT ConfigureSqlData( + __in SCA_ACTION saAction + ); + + +/******************************************************************** +InstallSqlData - CUSTOM ACTION ENTRY POINT for installing + SQL data + +********************************************************************/ +extern "C" UINT __stdcall InstallSqlData( + __in MSIHANDLE hInstall + ) +{ + HRESULT hr = S_OK; + UINT er = ERROR_SUCCESS; + + // initialize + hr = WcaInitialize(hInstall, "InstallSqlData"); + ExitOnFailure(hr, "Failed to initialize"); + + hr = ConfigureSqlData(SCA_ACTION_INSTALL); + +LExit: + er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; + return WcaFinalize(er); +} + + +/******************************************************************** +UninstallSqlData - CUSTOM ACTION ENTRY POINT for uninstalling + SQL data + +********************************************************************/ +extern "C" UINT __stdcall UninstallSqlData( + __in MSIHANDLE hInstall + ) +{ + HRESULT hr = S_OK; + UINT er = ERROR_SUCCESS; + + // initialize + hr = WcaInitialize(hInstall, "UninstallCertificates"); + ExitOnFailure(hr, "Failed to initialize"); + + hr = ConfigureSqlData(SCA_ACTION_UNINSTALL); + +LExit: + er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; + return WcaFinalize(er); +} + + +static HRESULT ConfigureSqlData( + __in SCA_ACTION saAction + ) +{ + //AssertSz(FALSE, "debug ConfigureSqlData()"); + HRESULT hr = S_OK; + + SCA_DB* psdList = NULL; + SCA_SQLSTR* psssList = NULL; + + // check for the prerequsite tables + if (S_OK != WcaTableExists(L"SqlDatabase")) + { + WcaLog(LOGMSG_VERBOSE, "skipping SQL CustomAction, no SqlDatabase table"); + ExitFunction1(hr = S_FALSE); + } + + // read tables + hr = ScaDbsRead(&psdList, saAction); + ExitOnFailure(hr, "failed to read SqlDatabase table"); + + hr = ScaSqlStrsRead(&psssList, saAction); + ExitOnFailure(hr, "failed to read SqlStrings table"); + + hr = ScaSqlStrsReadScripts(&psssList, saAction); + ExitOnFailure(hr, "failed to read SqlScripts table"); + + if (SCA_ACTION_UNINSTALL == saAction) + { + // do uninstall actions (order is important!) + hr = ScaSqlStrsUninstall(psdList, psssList); + ExitOnFailure(hr, "failed to execute uninstall SQL strings"); + + hr = ScaDbsUninstall(psdList); + ExitOnFailure(hr, "failed to uninstall databases"); + } + else + { + // do install actions (order is important!) + hr = ScaDbsInstall(psdList); + ExitOnFailure(hr, "failed to install databases"); + + hr = ScaSqlStrsInstall(psdList, psssList); + ExitOnFailure(hr, "failed to execute install SQL strings, length may be too long, try add GO to break up"); + } + +LExit: + if (psssList) + ScaSqlStrsFreeList(psssList); + + if (psdList) + ScaDbsFreeList(psdList); + + return hr; +} diff --git a/src/ca/scasqlstr.cpp b/src/ca/scasqlstr.cpp new file mode 100644 index 00000000..3108e307 --- /dev/null +++ b/src/ca/scasqlstr.cpp @@ -0,0 +1,728 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +// sql queries +LPCWSTR vcsSqlStringQuery = L"SELECT `String`, `SqlDb_`, `Component_`,`SQL`,`User_`,`Attributes`,`Sequence` " +L"FROM `SqlString` ORDER BY `SqlDb_`,`Sequence`"; +enum eSqlStringQuery { ssqSqlString = 1, ssqSqlDb, ssqComponent, ssqSQL, ssqUser, ssqAttributes, ssqSequence }; + +LPCWSTR vcsSqlScriptQuery = L"SELECT `ScriptBinary_`,`Script`, `SqlDb_`, `Component_`,`User_`,`Attributes`,`Sequence` " +L"FROM `SqlScript` ORDER BY `SqlDb_`,`Sequence`"; +enum eSqlScriptQuery { sscrqScriptBinary=1, sscrqSqlScript, sscrqSqlDb, sscrqComponent, sscrqUser, sscrqAttributes, sscrqSequence }; + +LPCWSTR vcsSqlBinaryScriptQuery = L"SELECT `Data` FROM `Binary` WHERE `Name`=?"; +enum eSqlBinaryScriptQuery { ssbsqData = 1 }; + + +// prototypes for private helper functions +static HRESULT NewSqlStr( + __out SCA_SQLSTR** ppsss + ); +static SCA_SQLSTR* AddSqlStrToList( + __in SCA_SQLSTR* psssList, + __in SCA_SQLSTR* psss + ); +static HRESULT ExecuteStrings( + __in SCA_DB* psdList, + __in SCA_SQLSTR* psssList, + __in BOOL fInstall + ); + +HRESULT ScaSqlStrsRead( + __inout SCA_SQLSTR** ppsssList, + __in SCA_ACTION saAction + ) +{ + HRESULT hr = S_OK; + UINT er = ERROR_SUCCESS; + PMSIHANDLE hView, hRec; + PMSIHANDLE hViewUser, hRecUser; + + LPWSTR pwzComponent = NULL; + LPWSTR pwzData = NULL; + + SCA_SQLSTR* psss = NULL; + + if (S_OK != WcaTableExists(L"SqlString") || S_OK != WcaTableExists(L"SqlDatabase")) + { + WcaLog(LOGMSG_VERBOSE, "Skipping ScaSqlStrsRead() - SqlString and/or SqlDatabase table not present"); + ExitFunction1(hr = S_FALSE); + } + + // loop through all the sql strings + hr = WcaOpenExecuteView(vcsSqlStringQuery, &hView); + ExitOnFailure(hr, "Failed to open view on SqlString table"); + while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) + { + INSTALLSTATE isInstalled = INSTALLSTATE_UNKNOWN; + INSTALLSTATE isAction = INSTALLSTATE_UNKNOWN; + + hr = WcaGetRecordString(hRec, ssqComponent, &pwzComponent); + ExitOnFailure(hr, "Failed to get Component for SQL String."); + + er = ::MsiGetComponentStateW(WcaGetInstallHandle(), pwzComponent, &isInstalled, &isAction); + hr = HRESULT_FROM_WIN32(er); + ExitOnFailure(hr, "Failed to get state for component: %ls", pwzComponent); + + // If we're doing install but the Component is not being installed or we're doing + // uninstall but the Component is not being uninstalled, skip it. + if ((WcaIsInstalling(isInstalled, isAction) && SCA_ACTION_INSTALL != saAction) || + (WcaIsUninstalling(isInstalled, isAction) && SCA_ACTION_UNINSTALL != saAction)) + { + continue; + } + + hr = NewSqlStr(&psss); + ExitOnFailure(hr, "failed to allocation new sql string element"); + + psss->isInstalled = isInstalled; + psss->isAction = isAction; + + hr = WcaGetRecordString(hRec, ssqSqlString, &pwzData); + ExitOnFailure(hr, "Failed to get SqlString.String"); + hr = ::StringCchCopyW(psss->wzKey, countof(psss->wzKey), pwzData); + ExitOnFailure(hr, "Failed to copy SqlString.String: %ls", pwzData); + + // find the database information for this string + hr = WcaGetRecordString(hRec, ssqSqlDb, &pwzData); + ExitOnFailure(hr, "Failed to get SqlString.SqlDb_ for SqlString '%ls'", psss->wzKey); + hr = ::StringCchCopyW(psss->wzSqlDb, countof(psss->wzSqlDb), pwzData); + ExitOnFailure(hr, "Failed to copy SqlString.SqlDb_: %ls", pwzData); + + hr = WcaGetRecordInteger(hRec, ssqAttributes, &psss->iAttributes); + ExitOnFailure(hr, "Failed to get SqlString.Attributes for SqlString '%ls'", psss->wzKey); + + //get the sequence number for the string (note that this will be sequenced with scripts too) + hr = WcaGetRecordInteger(hRec, ssqSequence, &psss->iSequence); + ExitOnFailure(hr, "Failed to get SqlString.Sequence for SqlString '%ls'", psss->wzKey); + + // execute SQL + hr = WcaGetRecordFormattedString(hRec, ssqSQL, &pwzData); + ExitOnFailure(hr, "Failed to get SqlString.SQL for SqlString '%ls'", psss->wzKey); + + Assert(!psss->pwzSql); + hr = StrAllocString(&psss->pwzSql, pwzData, 0); + ExitOnFailure(hr, "Failed to alloc string for SqlString '%ls'", psss->wzKey); + + *ppsssList = AddSqlStrToList(*ppsssList, psss); + psss = NULL; // set the sss to NULL so it doesn't get freed below + } + + if (E_NOMOREITEMS == hr) + { + hr = S_OK; + } + ExitOnFailure(hr, "Failure occured while reading SqlString table"); + +LExit: + // if anything was left over after an error clean it all up + if (psss) + { + ScaSqlStrsFreeList(psss); + } + + ReleaseStr(pwzData); + ReleaseStr(pwzComponent); + + return hr; +} + + +HRESULT ScaSqlStrsReadScripts( + __inout SCA_SQLSTR** ppsssList, + __in SCA_ACTION saAction + ) +{ + HRESULT hr = S_OK; + UINT er = ERROR_SUCCESS; + + PMSIHANDLE hView, hRec; + PMSIHANDLE hViewBinary, hRecBinary; + PMSIHANDLE hViewUser, hRecUser; + + LPWSTR pwzComponent = NULL; + LPWSTR pwzData = NULL; + + BYTE* pbScript = NULL; + DWORD cbRead = 0; + DWORD cbScript = 0; + DWORD cchScript = 0; + + LPWSTR pwzScriptBuffer = NULL; + WCHAR* pwzScript = NULL; + WCHAR* pwz; + DWORD cch = 0; + + SCA_SQLSTR sss; + SCA_SQLSTR* psss = NULL; + + if (S_OK != WcaTableExists(L"SqlScript") || S_OK != WcaTableExists(L"SqlDatabase") || S_OK != WcaTableExists(L"Binary")) + { + WcaLog(LOGMSG_VERBOSE, "Skipping ScaSqlStrsReadScripts() - SqlScripts and/or SqlDatabase table not present"); + ExitFunction1(hr = S_FALSE); + } + + // open a view on the binary table + hr = WcaOpenView(vcsSqlBinaryScriptQuery, &hViewBinary); + ExitOnFailure(hr, "Failed to open view on Binary table for SqlScripts"); + + // loop through all the sql scripts + hr = WcaOpenExecuteView(vcsSqlScriptQuery, &hView); + ExitOnFailure(hr, "Failed to open view on SqlScript table"); + while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) + { + INSTALLSTATE isInstalled = INSTALLSTATE_UNKNOWN; + INSTALLSTATE isAction = INSTALLSTATE_UNKNOWN; + + hr = WcaGetRecordString(hRec, sscrqComponent, &pwzComponent); + ExitOnFailure(hr, "Failed to get Component for SQL Script."); + + er = ::MsiGetComponentStateW(WcaGetInstallHandle(), pwzComponent, &isInstalled, &isAction); + hr = HRESULT_FROM_WIN32(er); + ExitOnFailure(hr, "Failed to get state for component: %ls", pwzComponent); + + // If we're doing install but the Component is not being installed or we're doing + // uninstall but the Component is not being uninstalled, skip it. + if ((WcaIsInstalling(isInstalled, isAction) && SCA_ACTION_INSTALL != saAction) || + (WcaIsUninstalling(isInstalled, isAction) && SCA_ACTION_UNINSTALL != saAction)) + { + continue; + } + + ::ZeroMemory(&sss, sizeof(sss)); + + sss.isInstalled = isInstalled; + sss.isAction = isAction; + + hr = WcaGetRecordString(hRec, sscrqSqlScript, &pwzData); + ExitOnFailure(hr, "Failed to get SqlScript.Script"); + hr = ::StringCchCopyW(sss.wzKey, countof(sss.wzKey), pwzData); + ExitOnFailure(hr, "Failed to copy SqlScript.Script: %ls", pwzData); + + // find the database information for this string + hr = WcaGetRecordString(hRec, sscrqSqlDb, &pwzData); + ExitOnFailure(hr, "Failed to get SqlScript.SqlDb_ for SqlScript '%ls'", sss.wzKey); + hr = ::StringCchCopyW(sss.wzSqlDb, countof(sss.wzSqlDb), pwzData); + ExitOnFailure(hr, "Failed to copy SqlScritp.SqlDbb: %ls", pwzData); + + hr = WcaGetRecordInteger(hRec, sscrqAttributes, &sss.iAttributes); + ExitOnFailure(hr, "Failed to get SqlScript.Attributes for SqlScript '%ls'", sss.wzKey); + + hr = WcaGetRecordInteger(hRec, sscrqSequence, &sss.iSequence); + ExitOnFailure(hr, "Failed to get SqlScript.Sequence for SqlScript '%ls'", sss.wzKey); + + // get the sql script out of the binary stream + hr = WcaExecuteView(hViewBinary, hRec); + ExitOnFailure(hr, "Failed to open SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey); + hr = WcaFetchSingleRecord(hViewBinary, &hRecBinary); + ExitOnFailure(hr, "Failed to fetch SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey); + + // Note: We need to allocate an extra character on the stream to NULL terminate the SQL script. + // The WcaGetRecordStream() function won't let us add extra space on the end of the stream + // so we'll read the stream "the old fashioned way". + //hr = WcaGetRecordStream(hRecBinary, ssbsqData, (BYTE**)&pbScript, &cbScript); + //ExitOnFailure(hr, "Failed to read SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey); + er = ::MsiRecordReadStream(hRecBinary, ssbsqData, NULL, &cbRead); + hr = HRESULT_FROM_WIN32(er); + ExitOnFailure(hr, "failed to get size of stream"); + + cbScript = cbRead + sizeof(WCHAR); // we may have an ANSI SQL script but leave enough to even NULL terminate a WCHAR string + hr = WcaAllocStream(&pbScript, cbScript); // this will allocate a fully zeroed out buffer so our string will be NULL terminated + ExitOnFailure(hr, "failed to allocate data for stream"); + + er = ::MsiRecordReadStream(hRecBinary, ssbsqData, reinterpret_cast(pbScript), &cbRead); //read the buffer but leave the space for the NULL terminator + hr = HRESULT_FROM_WIN32(er); + ExitOnFailure(hr, "failed to read from stream"); + + Assert(cbRead + sizeof(WCHAR) == cbScript); + + // Check for the UNICODE BOM file marker. + if ((0xFF == *pbScript) && (0xFE == *(pbScript + 1))) + { + // Copy the UNICODE string after the BOM marker (subtract one because we'll skip the BOM marker). + cchScript = (cbScript / sizeof(WCHAR)) - 1; + + hr = StrAllocString(&pwzScriptBuffer, reinterpret_cast(pbScript) + 1, 0); + ExitOnFailure(hr, "Failed to allocate WCHAR string of size '%d'", cchScript); + } + else + { + // We have an ANSI string so convert it to UNICODE. + cchScript = cbScript; + + hr = StrAllocStringAnsi(&pwzScriptBuffer, reinterpret_cast(pbScript), 0, CP_ACP); + ExitOnFailure(hr, "Failed to allocate WCHAR string of size '%d'", cchScript); + } + + // Free the byte buffer since it has been converted to a new UNICODE string, one way or another. + if (pbScript) + { + WcaFreeStream(pbScript); + pbScript = NULL; + } + + // Process the SQL script stripping out unnecessary stuff (like comments) and looking for "GO" statements. + pwzScript = pwzScriptBuffer; + while (cchScript && pwzScript && *pwzScript) + { + // strip off leading whitespace + while (cchScript && *pwzScript && iswspace(*pwzScript)) + { + ++pwzScript; + --cchScript; + } + + Assert(0 <= cchScript); + + // if there is a SQL comment remove it + while (cchScript && L'/' == *pwzScript && L'*' == *(pwzScript + 1)) + { + // go until end of comment + while (cchScript && *pwzScript && *(pwzScript + 1) && !(L'*' == *pwzScript && L'/' == *(pwzScript + 1))) + { + ++pwzScript; + --cchScript; + } + + Assert(2 <= cchScript); + + if (2 <= cchScript) + { + // to account for */ at end + pwzScript+=2; + cchScript-=2; + } + + Assert(0 <= cchScript); + + // strip off any new leading whitespace + while (cchScript && *pwzScript && iswspace(*pwzScript)) + { + ++pwzScript; + --cchScript; + } + } + + while (cchScript && L'-' == *pwzScript && L'-' == *(pwzScript + 1)) + { + // go past the new line character + while (cchScript && *pwzScript && L'\n' != *pwzScript) + { + ++pwzScript; + --cchScript; + } + + Assert(0 <= cchScript); + + if (cchScript && L'\n' == *pwzScript) + { + ++pwzScript; + --cchScript; + } + + Assert(0 <= cchScript); + + // strip off any new leading whitespace + while (cchScript && *pwzScript && iswspace(*pwzScript)) + { + ++pwzScript; + --cchScript; + } + } + + Assert(0 <= cchScript); + + // try to isolate a "GO" keyword and count the characters in the SQL string + pwz = pwzScript; + cch = 0; + while (cchScript && *pwz) + { + //skip past comment lines that might have "go" in them + //note that these comments are "in the middle" of our function, + //or possibly at the end of a line + if (cchScript && L'-' == *pwz && L'-' == *(pwz + 1)) + { + // skip past chars until the new line character + while (cchScript && *pwz && (L'\n' != *pwz)) + { + ++pwz; + ++cch; + --cchScript; + } + } + + //skip past comment lines of form /* to */ that might have "go" in them + //note that these comments are "in the middle" of our function, + //or possibly at the end of a line + if (cchScript && L'/' == *pwz && L'*' == *(pwz + 1)) + { + // skip past chars until the new line character + while (cchScript && *pwz && *(pwz + 1) && !((L'*' == *pwz) && (L'/' == *(pwz + 1)))) + { + ++pwz; + ++cch; + --cchScript; + } + + if (2 <= cchScript) + { + // to account for */ at end + pwz+=2; + cch+=2; + cchScript-=2; + } + } + + // Skip past strings that may be part of the SQL statement that might have a "go" in them + if ( cchScript && L'\'' == *pwz ) + { + ++pwz; + ++cch; + --cchScript; + + // Skip past chars until the end of the string + while ( cchScript && *pwz && !(L'\'' == *pwz) ) + { + ++pwz; + ++cch; + --cchScript; + } + } + + // Skip past strings that may be part of the SQL statement that might have a "go" in them + if ( cchScript && L'\"' == *pwz ) + { + ++pwz; + ++cch; + --cchScript; + + // Skip past chars until the end of the string + while ( cchScript && *pwz && !(L'\"' == *pwz) ) + { + ++pwz; + ++cch; + --cchScript; + } + } + + // if "GO" is isolated + if ((pwzScript == pwz || iswspace(*(pwz - 1))) && + (L'G' == *pwz || L'g' == *pwz) && + (L'O' == *(pwz + 1) || L'o' == *(pwz + 1)) && + (0 == *(pwz + 2) || iswspace(*(pwz + 2)))) + { + *pwz = 0; // null terminate the SQL string on the "G" + pwz += 2; + cchScript -= 2; + break; // found "GO" now add SQL string to list + } + + ++pwz; + ++cch; + --cchScript; + } + + Assert(0 <= cchScript); + + if (0 < cch) //don't process if there's nothing to process + { + // replace tabs with spaces + for (LPWSTR pwzTab = wcsstr(pwzScript, L"\t"); pwzTab; pwzTab = wcsstr(pwzTab, L"\t")) + *pwzTab = ' '; + + // strip off whitespace at the end of the script string + for (LPWSTR pwzErase = pwzScript + cch - 1; pwzScript < pwzErase && iswspace(*pwzErase); pwzErase--) + { + *(pwzErase) = 0; + cch--; + } + } + + if (0 < cch) + { + hr = NewSqlStr(&psss); + ExitOnFailure(hr, "failed to allocate new sql string element"); + + // copy everything over + hr = ::StringCchCopyW(psss->wzKey, countof(psss->wzKey), sss.wzKey); + ExitOnFailure(hr, "Failed to copy key string to sqlstr object"); + hr = ::StringCchCopyW(psss->wzSqlDb, countof(psss->wzSqlDb), sss.wzSqlDb); + ExitOnFailure(hr, "Failed to copy DB string to sqlstr object"); + hr = ::StringCchCopyW(psss->wzComponent, countof(psss->wzComponent), sss.wzComponent); + ExitOnFailure(hr, "Failed to copy component string to sqlstr object"); + psss->isInstalled = sss.isInstalled; + psss->isAction = sss.isAction; + psss->iAttributes = sss.iAttributes; + psss->iSequence = sss.iSequence; + + // cchRequired includes the NULL terminating char + hr = StrAllocString(&psss->pwzSql, pwzScript, 0); + ExitOnFailure(hr, "Failed to allocate string for SQL script: '%ls'", psss->wzKey); + + *ppsssList = AddSqlStrToList(*ppsssList, psss); + psss = NULL; // set the db NULL so it doesn't accidentally get freed below + } + + pwzScript = pwz; + } + } + + if (E_NOMOREITEMS == hr) + { + hr = S_OK; + } + ExitOnFailure(hr, "Failure occured while reading SqlString table"); + +LExit: + // if anything was left over after an error clean it all up + if (psss) + { + ScaSqlStrsFreeList(psss); + } + + if (pbScript) + { + WcaFreeStream(pbScript); + } + + ReleaseStr(pwzScriptBuffer); + ReleaseStr(pwzData); + ReleaseStr(pwzComponent); + + return hr; +} + + +HRESULT ScaSqlStrsInstall( + __in SCA_DB* psdList, + __in SCA_SQLSTR* psssList + ) +{ + HRESULT hr = ExecuteStrings(psdList, psssList, TRUE); + + return hr; +} + + +HRESULT ScaSqlStrsUninstall( + __in SCA_DB* psdList, + __in SCA_SQLSTR* psssList + ) +{ + HRESULT hr = ExecuteStrings(psdList, psssList, FALSE); + + return hr; +} + + +void ScaSqlStrsFreeList( + __in SCA_SQLSTR* psssList + ) +{ + SCA_SQLSTR* psssDelete = psssList; + while (psssList) + { + psssDelete = psssList; + psssList = psssList->psssNext; + + if (psssDelete->pwzSql) + { + ReleaseStr(psssDelete->pwzSql); + } + + MemFree(psssDelete); + } +} + + +// private helper functions + +static HRESULT NewSqlStr( + __out SCA_SQLSTR** ppsss + ) +{ + HRESULT hr = S_OK; + SCA_SQLSTR* psss = static_cast(MemAlloc(sizeof(SCA_SQLSTR), TRUE)); + ExitOnNull(psss, hr, E_OUTOFMEMORY, "failed to allocate memory for new sql string element"); + + *ppsss = psss; + +LExit: + return hr; +} + + +static SCA_SQLSTR* AddSqlStrToList( + __in SCA_SQLSTR* psssList, + __in SCA_SQLSTR* psss + ) +{ + Assert(psss); //just checking + + //make certain we have a valid sequence number; note that negatives are technically valid + if (MSI_NULL_INTEGER == psss->iSequence) + { + psss->iSequence = 0; + } + + if (psssList) + { + //list already exists, so insert psss into the list in Sequence order + + //see if we need to change the head, otherwise figure out where in the order it fits + if (psss->iSequence < psssList->iSequence) + { + psss->psssNext = psssList; + psssList = psss; + } + else + { + SCA_SQLSTR* psssT = psssList; + //note that if Sequence numbers are duplicated, as in the case of a sqlscript, + //we need to insert them "at the end" of the group so the sqlfile stays in order + while (psssT->psssNext && (psssT->psssNext->iSequence <= psss->iSequence)) + { + psssT = psssT->psssNext; + } + + //insert our new psss AFTER psssT + psss->psssNext = psssT->psssNext; + psssT->psssNext = psss; + } + } + else + { + psssList = psss; + } + + return psssList; +} + + +static HRESULT ExecuteStrings( + __in SCA_DB* psdList, + __in SCA_SQLSTR* psssList, + __in BOOL fInstall + ) +{ + HRESULT hr = S_FALSE; // assume nothing will be done + + int iRollback = -1; + int iOldRollback = iRollback; + + LPCWSTR wzOldDb = NULL; + UINT uiCost = 0; + WCHAR* pwzCustomActionData = NULL; + WCHAR wzNumber[64]; + + // loop through all sql strings + for (SCA_SQLSTR* psss = psssList; psss; psss = psss->psssNext) + { + // if installing this component + if ((fInstall && (psss->iAttributes & SCASQL_EXECUTE_ON_INSTALL) && WcaIsInstalling(psss->isInstalled, psss->isAction) && !WcaIsReInstalling(psss->isInstalled, psss->isAction)) || + (fInstall && (psss->iAttributes & SCASQL_EXECUTE_ON_REINSTALL) && WcaIsReInstalling(psss->isInstalled, psss->isAction)) || + (!fInstall && (psss->iAttributes & SCASQL_EXECUTE_ON_UNINSTALL) && WcaIsUninstalling(psss->isInstalled, psss->isAction))) + { + // determine if this is a rollback scheduling or normal deferred scheduling + if (psss->iAttributes & SCASQL_ROLLBACK) + { + iRollback = 1; + } + else + { + iRollback = 0; + } + + // if we need to create a connection to a new server\database + if (!wzOldDb || 0 != lstrcmpW(wzOldDb, psss->wzSqlDb) || iOldRollback != iRollback) + { + const SCA_DB* psd = ScaDbsFindDatabase(psss->wzSqlDb, psdList); + if (!psd) + { + ExitOnFailure(hr = HRESULT_FROM_WIN32(ERROR_NOT_FOUND), "failed to find data for Database: %ls", psss->wzSqlDb); + } + + if (-1 == iOldRollback) + { + iOldRollback = iRollback; + } + Assert(0 == iOldRollback || 1 == iOldRollback); + + // if there was custom action data before, schedule the action to write it + if (pwzCustomActionData && *pwzCustomActionData) + { + Assert(pwzCustomActionData && *pwzCustomActionData && uiCost); + + hr = WcaDoDeferredAction(1 == iOldRollback ? L"RollbackExecuteSqlStrings" : L"ExecuteSqlStrings", pwzCustomActionData, uiCost); + ExitOnFailure(hr, "failed to schedule ExecuteSqlStrings action, rollback: %d", iOldRollback); + iOldRollback = iRollback; + + *pwzCustomActionData = L'\0'; + uiCost = 0; + } + + Assert(!pwzCustomActionData || (pwzCustomActionData && 0 == *pwzCustomActionData) && 0 == uiCost); + + hr = WcaWriteStringToCaData(psd->wzKey, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add SQL Server Database String to CustomActionData for Database String: %ls", psd->wzKey); + + hr = WcaWriteStringToCaData(psd->wzServer, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add SQL Server to CustomActionData for Database String: %ls", psd->wzKey); + + hr = WcaWriteStringToCaData(psd->wzInstance, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add SQL Instance to CustomActionData for Database String: %ls", psd->wzKey); + + hr = WcaWriteStringToCaData(psd->wzDatabase, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add SQL Database to CustomActionData for Database String: %ls", psd->wzKey); + + hr = ::StringCchPrintfW(wzNumber, countof(wzNumber), L"%d", psd->iAttributes); + ExitOnFailure(hr, "Failed to format attributes integer value to string"); + hr = WcaWriteStringToCaData(wzNumber, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add SQL Attributes to CustomActionData for Database String: %ls", psd->wzKey); + + hr = ::StringCchPrintfW(wzNumber, countof(wzNumber), L"%d", psd->fUseIntegratedAuth); + ExitOnFailure(hr, "Failed to format UseIntegratedAuth integer value to string"); + hr = WcaWriteStringToCaData(wzNumber, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add SQL IntegratedAuth flag to CustomActionData for Database String: %ls", psd->wzKey); + + hr = WcaWriteStringToCaData(psd->scau.wzName, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add SQL UserName to CustomActionData for Database String: %ls", psd->wzKey); + + hr = WcaWriteStringToCaData(psd->scau.wzPassword, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add SQL Password to CustomActionData for Database String: %ls", psd->wzKey); + + uiCost += COST_SQL_CONNECTDB; + + wzOldDb = psss->wzSqlDb; + } + + WcaLog(LOGMSG_VERBOSE, "Scheduling SQL string: %ls", psss->pwzSql); + + hr = WcaWriteStringToCaData(psss->wzKey, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add SQL Key to CustomActionData for SQL string: %ls", psss->wzKey); + + hr = WcaWriteIntegerToCaData(psss->iAttributes, &pwzCustomActionData); + ExitOnFailure(hr, "failed to add attributes to CustomActionData for SQL string: %ls", psss->wzKey); + + hr = WcaWriteStringToCaData(psss->pwzSql, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to to add SQL Query to CustomActionData for SQL string: %ls", psss->wzKey); + uiCost += COST_SQL_STRING; + } + } + + if (pwzCustomActionData && *pwzCustomActionData) + { + Assert(pwzCustomActionData && *pwzCustomActionData && uiCost); + hr = WcaDoDeferredAction(1 == iRollback ? L"RollbackExecuteSqlStrings" : L"ExecuteSqlStrings", pwzCustomActionData, uiCost); + ExitOnFailure(hr, "Failed to schedule ExecuteSqlStrings action"); + + *pwzCustomActionData = L'\0'; + uiCost = 0; + } + +LExit: + ReleaseStr(pwzCustomActionData); + + return hr; +} diff --git a/src/ca/scasqlstr.h b/src/ca/scasqlstr.h new file mode 100644 index 00000000..a6f6df1c --- /dev/null +++ b/src/ca/scasqlstr.h @@ -0,0 +1,51 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +#include "scadb.h" + +struct SCA_SQLSTR +{ + // darwin information + WCHAR wzKey[MAX_DARWIN_KEY + 1]; + WCHAR wzComponent[MAX_DARWIN_KEY + 1]; + INSTALLSTATE isInstalled, isAction; + + WCHAR wzSqlDb[MAX_DARWIN_COLUMN + 1]; + + BOOL fHasUser; + SCA_USER scau; + + LPWSTR pwzSql; + int iAttributes; + int iSequence; //used to sequence SqlString and SqlScript tables together + + SCA_SQLSTR* psssNext; +}; + + +// prototypes +HRESULT ScaSqlStrsRead( + __inout SCA_SQLSTR** ppsssList, + __in SCA_ACTION saAction + ); + +HRESULT ScaSqlStrsReadScripts( + __inout SCA_SQLSTR** ppsssList, + __in SCA_ACTION saAction + ); + +HRESULT ScaSqlStrsInstall( + __in SCA_DB* psdList, + __in SCA_SQLSTR* psssList + ); + +HRESULT ScaSqlStrsUninstall( + __in SCA_DB* psdList, + __in SCA_SQLSTR* psssList + ); + +void ScaSqlStrsFreeList( + __in SCA_SQLSTR* psssList + ); + diff --git a/src/ca/scauser.cpp b/src/ca/scauser.cpp new file mode 100644 index 00000000..4d74e4d4 --- /dev/null +++ b/src/ca/scauser.cpp @@ -0,0 +1,82 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +LPCWSTR vcsUserQuery = L"SELECT `User`, `Component_`, `Name`, `Domain`, `Password` FROM `User` WHERE `User`=?"; +enum eUserQuery { vuqUser = 1, vuqComponent, vuqName, vuqDomain, vuqPassword }; + + +HRESULT __stdcall ScaGetUser( + __in LPCWSTR wzUser, + __out SCA_USER* pscau + ) +{ + if (!wzUser || !pscau) + { + return E_INVALIDARG; + } + + HRESULT hr = S_OK; + PMSIHANDLE hView, hRec; + + LPWSTR pwzData = NULL; + + // clear struct and bail right away if no user key was passed to search for + ::ZeroMemory(pscau, sizeof(*pscau)); + if (!*wzUser) + { + ExitFunction1(hr = S_OK); + } + + hRec = ::MsiCreateRecord(1); + hr = WcaSetRecordString(hRec, 1, wzUser); + ExitOnFailure(hr, "Failed to look up User"); + + hr = WcaOpenView(vcsUserQuery, &hView); + ExitOnFailure(hr, "Failed to open view on User table"); + hr = WcaExecuteView(hView, hRec); + ExitOnFailure(hr, "Failed to execute view on User table"); + + hr = WcaFetchSingleRecord(hView, &hRec); + if (S_OK == hr) + { + hr = WcaGetRecordString(hRec, vuqUser, &pwzData); + ExitOnFailure(hr, "Failed to get User.User"); + hr = ::StringCchCopyW(pscau->wzKey, countof(pscau->wzKey), pwzData); + ExitOnFailure(hr, "Failed to copy key string to user object"); + + hr = WcaGetRecordString(hRec, vuqComponent, &pwzData); + ExitOnFailure(hr, "Failed to get User.Component_"); + hr = ::StringCchCopyW(pscau->wzComponent, countof(pscau->wzComponent), pwzData); + ExitOnFailure(hr, "Failed to copy component string to user object"); + + hr = WcaGetRecordFormattedString(hRec, vuqName, &pwzData); + ExitOnFailure(hr, "Failed to get User.Name"); + hr = ::StringCchCopyW(pscau->wzName, countof(pscau->wzName), pwzData); + ExitOnFailure(hr, "Failed to copy name string to user object"); + + hr = WcaGetRecordFormattedString(hRec, vuqDomain, &pwzData); + ExitOnFailure(hr, "Failed to get User.Domain"); + hr = ::StringCchCopyW(pscau->wzDomain, countof(pscau->wzDomain), pwzData); + ExitOnFailure(hr, "Failed to copy domain string to user object"); + + hr = WcaGetRecordFormattedString(hRec, vuqPassword, &pwzData); + ExitOnFailure(hr, "Failed to get User.Password"); + hr = ::StringCchCopyW(pscau->wzPassword, countof(pscau->wzPassword), pwzData); + ExitOnFailure(hr, "Failed to copy password string to user object"); + } + else if (E_NOMOREITEMS == hr) + { + WcaLog(LOGMSG_STANDARD, "Error: Cannot locate User.User='%ls'", wzUser); + hr = E_FAIL; + } + else + { + ExitOnFailure(hr, "Error or found multiple matching User rows"); + } + +LExit: + ReleaseStr(pwzData); + + return hr; +} diff --git a/src/ca/scauser.h b/src/ca/scauser.h new file mode 100644 index 00000000..20e561f2 --- /dev/null +++ b/src/ca/scauser.h @@ -0,0 +1,40 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + + +// structs +struct SCA_GROUP +{ + WCHAR wzKey[MAX_DARWIN_KEY + 1]; + WCHAR wzComponent[MAX_DARWIN_KEY + 1]; + + WCHAR wzDomain[MAX_DARWIN_COLUMN + 1]; + WCHAR wzName[MAX_DARWIN_COLUMN + 1]; + + SCA_GROUP *psgNext; +}; + +struct SCA_USER +{ + WCHAR wzKey[MAX_DARWIN_KEY + 1]; + WCHAR wzComponent[MAX_DARWIN_KEY + 1]; + INSTALLSTATE isInstalled; + INSTALLSTATE isAction; + + WCHAR wzDomain[MAX_DARWIN_COLUMN + 1]; + WCHAR wzName[MAX_DARWIN_COLUMN + 1]; + WCHAR wzPassword[MAX_DARWIN_COLUMN + 1]; + INT iAttributes; + + SCA_GROUP *psgGroups; + + SCA_USER *psuNext; +}; + + +// prototypes +HRESULT __stdcall ScaGetUser( + __in LPCWSTR wzUser, + __out SCA_USER* pscau + ); diff --git a/src/ca/sqlca.def b/src/ca/sqlca.def index e16626b3..e899d560 100644 --- a/src/ca/sqlca.def +++ b/src/ca/sqlca.def @@ -4,4 +4,10 @@ LIBRARY "sqlca" EXPORTS - +;scaexec.cpp + CreateDatabase + DropDatabase + ExecuteSqlStrings +;scasql.cpp + InstallSqlData + UninstallSqlData diff --git a/src/ca/sqlca.vcxproj b/src/ca/sqlca.vcxproj index 3d638f6e..b1f7dafa 100644 --- a/src/ca/sqlca.vcxproj +++ b/src/ca/sqlca.vcxproj @@ -45,11 +45,22 @@ Create + + + + + + + + + + + -- cgit v1.2.3-55-g6feb From 6a497dc3559b8a5283405a1e1456af6a4c0bbdde Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Mon, 24 Dec 2018 05:51:25 -0800 Subject: Update to latest Home\repo-template --- .editorconfig | 37 +++++++++++ .gitignore | 72 ++++++++++++++++++---- appveyor.yml | 6 ++ src/Directory.Build.props | 9 +-- src/Directory.Build.targets | 48 +++++++++++++++ .../WixToolsetTest.Sql/WixToolsetTest.Sql.csproj | 6 +- src/wixext/WixToolset.Sql.wixext.csproj | 6 +- 7 files changed, 155 insertions(+), 29 deletions(-) create mode 100644 .editorconfig create mode 100644 src/Directory.Build.targets (limited to 'src') diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..1d72e683 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,37 @@ +# Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\.editorconfig +# then update all of the repos. + +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.{cs,vb}] +dotnet_sort_system_directives_first = true + +[*.cs] +csharp_indent_case_contents = true : error +csharp_indent_switch_labels = true : error +csharp_new_line_before_open_brace = all +csharp_prefer_braces = true : error +csharp_style_expression_bodied_methods = when_on_single_line : suggestion +csharp_style_expression_bodied_constructors = when_on_single_line : suggestion +csharp_style_expression_bodied_operators = when_on_single_line : suggestion +csharp_style_expression_bodied_properties = when_on_single_line : suggestion +csharp_style_expression_bodied_indexers = when_on_single_line : suggestion +csharp_style_expression_bodied_accessors = when_on_single_line : suggestion +csharp_style_var_elsewhere = true : suggestion +csharp_style_var_for_built_in_types = true : suggestion +csharp_style_var_when_type_is_apparent = true : suggestion +dotnet_style_qualification_for_event = true : error +dotnet_style_qualification_for_field = true : error +dotnet_style_qualification_for_method = true : error +dotnet_style_qualification_for_property = true : error + +[*.targets] +indent_size = 2 diff --git a/.gitignore b/.gitignore index 3c6208a8..3e8a1553 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore # User-specific files +*.rsuser *.suo *.user *.userosscache @@ -19,16 +20,21 @@ [Rr]eleases/ x64/ x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ bld/ [Bb]in/ [Oo]bj/ [Ll]og/ -# Visual Studio 2015 cache/options directory +# Visual Studio 2015/2017 cache/options directory .vs/ # Uncomment if you have tasks that create the project's static files in wwwroot #wwwroot/ +# Visual Studio 2017 auto generated files +Generated\ Files/ + # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* @@ -49,16 +55,21 @@ BenchmarkDotNet.Artifacts/ project.lock.json project.fragment.lock.json artifacts/ -**/Properties/launchSettings.json +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio *_i.c *_p.c -*_i.h +*_h.h *.ilk *.meta *.obj +*.iobj *.pch *.pdb +*.ipdb *.pgc *.pgd *.rsp @@ -68,6 +79,7 @@ artifacts/ *.tlh *.tmp *.tmp_proj +*_wpftmp.csproj *.log *.vspscc *.vssscc @@ -96,6 +108,9 @@ ipch/ *.vspx *.sap +# Visual Studio Trace Files +*.e2e + # TFS 2012 Local Workspace $tf/ @@ -116,6 +131,10 @@ _TeamCity* # DotCover is a Code Coverage Tool *.dotCover +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + # Visual Studio code coverage results *.coverage *.coveragexml @@ -164,11 +183,11 @@ PublishScripts/ # NuGet Packages *.nupkg # The packages folder can be ignored because of Package Restore -**/packages/* +**/[Pp]ackages/* # except build/, which is used as an MSBuild target. -!**/packages/build/ +!**/[Pp]ackages/build/ # Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config +#!**/[Pp]ackages/repositories.config # NuGet v3's project.json files produces more ignorable files *.nuget.props *.nuget.targets @@ -192,7 +211,7 @@ _pkginfo.txt # files ending in .cache can be ignored *.[Cc]ache # but keep track of directories ending in .cache -!*.[Cc]ache/ +!?*.[Cc]ache/ # Others ClientBin/ @@ -205,9 +224,15 @@ ClientBin/ *.publishsettings orleans.codegen.cs +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + # Since there are multiple workflows, uncomment next line to ignore bower_components # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) #bower_components/ +# ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true +**/wwwroot/lib/ # RIA/Silverlight projects Generated_Code/ @@ -219,6 +244,8 @@ _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak # SQL Server files *.mdf @@ -229,6 +256,7 @@ UpgradeLog*.htm *.rdl.data *.bim.layout *.bim_*.settings +*.rptproj.rsuser # Microsoft Fakes FakesAssemblies/ @@ -240,9 +268,6 @@ FakesAssemblies/ .ntvs_analysis.dat node_modules/ -# Typescript v1 declaration files -typings/ - # Visual Studio 6 build log *.plg @@ -271,8 +296,8 @@ paket-files/ .idea/ *.sln.iml -# CodeRush -.cr/ +# CodeRush personal settings +.cr/personal # Python Tools for Visual Studio (PTVS) __pycache__/ @@ -292,4 +317,25 @@ __pycache__/ *.btp.cs *.btm.cs *.odx.cs -*.xsd.cs \ No newline at end of file +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb diff --git a/appveyor.yml b/appveyor.yml index 0c74d54b..d55322da 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,3 +1,8 @@ +# Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml +# then update all of the repos. + image: Visual Studio 2017 version: 0.0.0.{build} @@ -17,6 +22,7 @@ pull_requests: nuget: disable_publish_on_pr: true +skip_branch_with_pr: true skip_tags: true artifacts: diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 9eacf3f5..e853e22d 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,7 +1,7 @@ @@ -10,20 +10,17 @@ false $(MSBuildProjectName) - $(MSBuildThisFileDirectory)..\build\ + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) $(BaseOutputPath)obj\$(ProjectName)\ $(BaseOutputPath)$(Configuration)\ WiX Toolset Team WiX Toolset Copyright (c) .NET Foundation and contributors. All rights reserved. + MS-RL WiX Toolset - - $(MSBuildThisFileDirectory)..\..\ - - diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets new file mode 100644 index 00000000..dac7452a --- /dev/null +++ b/src/Directory.Build.targets @@ -0,0 +1,48 @@ + + + + + + + true + $(SolutionPath) + $(NCrunchOriginalSolutionPath) + + + + + + + $([System.IO.File]::ReadAllText($(TheSolutionPath))) + $([System.IO.Path]::GetDirectoryName( $(TheSolutionPath) )) + (?<="[PackageName]", ")(.*)(?=", ") + + + + + + %(Identity) + $(SolutionFileContent.Contains('\%(Identity).csproj')) + + + + + $(RegexPattern.Replace('[PackageName]','%(PackageName)') ) + $([System.Text.RegularExpressions.Regex]::Match('$(SolutionFileContent)', '%(Pattern)')) + + + + + + + + + + + diff --git a/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj b/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj index 6efa50a3..bfcf6e17 100644 --- a/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj +++ b/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj @@ -23,11 +23,7 @@ - - - - - + diff --git a/src/wixext/WixToolset.Sql.wixext.csproj b/src/wixext/WixToolset.Sql.wixext.csproj index a782ea8f..5db8b9d3 100644 --- a/src/wixext/WixToolset.Sql.wixext.csproj +++ b/src/wixext/WixToolset.Sql.wixext.csproj @@ -19,11 +19,7 @@ - - - - - + -- cgit v1.2.3-55-g6feb From 2dcc519054be041ef5aa6cfac9dac13b0ea04eca Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Wed, 2 Jan 2019 22:33:22 -0600 Subject: Add tuple definitions and fix test. --- src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs | 2 +- .../TestData/UsingSql/PackageComponents.wxs | 4 +- src/wixext/SqlCompiler.cs | 8 +- src/wixext/SqlExtensionData.cs | 2 +- src/wixext/Tuples/SqlDatabaseTuple.cs | 111 +++++++++++++++++++++ src/wixext/Tuples/SqlFileSpecTuple.cs | 87 ++++++++++++++++ src/wixext/Tuples/SqlScriptTuple.cs | 95 ++++++++++++++++++ src/wixext/Tuples/SqlStringTuple.cs | 95 ++++++++++++++++++ src/wixext/Tuples/SqlTupleDefinitions.cs | 51 ++++++++++ 9 files changed, 447 insertions(+), 8 deletions(-) create mode 100644 src/wixext/Tuples/SqlDatabaseTuple.cs create mode 100644 src/wixext/Tuples/SqlFileSpecTuple.cs create mode 100644 src/wixext/Tuples/SqlScriptTuple.cs create mode 100644 src/wixext/Tuples/SqlStringTuple.cs create mode 100644 src/wixext/Tuples/SqlTupleDefinitions.cs (limited to 'src') diff --git a/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs b/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs index 831bcd83..d7fe74e6 100644 --- a/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs +++ b/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs @@ -19,7 +19,7 @@ namespace WixToolsetTest.Sql var results = build.BuildAndQuery(Build, "SqlString"); Assert.Equal(new[] { - "SqlString:", + "SqlString:TestString\tTestDB\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tCREATE TABLE TestTable1(name varchar(20), value varchar(20))\t\t1\t0", }, results.OrderBy(s => s).ToArray()); } diff --git a/src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs b/src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs index d2572659..653f7e02 100644 --- a/src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs +++ b/src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs @@ -3,8 +3,8 @@ xmlns:sql="http://wixtoolset.org/schemas/v4/wxs/sql"> - - + + diff --git a/src/wixext/SqlCompiler.cs b/src/wixext/SqlCompiler.cs index c789f3bd..3fb33993 100644 --- a/src/wixext/SqlCompiler.cs +++ b/src/wixext/SqlCompiler.cs @@ -265,7 +265,7 @@ namespace WixToolset.Sql this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); } - this.ParseSqlScriptElement(intermediate, section, child, componentId, id.Id); + this.ParseSqlScriptElement(intermediate, section, child, componentId, id?.Id); break; case "SqlString": if (null == componentId) @@ -273,7 +273,7 @@ namespace WixToolset.Sql this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); } - this.ParseSqlStringElement(intermediate, section, child, componentId, id.Id); + this.ParseSqlStringElement(intermediate, section, child, componentId, id?.Id); break; case "SqlFileSpec": if (null == componentId) @@ -325,8 +325,8 @@ namespace WixToolset.Sql row.Set(3, database); row.Set(4, componentId); row.Set(5, user); - row.Set(6, fileSpec.Id); - row.Set(7, logFileSpec.Id); + row.Set(6, fileSpec?.Id); + row.Set(7, logFileSpec?.Id); if (0 != attributes) { row.Set(8, attributes); diff --git a/src/wixext/SqlExtensionData.cs b/src/wixext/SqlExtensionData.cs index a1b24b07..e27b698f 100644 --- a/src/wixext/SqlExtensionData.cs +++ b/src/wixext/SqlExtensionData.cs @@ -18,7 +18,7 @@ namespace WixToolset.Sql public override bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) { - tupleDefinition = null; + tupleDefinition = SqlTupleDefinitions.ByName(name); return tupleDefinition != null; } diff --git a/src/wixext/Tuples/SqlDatabaseTuple.cs b/src/wixext/Tuples/SqlDatabaseTuple.cs new file mode 100644 index 00000000..fd107690 --- /dev/null +++ b/src/wixext/Tuples/SqlDatabaseTuple.cs @@ -0,0 +1,111 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using WixToolset.Data; + using WixToolset.Sql.Tuples; + + public static partial class SqlTupleDefinitions + { + public static readonly IntermediateTupleDefinition SqlDatabase = new IntermediateTupleDefinition( + SqlTupleDefinitionType.SqlDatabase.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.SqlDb), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Server), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Instance), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Database), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Component_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.User_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.FileSpec_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.FileSpec_Log), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Attributes), IntermediateFieldType.Number), + }, + typeof(SqlDatabaseTuple)); + } +} + +namespace WixToolset.Sql.Tuples +{ + using WixToolset.Data; + + public enum SqlDatabaseTupleFields + { + SqlDb, + Server, + Instance, + Database, + Component_, + User_, + FileSpec_, + FileSpec_Log, + Attributes, + } + + public class SqlDatabaseTuple : IntermediateTuple + { + public SqlDatabaseTuple() : base(SqlTupleDefinitions.SqlDatabase, null, null) + { + } + + public SqlDatabaseTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlTupleDefinitions.SqlDatabase, sourceLineNumber, id) + { + } + + public IntermediateField this[SqlDatabaseTupleFields index] => this.Fields[(int)index]; + + public string SqlDb + { + get => this.Fields[(int)SqlDatabaseTupleFields.SqlDb].AsString(); + set => this.Set((int)SqlDatabaseTupleFields.SqlDb, value); + } + + public string Server + { + get => this.Fields[(int)SqlDatabaseTupleFields.Server].AsString(); + set => this.Set((int)SqlDatabaseTupleFields.Server, value); + } + + public string Instance + { + get => this.Fields[(int)SqlDatabaseTupleFields.Instance].AsString(); + set => this.Set((int)SqlDatabaseTupleFields.Instance, value); + } + + public string Database + { + get => this.Fields[(int)SqlDatabaseTupleFields.Database].AsString(); + set => this.Set((int)SqlDatabaseTupleFields.Database, value); + } + + public string Component_ + { + get => this.Fields[(int)SqlDatabaseTupleFields.Component_].AsString(); + set => this.Set((int)SqlDatabaseTupleFields.Component_, value); + } + + public string User_ + { + get => this.Fields[(int)SqlDatabaseTupleFields.User_].AsString(); + set => this.Set((int)SqlDatabaseTupleFields.User_, value); + } + + public string FileSpec_ + { + get => this.Fields[(int)SqlDatabaseTupleFields.FileSpec_].AsString(); + set => this.Set((int)SqlDatabaseTupleFields.FileSpec_, value); + } + + public string FileSpec_Log + { + get => this.Fields[(int)SqlDatabaseTupleFields.FileSpec_Log].AsString(); + set => this.Set((int)SqlDatabaseTupleFields.FileSpec_Log, value); + } + + public int Attributes + { + get => this.Fields[(int)SqlDatabaseTupleFields.Attributes].AsNumber(); + set => this.Set((int)SqlDatabaseTupleFields.Attributes, value); + } + } +} \ No newline at end of file diff --git a/src/wixext/Tuples/SqlFileSpecTuple.cs b/src/wixext/Tuples/SqlFileSpecTuple.cs new file mode 100644 index 00000000..9813ec83 --- /dev/null +++ b/src/wixext/Tuples/SqlFileSpecTuple.cs @@ -0,0 +1,87 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using WixToolset.Data; + using WixToolset.Sql.Tuples; + + public static partial class SqlTupleDefinitions + { + public static readonly IntermediateTupleDefinition SqlFileSpec = new IntermediateTupleDefinition( + SqlTupleDefinitionType.SqlFileSpec.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.FileSpec), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Name), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Filename), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Size), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.MaxSize), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.GrowthSize), IntermediateFieldType.String), + }, + typeof(SqlFileSpecTuple)); + } +} + +namespace WixToolset.Sql.Tuples +{ + using WixToolset.Data; + + public enum SqlFileSpecTupleFields + { + FileSpec, + Name, + Filename, + Size, + MaxSize, + GrowthSize, + } + + public class SqlFileSpecTuple : IntermediateTuple + { + public SqlFileSpecTuple() : base(SqlTupleDefinitions.SqlFileSpec, null, null) + { + } + + public SqlFileSpecTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlTupleDefinitions.SqlFileSpec, sourceLineNumber, id) + { + } + + public IntermediateField this[SqlFileSpecTupleFields index] => this.Fields[(int)index]; + + public string FileSpec + { + get => this.Fields[(int)SqlFileSpecTupleFields.FileSpec].AsString(); + set => this.Set((int)SqlFileSpecTupleFields.FileSpec, value); + } + + public string Name + { + get => this.Fields[(int)SqlFileSpecTupleFields.Name].AsString(); + set => this.Set((int)SqlFileSpecTupleFields.Name, value); + } + + public string Filename + { + get => this.Fields[(int)SqlFileSpecTupleFields.Filename].AsString(); + set => this.Set((int)SqlFileSpecTupleFields.Filename, value); + } + + public string Size + { + get => this.Fields[(int)SqlFileSpecTupleFields.Size].AsString(); + set => this.Set((int)SqlFileSpecTupleFields.Size, value); + } + + public string MaxSize + { + get => this.Fields[(int)SqlFileSpecTupleFields.MaxSize].AsString(); + set => this.Set((int)SqlFileSpecTupleFields.MaxSize, value); + } + + public string GrowthSize + { + get => this.Fields[(int)SqlFileSpecTupleFields.GrowthSize].AsString(); + set => this.Set((int)SqlFileSpecTupleFields.GrowthSize, value); + } + } +} \ No newline at end of file diff --git a/src/wixext/Tuples/SqlScriptTuple.cs b/src/wixext/Tuples/SqlScriptTuple.cs new file mode 100644 index 00000000..b1f95709 --- /dev/null +++ b/src/wixext/Tuples/SqlScriptTuple.cs @@ -0,0 +1,95 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using WixToolset.Data; + using WixToolset.Sql.Tuples; + + public static partial class SqlTupleDefinitions + { + public static readonly IntermediateTupleDefinition SqlScript = new IntermediateTupleDefinition( + SqlTupleDefinitionType.SqlScript.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Script), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.SqlDb_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Component_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.ScriptBinary_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.User_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Attributes), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Sequence), IntermediateFieldType.Number), + }, + typeof(SqlScriptTuple)); + } +} + +namespace WixToolset.Sql.Tuples +{ + using WixToolset.Data; + + public enum SqlScriptTupleFields + { + Script, + SqlDb_, + Component_, + ScriptBinary_, + User_, + Attributes, + Sequence, + } + + public class SqlScriptTuple : IntermediateTuple + { + public SqlScriptTuple() : base(SqlTupleDefinitions.SqlScript, null, null) + { + } + + public SqlScriptTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlTupleDefinitions.SqlScript, sourceLineNumber, id) + { + } + + public IntermediateField this[SqlScriptTupleFields index] => this.Fields[(int)index]; + + public string Script + { + get => this.Fields[(int)SqlScriptTupleFields.Script].AsString(); + set => this.Set((int)SqlScriptTupleFields.Script, value); + } + + public string SqlDb_ + { + get => this.Fields[(int)SqlScriptTupleFields.SqlDb_].AsString(); + set => this.Set((int)SqlScriptTupleFields.SqlDb_, value); + } + + public string Component_ + { + get => this.Fields[(int)SqlScriptTupleFields.Component_].AsString(); + set => this.Set((int)SqlScriptTupleFields.Component_, value); + } + + public string ScriptBinary_ + { + get => this.Fields[(int)SqlScriptTupleFields.ScriptBinary_].AsString(); + set => this.Set((int)SqlScriptTupleFields.ScriptBinary_, value); + } + + public string User_ + { + get => this.Fields[(int)SqlScriptTupleFields.User_].AsString(); + set => this.Set((int)SqlScriptTupleFields.User_, value); + } + + public int Attributes + { + get => this.Fields[(int)SqlScriptTupleFields.Attributes].AsNumber(); + set => this.Set((int)SqlScriptTupleFields.Attributes, value); + } + + public int Sequence + { + get => this.Fields[(int)SqlScriptTupleFields.Sequence].AsNumber(); + set => this.Set((int)SqlScriptTupleFields.Sequence, value); + } + } +} \ No newline at end of file diff --git a/src/wixext/Tuples/SqlStringTuple.cs b/src/wixext/Tuples/SqlStringTuple.cs new file mode 100644 index 00000000..d2cba0e0 --- /dev/null +++ b/src/wixext/Tuples/SqlStringTuple.cs @@ -0,0 +1,95 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using WixToolset.Data; + using WixToolset.Sql.Tuples; + + public static partial class SqlTupleDefinitions + { + public static readonly IntermediateTupleDefinition SqlString = new IntermediateTupleDefinition( + SqlTupleDefinitionType.SqlString.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(SqlStringTupleFields.String), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringTupleFields.SqlDb_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringTupleFields.Component_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringTupleFields.SQL), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringTupleFields.User_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringTupleFields.Attributes), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(SqlStringTupleFields.Sequence), IntermediateFieldType.Number), + }, + typeof(SqlStringTuple)); + } +} + +namespace WixToolset.Sql.Tuples +{ + using WixToolset.Data; + + public enum SqlStringTupleFields + { + String, + SqlDb_, + Component_, + SQL, + User_, + Attributes, + Sequence, + } + + public class SqlStringTuple : IntermediateTuple + { + public SqlStringTuple() : base(SqlTupleDefinitions.SqlString, null, null) + { + } + + public SqlStringTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlTupleDefinitions.SqlString, sourceLineNumber, id) + { + } + + public IntermediateField this[SqlStringTupleFields index] => this.Fields[(int)index]; + + public string String + { + get => this.Fields[(int)SqlStringTupleFields.String].AsString(); + set => this.Set((int)SqlStringTupleFields.String, value); + } + + public string SqlDb_ + { + get => this.Fields[(int)SqlStringTupleFields.SqlDb_].AsString(); + set => this.Set((int)SqlStringTupleFields.SqlDb_, value); + } + + public string Component_ + { + get => this.Fields[(int)SqlStringTupleFields.Component_].AsString(); + set => this.Set((int)SqlStringTupleFields.Component_, value); + } + + public string SQL + { + get => this.Fields[(int)SqlStringTupleFields.SQL].AsString(); + set => this.Set((int)SqlStringTupleFields.SQL, value); + } + + public string User_ + { + get => this.Fields[(int)SqlStringTupleFields.User_].AsString(); + set => this.Set((int)SqlStringTupleFields.User_, value); + } + + public int Attributes + { + get => this.Fields[(int)SqlStringTupleFields.Attributes].AsNumber(); + set => this.Set((int)SqlStringTupleFields.Attributes, value); + } + + public int Sequence + { + get => this.Fields[(int)SqlStringTupleFields.Sequence].AsNumber(); + set => this.Set((int)SqlStringTupleFields.Sequence, value); + } + } +} \ No newline at end of file diff --git a/src/wixext/Tuples/SqlTupleDefinitions.cs b/src/wixext/Tuples/SqlTupleDefinitions.cs new file mode 100644 index 00000000..b99b96a7 --- /dev/null +++ b/src/wixext/Tuples/SqlTupleDefinitions.cs @@ -0,0 +1,51 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using System; + using WixToolset.Data; + + public enum SqlTupleDefinitionType + { + SqlDatabase, + SqlFileSpec, + SqlScript, + SqlString, + } + + public static partial class SqlTupleDefinitions + { + public static readonly Version Version = new Version("4.0.0"); + + public static IntermediateTupleDefinition ByName(string name) + { + if (!Enum.TryParse(name, out SqlTupleDefinitionType type)) + { + return null; + } + + return ByType(type); + } + + public static IntermediateTupleDefinition ByType(SqlTupleDefinitionType type) + { + switch (type) + { + case SqlTupleDefinitionType.SqlDatabase: + return SqlTupleDefinitions.SqlDatabase; + + case SqlTupleDefinitionType.SqlFileSpec: + return SqlTupleDefinitions.SqlFileSpec; + + case SqlTupleDefinitionType.SqlScript: + return SqlTupleDefinitions.SqlScript; + + case SqlTupleDefinitionType.SqlString: + return SqlTupleDefinitions.SqlString; + + default: + throw new ArgumentOutOfRangeException(nameof(type)); + } + } + } +} -- cgit v1.2.3-55-g6feb From 2b6c622d48bb76619bbba89f94d4f7669a6eef5e Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 13 Jan 2019 19:12:32 -0600 Subject: Update to latest Cpp.Build.props for locating latest Win10 SDK. Remove unused Microsoft.VisualStudio.Setup.Configuration.Native package. --- src/Cpp.Build.props | 6 +++++- src/ca/packages.config | 1 - src/ca/precomp.h | 1 - src/ca/sqlca.vcxproj | 9 --------- 4 files changed, 5 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props index 296b36ca..0e00132b 100644 --- a/src/Cpp.Build.props +++ b/src/Cpp.Build.props @@ -8,6 +8,10 @@ $(OutputPath)$(Platform)\ + + $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) + + $(DisableSpecificCompilerWarnings) @@ -16,7 +20,7 @@ WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) Use precomp.h - StdCall + StdCall true false -YlprecompDefine diff --git a/src/ca/packages.config b/src/ca/packages.config index b74ff5d0..b87f9ab4 100644 --- a/src/ca/packages.config +++ b/src/ca/packages.config @@ -1,6 +1,5 @@  - \ No newline at end of file diff --git a/src/ca/precomp.h b/src/ca/precomp.h index 7a5074b3..08454d3a 100644 --- a/src/ca/precomp.h +++ b/src/ca/precomp.h @@ -12,7 +12,6 @@ #include #define MAXUINT USHRT_MAX -#include #include "wcautil.h" #include "fileutil.h" diff --git a/src/ca/sqlca.vcxproj b/src/ca/sqlca.vcxproj index b1f7dafa..f8292706 100644 --- a/src/ca/sqlca.vcxproj +++ b/src/ca/sqlca.vcxproj @@ -24,19 +24,11 @@ Unicode sqlca.def WiX Toolset Sql CustomAction - $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) - - - - - - - msi.lib @@ -74,7 +66,6 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - -- cgit v1.2.3-55-g6feb From 2b82ad224e45a6f9d052ae892ecbf85e436b0bdf Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 6 Apr 2020 08:20:28 +1000 Subject: Update dependencies. --- appveyor.yml | 2 +- src/Cpp.Build.props | 2 +- src/Directory.Build.props | 4 +++- src/FindLocalWix.props | 2 +- src/ca/packages.config | 4 ++-- src/ca/sqlca.vcxproj | 8 ++++---- src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj | 15 +++++++++------ src/wixext/SqlWindowsInstallerBackendExtension.cs | 3 ++- src/wixlib/packages.config | 2 +- src/wixlib/sql.wixproj | 4 ++-- 10 files changed, 26 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/appveyor.yml b/appveyor.yml index d55322da..bbf880f0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,7 +3,7 @@ # Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml # then update all of the repos. -image: Visual Studio 2017 +image: Visual Studio 2019 version: 0.0.0.{build} configuration: Release diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props index 0e00132b..44a042c7 100644 --- a/src/Cpp.Build.props +++ b/src/Cpp.Build.props @@ -8,7 +8,7 @@ $(OutputPath)$(Platform)\ - + $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index e853e22d..a22f4470 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -8,6 +8,7 @@ Debug false + MSB3246 $(MSBuildProjectName) $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) @@ -21,6 +22,7 @@ WiX Toolset - + + diff --git a/src/FindLocalWix.props b/src/FindLocalWix.props index a784e352..1666e4fe 100644 --- a/src/FindLocalWix.props +++ b/src/FindLocalWix.props @@ -3,6 +3,6 @@ - $(MSBuildThisFileDirectory)..\..\Tools\build\Debug\net461\wix.targets + $(MSBuildThisFileDirectory)..\..\Tools\build\Debug\net461\wix.targets diff --git a/src/ca/packages.config b/src/ca/packages.config index b87f9ab4..4e9403bf 100644 --- a/src/ca/packages.config +++ b/src/ca/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/src/ca/sqlca.vcxproj b/src/ca/sqlca.vcxproj index f8292706..1c176d80 100644 --- a/src/ca/sqlca.vcxproj +++ b/src/ca/sqlca.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -66,7 +66,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + diff --git a/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj b/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj index bfcf6e17..a845e563 100644 --- a/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj +++ b/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj @@ -1,9 +1,9 @@ - + - netcoreapp2.1 + netcoreapp3.1 false @@ -23,7 +23,10 @@ - + + + + @@ -31,8 +34,8 @@ - - - + + + diff --git a/src/wixext/SqlWindowsInstallerBackendExtension.cs b/src/wixext/SqlWindowsInstallerBackendExtension.cs index 56bdbb1f..83505059 100644 --- a/src/wixext/SqlWindowsInstallerBackendExtension.cs +++ b/src/wixext/SqlWindowsInstallerBackendExtension.cs @@ -2,6 +2,7 @@ namespace WixToolset.Sql { + using System.Collections.Generic; using System.Linq; using System.Xml; using WixToolset.Data.WindowsInstaller; @@ -16,7 +17,7 @@ namespace WixToolset.Sql private static readonly TableDefinition[] Tables = LoadTables(); - protected override TableDefinition[] TableDefinitionsForTuples => Tables; + public override IEnumerable TableDefinitions => Tables; private static TableDefinition[] LoadTables() { diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config index f3d424e1..d73f4d3a 100644 --- a/src/wixlib/packages.config +++ b/src/wixlib/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/src/wixlib/sql.wixproj b/src/wixlib/sql.wixproj index 8a775f8f..7274acff 100644 --- a/src/wixlib/sql.wixproj +++ b/src/wixlib/sql.wixproj @@ -1,7 +1,7 @@ - + {9ACF1A20-D801-45CC-A463-F9D13E506AA3} @@ -40,7 +40,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From 2df59141a12979c9869ad2e62d01e9f7432e2f7c Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 6 Apr 2020 09:06:53 +1000 Subject: Modernize SqlCompiler and tuples. --- src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs | 4 +- src/wixext/SqlCompiler.cs | 142 ++++++++++++--------- src/wixext/SqlTableDefinitions.cs | 82 ++++++++++++ src/wixext/SqlWindowsInstallerBackendExtension.cs | 23 +--- src/wixext/Tuples/SqlDatabaseTuple.cs | 48 +++---- src/wixext/Tuples/SqlFileSpecTuple.cs | 8 -- src/wixext/Tuples/SqlScriptTuple.cs | 48 +++---- src/wixext/Tuples/SqlStringTuple.cs | 38 +++--- src/wixext/WixToolset.Sql.wixext.csproj | 1 - src/wixext/tables.xml | 73 ----------- 10 files changed, 220 insertions(+), 247 deletions(-) create mode 100644 src/wixext/SqlTableDefinitions.cs delete mode 100644 src/wixext/tables.xml (limited to 'src') diff --git a/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs b/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs index d7fe74e6..7d51c0fb 100644 --- a/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs +++ b/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs @@ -19,8 +19,8 @@ namespace WixToolsetTest.Sql var results = build.BuildAndQuery(Build, "SqlString"); Assert.Equal(new[] { - "SqlString:TestString\tTestDB\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tCREATE TABLE TestTable1(name varchar(20), value varchar(20))\t\t1\t0", - }, results.OrderBy(s => s).ToArray()); + "SqlString:TestString\tTestDB\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tCREATE TABLE TestTable1(name varchar(20), value varchar(20))\t\t1\t", + }, results.ToArray()); } private static void Build(string[] args) diff --git a/src/wixext/SqlCompiler.cs b/src/wixext/SqlCompiler.cs index 3fb33993..22b533de 100644 --- a/src/wixext/SqlCompiler.cs +++ b/src/wixext/SqlCompiler.cs @@ -7,6 +7,7 @@ namespace WixToolset.Sql using System.Xml.Linq; using WixToolset.Data; using WixToolset.Extensibility; + using WixToolset.Sql.Tuples; /// /// The compiler for the WiX Toolset SQL Server Extension. @@ -45,8 +46,8 @@ namespace WixToolset.Sql switch (parentElement.Name.LocalName) { case "Component": - string componentId = context["ComponentId"]; - string directoryId = context["DirectoryId"]; + var componentId = context["ComponentId"]; + var directoryId = context["DirectoryId"]; switch (element.Name.LocalName) { @@ -92,7 +93,7 @@ namespace WixToolset.Sql /// Identifier for parent component. private void ParseSqlDatabaseElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId) { - SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); Identifier id = null; int attributes = 0; string database = null; @@ -102,7 +103,7 @@ namespace WixToolset.Sql string server = null; string user = null; - foreach (XAttribute attrib in element.Attributes()) + foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { @@ -230,7 +231,7 @@ namespace WixToolset.Sql if (null == id) { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); + id = this.ParseHelper.CreateIdentifier("sdb", componentId, server, database); } if (null == database) @@ -252,11 +253,11 @@ namespace WixToolset.Sql this.Messaging.Write(SqlErrors.OneOfAttributesRequiredUnderComponent(sourceLineNumbers, element.Name.LocalName, "CreateOnInstall", "CreateOnUninstall", "DropOnInstall", "DropOnUninstall")); } - foreach (XElement child in element.Elements()) + foreach (var child in element.Elements()) { if (this.Namespace == child.Name.Namespace) { - SourceLineNumber childSourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(child); + var childSourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(child); switch (child.Name.LocalName) { case "SqlScript": @@ -285,7 +286,7 @@ namespace WixToolset.Sql this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, element.Name.LocalName, child.Name.LocalName, 1)); } - fileSpec = this.ParseSqlFileSpecElement(intermediate, section, child); + fileSpec = this.ParseSqlFileSpecElement(intermediate, section, child, id?.Id); break; case "SqlLogFileSpec": if (null == componentId) @@ -297,7 +298,7 @@ namespace WixToolset.Sql this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, element.Name.LocalName, child.Name.LocalName, 1)); } - logFileSpec = this.ParseSqlFileSpecElement(intermediate, section, child); + logFileSpec = this.ParseSqlFileSpecElement(intermediate, section, child, id?.Id); break; default: this.ParseHelper.UnexpectedElement(element, child); @@ -313,23 +314,25 @@ namespace WixToolset.Sql if (null != componentId) { // Reference InstallSqlData and UninstallSqlData since nothing will happen without it - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "InstallSqlData"); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "UninstallSqlData"); + this.AddReferenceToInstallSqlData(section, sourceLineNumbers); } if (!this.Messaging.EncounteredError) { - var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlDatabase", id); - row.Set(1, server); - row.Set(2, instance); - row.Set(3, database); - row.Set(4, componentId); - row.Set(5, user); - row.Set(6, fileSpec?.Id); - row.Set(7, logFileSpec?.Id); + var tuple = section.AddTuple(new SqlDatabaseTuple(sourceLineNumbers, id) + { + Server = server, + Instance = instance, + Database = database, + ComponentRef = componentId, + UserRef = user, + FileSpecRef = fileSpec?.Id, + LogFileSpecRef = logFileSpec?.Id, + }); + if (0 != attributes) { - row.Set(8, attributes); + tuple.Attributes = attributes; } } } @@ -341,9 +344,9 @@ namespace WixToolset.Sql /// /// Element to parse. /// Identifier of sql file specification. - private Identifier ParseSqlFileSpecElement(Intermediate intermediate, IntermediateSection section, XElement element) + private Identifier ParseSqlFileSpecElement(Intermediate intermediate, IntermediateSection section, XElement element, string parentId) { - SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); Identifier id = null; string fileName = null; string growthSize = null; @@ -351,7 +354,7 @@ namespace WixToolset.Sql string name = null; string size = null; - foreach (XAttribute attrib in element.Attributes()) + foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { @@ -388,7 +391,7 @@ namespace WixToolset.Sql if (null == id) { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); + id = this.ParseHelper.CreateIdentifier("sfs", parentId, name, fileName); } if (null == name) @@ -405,22 +408,25 @@ namespace WixToolset.Sql if (!this.Messaging.EncounteredError) { - var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlFileSpec", id); - row.Set(1, name); - row.Set(2, fileName); + var tuple = section.AddTuple(new SqlFileSpecTuple(sourceLineNumbers, id) + { + Name = name, + Filename = fileName, + }); + if (null != size) { - row.Set(3, size); + tuple.Size = size; } if (null != maxSize) { - row.Set(4, maxSize); + tuple.MaxSize = maxSize; } if (null != growthSize) { - row.Set(5, growthSize); + tuple.GrowthSize = growthSize; } } @@ -435,16 +441,16 @@ namespace WixToolset.Sql /// Optional database to execute script against. private void ParseSqlScriptElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string sqlDb) { - SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); Identifier id = null; int attributes = 0; - bool rollbackAttribute = false; - bool nonRollbackAttribute = false; + var rollbackAttribute = false; + var nonRollbackAttribute = false; string binary = null; - int sequence = CompilerConstants.IntegerNotSet; + var sequence = CompilerConstants.IntegerNotSet; string user = null; - foreach (XAttribute attrib in element.Attributes()) + foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { @@ -455,7 +461,7 @@ namespace WixToolset.Sql break; case "BinaryKey": binary = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "Binary", binary); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.Binary, binary); break; case "Sequence": sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); @@ -466,7 +472,7 @@ namespace WixToolset.Sql this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, element.Parent.Name.LocalName)); } sqlDb = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "SqlDatabase", sqlDb); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SqlTupleDefinitions.SqlDatabase, sqlDb); break; case "User": user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); @@ -568,7 +574,7 @@ namespace WixToolset.Sql if (null == id) { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); + id = this.ParseHelper.CreateIdentifier("ssc", componentId, binary, sqlDb); } if (null == binary) @@ -589,20 +595,22 @@ namespace WixToolset.Sql this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); // Reference InstallSqlData and UninstallSqlData since nothing will happen without it - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "InstallSqlData"); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "UninstallSqlData"); + this.AddReferenceToInstallSqlData(section, sourceLineNumbers); if (!this.Messaging.EncounteredError) { - var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlScript", id); - row.Set(1, sqlDb); - row.Set(2, componentId); - row.Set(3, binary); - row.Set(4, user); - row.Set(5, attributes); + var tuple = section.AddTuple(new SqlScriptTuple(sourceLineNumbers, id) + { + SqlDbRef = sqlDb, + ComponentRef = componentId, + ScriptBinaryRef = binary, + UserRef = user, + Attributes = attributes, + }); + if (CompilerConstants.IntegerNotSet != sequence) { - row.Set(6, sequence); + tuple.Sequence = sequence; } } } @@ -615,16 +623,16 @@ namespace WixToolset.Sql /// Optional database to execute string against. private void ParseSqlStringElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string sqlDb) { - SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); Identifier id = null; int attributes = 0; - bool rollbackAttribute = false; - bool nonRollbackAttribute = false; - int sequence = CompilerConstants.IntegerNotSet; + var rollbackAttribute = false; + var nonRollbackAttribute = false; + var sequence = CompilerConstants.IntegerNotSet; string sql = null; string user = null; - foreach (XAttribute attrib in element.Attributes()) + foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { @@ -727,7 +735,7 @@ namespace WixToolset.Sql } sqlDb = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "SqlDatabase", sqlDb); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SqlTupleDefinitions.SqlDatabase, sqlDb); break; case "User": user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); @@ -746,7 +754,7 @@ namespace WixToolset.Sql if (null == id) { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Id")); + id = this.ParseHelper.CreateIdentifier("sst", componentId, sql, sqlDb); } if (null == sql) @@ -767,22 +775,30 @@ namespace WixToolset.Sql this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); // Reference InstallSqlData and UninstallSqlData since nothing will happen without it - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "InstallSqlData"); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "UninstallSqlData"); + this.AddReferenceToInstallSqlData(section, sourceLineNumbers); if (!this.Messaging.EncounteredError) { - var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "SqlString", id); - row.Set(1, sqlDb); - row.Set(2, componentId); - row.Set(3, sql); - row.Set(4, user); - row.Set(5, attributes); + var tuple = section.AddTuple(new SqlStringTuple(sourceLineNumbers, id) + { + SqlDbRef = sqlDb, + ComponentRef = componentId, + SQL = sql, + UserRef = user, + Attributes = attributes, + }); + if (CompilerConstants.IntegerNotSet != sequence) { - row.Set(6, sequence); + tuple.Sequence = sequence; } } } + + private void AddReferenceToInstallSqlData(IntermediateSection section, SourceLineNumber sourceLineNumbers) + { + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "InstallSqlData"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "UninstallSqlData"); + } } } diff --git a/src/wixext/SqlTableDefinitions.cs b/src/wixext/SqlTableDefinitions.cs new file mode 100644 index 00000000..e980aaae --- /dev/null +++ b/src/wixext/SqlTableDefinitions.cs @@ -0,0 +1,82 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using WixToolset.Data.WindowsInstaller; + + public static class SqlTableDefinitions + { + public static readonly TableDefinition SqlDatabase = new TableDefinition( + "SqlDatabase", + new[] + { + new ColumnDefinition("SqlDb", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Server", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Primary key, name of server running SQL Server"), + new ColumnDefinition("Instance", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Primary key, name of SQL Server instance"), + new ColumnDefinition("Database", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Primary key, name of database in a SQL Server"), + new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key, Component used to determine install state ", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "User", keyColumn: 1, description: "Foreign key, User used to log into database", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("FileSpec_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "SqlFileSpec", keyColumn: 1, description: "Foreign key referencing SqlFileSpec.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("FileSpec_Log", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "SqlFileSpec", keyColumn: 1, description: "Foreign key referencing SqlFileSpec.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, minValue: 0, maxValue: 255, description: "1 == create on install, 2 == drop on uninstall, 4 == continue on error, 8 == drop on install, 16 == create on uninstall, 32 == confirm update existing table, 64 == create on reinstall, 128 == drop on reinstall"), + }, + tupleDefinitionName: "SqlDatabase", + tupleIdIsPrimaryKey: true + ); + + public static readonly TableDefinition SqlFileSpec = new TableDefinition( + "SqlFileSpec", + new[] + { + new ColumnDefinition("FileSpec", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Name", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Logical name of filespec", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Filename", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Filename to use (path must exist)", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Size", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Initial size for file", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("MaxSize", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Maximum size for file", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("GrowthSize", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Size file should grow when necessary", modularizeType: ColumnModularizeType.Property), + }, + tupleDefinitionName: "SqlFileSpec", + tupleIdIsPrimaryKey: true + ); + + public static readonly TableDefinition SqlScript = new TableDefinition( + "SqlScript", + new[] + { + new ColumnDefinition("Script", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token"), + new ColumnDefinition("SqlDb_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "SqlDatabase", keyColumn: 1, description: "Foreign key, SQL Server key", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key, Component used to determine install state", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("ScriptBinary_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Binary", keyColumn: 1, description: "Foreign key, Binary stream that contains SQL Script to execute", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "User", keyColumn: 1, description: "Foreign key, User used to log into database", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, possibilities: "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31", description: "1 == execute on install, 2 == execute on uninstall, 4 == continue on error, 8 == rollback on install, 16 == rollback on uninstall"), + new ColumnDefinition("Sequence", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Order to execute SQL Queries in"), + }, + tupleDefinitionName: "SqlScript", + tupleIdIsPrimaryKey: true + ); + + public static readonly TableDefinition SqlString = new TableDefinition( + "SqlString", + new[] + { + new ColumnDefinition("String", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Id for the SqlString", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("SqlDb_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "SqlDatabase", keyColumn: 1, description: "Foreign key, SQL Server key", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key, Component used to determine install state", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("SQL", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "SQL query to execute"), + new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "User", keyColumn: 1, description: "Foreign key, User used to log into database", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, possibilities: "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31", description: "1 == execute on install, 2 == execute on uninstall, 4 == continue on error, 8 == rollback on install, 16 == rollback on uninstall"), + new ColumnDefinition("Sequence", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Order to execute SQL Queries in"), + }, + tupleDefinitionName: "SqlString", + tupleIdIsPrimaryKey: true + ); + + public static readonly TableDefinition[] All = new[] + { + SqlDatabase, + SqlFileSpec, + SqlScript, + SqlString, + }; + } +} diff --git a/src/wixext/SqlWindowsInstallerBackendExtension.cs b/src/wixext/SqlWindowsInstallerBackendExtension.cs index 83505059..b679e871 100644 --- a/src/wixext/SqlWindowsInstallerBackendExtension.cs +++ b/src/wixext/SqlWindowsInstallerBackendExtension.cs @@ -1,32 +1,13 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. namespace WixToolset.Sql { using System.Collections.Generic; - using System.Linq; - using System.Xml; using WixToolset.Data.WindowsInstaller; using WixToolset.Extensibility; public class SqlWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension { - public SqlWindowsInstallerBackendBinderExtension() - { - - } - - private static readonly TableDefinition[] Tables = LoadTables(); - - public override IEnumerable TableDefinitions => Tables; - - private static TableDefinition[] LoadTables() - { - using (var resourceStream = typeof(SqlWindowsInstallerBackendBinderExtension).Assembly.GetManifestResourceStream("WixToolset.Sql.tables.xml")) - using (var reader = XmlReader.Create(resourceStream)) - { - var tables = TableDefinitionCollection.Load(reader); - return tables.ToArray(); - } - } + public override IEnumerable TableDefinitions => SqlTableDefinitions.All; } } diff --git a/src/wixext/Tuples/SqlDatabaseTuple.cs b/src/wixext/Tuples/SqlDatabaseTuple.cs index fd107690..1e056212 100644 --- a/src/wixext/Tuples/SqlDatabaseTuple.cs +++ b/src/wixext/Tuples/SqlDatabaseTuple.cs @@ -11,14 +11,13 @@ namespace WixToolset.Sql SqlTupleDefinitionType.SqlDatabase.ToString(), new[] { - new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.SqlDb), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Server), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Instance), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Database), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Component_), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.User_), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.FileSpec_), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.FileSpec_Log), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.ComponentRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.UserRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.FileSpecRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.LogFileSpecRef), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Attributes), IntermediateFieldType.Number), }, typeof(SqlDatabaseTuple)); @@ -31,14 +30,13 @@ namespace WixToolset.Sql.Tuples public enum SqlDatabaseTupleFields { - SqlDb, Server, Instance, Database, - Component_, - User_, - FileSpec_, - FileSpec_Log, + ComponentRef, + UserRef, + FileSpecRef, + LogFileSpecRef, Attributes, } @@ -54,12 +52,6 @@ namespace WixToolset.Sql.Tuples public IntermediateField this[SqlDatabaseTupleFields index] => this.Fields[(int)index]; - public string SqlDb - { - get => this.Fields[(int)SqlDatabaseTupleFields.SqlDb].AsString(); - set => this.Set((int)SqlDatabaseTupleFields.SqlDb, value); - } - public string Server { get => this.Fields[(int)SqlDatabaseTupleFields.Server].AsString(); @@ -78,28 +70,28 @@ namespace WixToolset.Sql.Tuples set => this.Set((int)SqlDatabaseTupleFields.Database, value); } - public string Component_ + public string ComponentRef { - get => this.Fields[(int)SqlDatabaseTupleFields.Component_].AsString(); - set => this.Set((int)SqlDatabaseTupleFields.Component_, value); + get => this.Fields[(int)SqlDatabaseTupleFields.ComponentRef].AsString(); + set => this.Set((int)SqlDatabaseTupleFields.ComponentRef, value); } - public string User_ + public string UserRef { - get => this.Fields[(int)SqlDatabaseTupleFields.User_].AsString(); - set => this.Set((int)SqlDatabaseTupleFields.User_, value); + get => this.Fields[(int)SqlDatabaseTupleFields.UserRef].AsString(); + set => this.Set((int)SqlDatabaseTupleFields.UserRef, value); } - public string FileSpec_ + public string FileSpecRef { - get => this.Fields[(int)SqlDatabaseTupleFields.FileSpec_].AsString(); - set => this.Set((int)SqlDatabaseTupleFields.FileSpec_, value); + get => this.Fields[(int)SqlDatabaseTupleFields.FileSpecRef].AsString(); + set => this.Set((int)SqlDatabaseTupleFields.FileSpecRef, value); } - public string FileSpec_Log + public string LogFileSpecRef { - get => this.Fields[(int)SqlDatabaseTupleFields.FileSpec_Log].AsString(); - set => this.Set((int)SqlDatabaseTupleFields.FileSpec_Log, value); + get => this.Fields[(int)SqlDatabaseTupleFields.LogFileSpecRef].AsString(); + set => this.Set((int)SqlDatabaseTupleFields.LogFileSpecRef, value); } public int Attributes diff --git a/src/wixext/Tuples/SqlFileSpecTuple.cs b/src/wixext/Tuples/SqlFileSpecTuple.cs index 9813ec83..98a3002b 100644 --- a/src/wixext/Tuples/SqlFileSpecTuple.cs +++ b/src/wixext/Tuples/SqlFileSpecTuple.cs @@ -11,7 +11,6 @@ namespace WixToolset.Sql SqlTupleDefinitionType.SqlFileSpec.ToString(), new[] { - new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.FileSpec), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Name), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Filename), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Size), IntermediateFieldType.String), @@ -28,7 +27,6 @@ namespace WixToolset.Sql.Tuples public enum SqlFileSpecTupleFields { - FileSpec, Name, Filename, Size, @@ -48,12 +46,6 @@ namespace WixToolset.Sql.Tuples public IntermediateField this[SqlFileSpecTupleFields index] => this.Fields[(int)index]; - public string FileSpec - { - get => this.Fields[(int)SqlFileSpecTupleFields.FileSpec].AsString(); - set => this.Set((int)SqlFileSpecTupleFields.FileSpec, value); - } - public string Name { get => this.Fields[(int)SqlFileSpecTupleFields.Name].AsString(); diff --git a/src/wixext/Tuples/SqlScriptTuple.cs b/src/wixext/Tuples/SqlScriptTuple.cs index b1f95709..de76d49d 100644 --- a/src/wixext/Tuples/SqlScriptTuple.cs +++ b/src/wixext/Tuples/SqlScriptTuple.cs @@ -11,11 +11,10 @@ namespace WixToolset.Sql SqlTupleDefinitionType.SqlScript.ToString(), new[] { - new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Script), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.SqlDb_), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Component_), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.ScriptBinary_), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.User_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.SqlDbRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.ComponentRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.ScriptBinaryRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.UserRef), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Attributes), IntermediateFieldType.Number), new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Sequence), IntermediateFieldType.Number), }, @@ -29,11 +28,10 @@ namespace WixToolset.Sql.Tuples public enum SqlScriptTupleFields { - Script, - SqlDb_, - Component_, - ScriptBinary_, - User_, + SqlDbRef, + ComponentRef, + ScriptBinaryRef, + UserRef, Attributes, Sequence, } @@ -50,34 +48,28 @@ namespace WixToolset.Sql.Tuples public IntermediateField this[SqlScriptTupleFields index] => this.Fields[(int)index]; - public string Script + public string SqlDbRef { - get => this.Fields[(int)SqlScriptTupleFields.Script].AsString(); - set => this.Set((int)SqlScriptTupleFields.Script, value); + get => this.Fields[(int)SqlScriptTupleFields.SqlDbRef].AsString(); + set => this.Set((int)SqlScriptTupleFields.SqlDbRef, value); } - public string SqlDb_ + public string ComponentRef { - get => this.Fields[(int)SqlScriptTupleFields.SqlDb_].AsString(); - set => this.Set((int)SqlScriptTupleFields.SqlDb_, value); + get => this.Fields[(int)SqlScriptTupleFields.ComponentRef].AsString(); + set => this.Set((int)SqlScriptTupleFields.ComponentRef, value); } - public string Component_ + public string ScriptBinaryRef { - get => this.Fields[(int)SqlScriptTupleFields.Component_].AsString(); - set => this.Set((int)SqlScriptTupleFields.Component_, value); + get => this.Fields[(int)SqlScriptTupleFields.ScriptBinaryRef].AsString(); + set => this.Set((int)SqlScriptTupleFields.ScriptBinaryRef, value); } - public string ScriptBinary_ + public string UserRef { - get => this.Fields[(int)SqlScriptTupleFields.ScriptBinary_].AsString(); - set => this.Set((int)SqlScriptTupleFields.ScriptBinary_, value); - } - - public string User_ - { - get => this.Fields[(int)SqlScriptTupleFields.User_].AsString(); - set => this.Set((int)SqlScriptTupleFields.User_, value); + get => this.Fields[(int)SqlScriptTupleFields.UserRef].AsString(); + set => this.Set((int)SqlScriptTupleFields.UserRef, value); } public int Attributes diff --git a/src/wixext/Tuples/SqlStringTuple.cs b/src/wixext/Tuples/SqlStringTuple.cs index d2cba0e0..77882d33 100644 --- a/src/wixext/Tuples/SqlStringTuple.cs +++ b/src/wixext/Tuples/SqlStringTuple.cs @@ -11,11 +11,10 @@ namespace WixToolset.Sql SqlTupleDefinitionType.SqlString.ToString(), new[] { - new IntermediateFieldDefinition(nameof(SqlStringTupleFields.String), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlStringTupleFields.SqlDb_), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlStringTupleFields.Component_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringTupleFields.SqlDbRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringTupleFields.ComponentRef), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlStringTupleFields.SQL), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlStringTupleFields.User_), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringTupleFields.UserRef), IntermediateFieldType.String), new IntermediateFieldDefinition(nameof(SqlStringTupleFields.Attributes), IntermediateFieldType.Number), new IntermediateFieldDefinition(nameof(SqlStringTupleFields.Sequence), IntermediateFieldType.Number), }, @@ -29,11 +28,10 @@ namespace WixToolset.Sql.Tuples public enum SqlStringTupleFields { - String, - SqlDb_, - Component_, + SqlDbRef, + ComponentRef, SQL, - User_, + UserRef, Attributes, Sequence, } @@ -50,22 +48,16 @@ namespace WixToolset.Sql.Tuples public IntermediateField this[SqlStringTupleFields index] => this.Fields[(int)index]; - public string String + public string SqlDbRef { - get => this.Fields[(int)SqlStringTupleFields.String].AsString(); - set => this.Set((int)SqlStringTupleFields.String, value); + get => this.Fields[(int)SqlStringTupleFields.SqlDbRef].AsString(); + set => this.Set((int)SqlStringTupleFields.SqlDbRef, value); } - public string SqlDb_ + public string ComponentRef { - get => this.Fields[(int)SqlStringTupleFields.SqlDb_].AsString(); - set => this.Set((int)SqlStringTupleFields.SqlDb_, value); - } - - public string Component_ - { - get => this.Fields[(int)SqlStringTupleFields.Component_].AsString(); - set => this.Set((int)SqlStringTupleFields.Component_, value); + get => this.Fields[(int)SqlStringTupleFields.ComponentRef].AsString(); + set => this.Set((int)SqlStringTupleFields.ComponentRef, value); } public string SQL @@ -74,10 +66,10 @@ namespace WixToolset.Sql.Tuples set => this.Set((int)SqlStringTupleFields.SQL, value); } - public string User_ + public string UserRef { - get => this.Fields[(int)SqlStringTupleFields.User_].AsString(); - set => this.Set((int)SqlStringTupleFields.User_, value); + get => this.Fields[(int)SqlStringTupleFields.UserRef].AsString(); + set => this.Set((int)SqlStringTupleFields.UserRef, value); } public int Attributes diff --git a/src/wixext/WixToolset.Sql.wixext.csproj b/src/wixext/WixToolset.Sql.wixext.csproj index 5db8b9d3..73c7a4e5 100644 --- a/src/wixext/WixToolset.Sql.wixext.csproj +++ b/src/wixext/WixToolset.Sql.wixext.csproj @@ -14,7 +14,6 @@ - diff --git a/src/wixext/tables.xml b/src/wixext/tables.xml deleted file mode 100644 index a8b6c3a1..00000000 --- a/src/wixext/tables.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3-55-g6feb From 10f90c4a1fbac76278c3cccd565f7767060c8d5c Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Mon, 13 Apr 2020 18:55:48 +1000 Subject: Update dependencies. --- appveyor.yml | 5 +++++ src/Cpp.Build.props | 18 ------------------ src/wixext/SqlTableDefinitions.cs | 8 ++++---- src/wixext/Tuples/SqlScriptTuple.cs | 4 ++-- src/wixext/Tuples/SqlStringTuple.cs | 4 ++-- src/wixlib/packages.config | 2 +- src/wixlib/sql.wixproj | 4 ++-- 7 files changed, 16 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/appveyor.yml b/appveyor.yml index bbf880f0..7c686b04 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,6 +3,11 @@ # Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml # then update all of the repos. +branches: + only: + - master + - develop + image: Visual Studio 2019 version: 0.0.0.{build} diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props index 44a042c7..9b7a1bb5 100644 --- a/src/Cpp.Build.props +++ b/src/Cpp.Build.props @@ -70,12 +70,6 @@ MultiThreadedDebug - - - - MultiThreadedDebugDll - - MinSpace @@ -89,16 +83,4 @@ true - - - - MultiThreadedDll - - - - - $(LinkKeyFile) - $(LinkDelaySign) - - diff --git a/src/wixext/SqlTableDefinitions.cs b/src/wixext/SqlTableDefinitions.cs index e980aaae..3d1daee0 100644 --- a/src/wixext/SqlTableDefinitions.cs +++ b/src/wixext/SqlTableDefinitions.cs @@ -8,6 +8,7 @@ namespace WixToolset.Sql { public static readonly TableDefinition SqlDatabase = new TableDefinition( "SqlDatabase", + SqlTupleDefinitions.SqlDatabase, new[] { new ColumnDefinition("SqlDb", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token", modularizeType: ColumnModularizeType.Column), @@ -20,12 +21,12 @@ namespace WixToolset.Sql new ColumnDefinition("FileSpec_Log", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "SqlFileSpec", keyColumn: 1, description: "Foreign key referencing SqlFileSpec.", modularizeType: ColumnModularizeType.Column), new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, minValue: 0, maxValue: 255, description: "1 == create on install, 2 == drop on uninstall, 4 == continue on error, 8 == drop on install, 16 == create on uninstall, 32 == confirm update existing table, 64 == create on reinstall, 128 == drop on reinstall"), }, - tupleDefinitionName: "SqlDatabase", tupleIdIsPrimaryKey: true ); public static readonly TableDefinition SqlFileSpec = new TableDefinition( "SqlFileSpec", + SqlTupleDefinitions.SqlFileSpec, new[] { new ColumnDefinition("FileSpec", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token", modularizeType: ColumnModularizeType.Column), @@ -35,12 +36,12 @@ namespace WixToolset.Sql new ColumnDefinition("MaxSize", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Maximum size for file", modularizeType: ColumnModularizeType.Property), new ColumnDefinition("GrowthSize", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Size file should grow when necessary", modularizeType: ColumnModularizeType.Property), }, - tupleDefinitionName: "SqlFileSpec", tupleIdIsPrimaryKey: true ); public static readonly TableDefinition SqlScript = new TableDefinition( "SqlScript", + SqlTupleDefinitions.SqlScript, new[] { new ColumnDefinition("Script", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token"), @@ -51,12 +52,12 @@ namespace WixToolset.Sql new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, possibilities: "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31", description: "1 == execute on install, 2 == execute on uninstall, 4 == continue on error, 8 == rollback on install, 16 == rollback on uninstall"), new ColumnDefinition("Sequence", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Order to execute SQL Queries in"), }, - tupleDefinitionName: "SqlScript", tupleIdIsPrimaryKey: true ); public static readonly TableDefinition SqlString = new TableDefinition( "SqlString", + SqlTupleDefinitions.SqlString, new[] { new ColumnDefinition("String", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Id for the SqlString", modularizeType: ColumnModularizeType.Column), @@ -67,7 +68,6 @@ namespace WixToolset.Sql new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, possibilities: "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31", description: "1 == execute on install, 2 == execute on uninstall, 4 == continue on error, 8 == rollback on install, 16 == rollback on uninstall"), new ColumnDefinition("Sequence", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Order to execute SQL Queries in"), }, - tupleDefinitionName: "SqlString", tupleIdIsPrimaryKey: true ); diff --git a/src/wixext/Tuples/SqlScriptTuple.cs b/src/wixext/Tuples/SqlScriptTuple.cs index de76d49d..6e4e484b 100644 --- a/src/wixext/Tuples/SqlScriptTuple.cs +++ b/src/wixext/Tuples/SqlScriptTuple.cs @@ -78,9 +78,9 @@ namespace WixToolset.Sql.Tuples set => this.Set((int)SqlScriptTupleFields.Attributes, value); } - public int Sequence + public int? Sequence { - get => this.Fields[(int)SqlScriptTupleFields.Sequence].AsNumber(); + get => this.Fields[(int)SqlScriptTupleFields.Sequence].AsNullableNumber(); set => this.Set((int)SqlScriptTupleFields.Sequence, value); } } diff --git a/src/wixext/Tuples/SqlStringTuple.cs b/src/wixext/Tuples/SqlStringTuple.cs index 77882d33..7a73f271 100644 --- a/src/wixext/Tuples/SqlStringTuple.cs +++ b/src/wixext/Tuples/SqlStringTuple.cs @@ -78,9 +78,9 @@ namespace WixToolset.Sql.Tuples set => this.Set((int)SqlStringTupleFields.Attributes, value); } - public int Sequence + public int? Sequence { - get => this.Fields[(int)SqlStringTupleFields.Sequence].AsNumber(); + get => this.Fields[(int)SqlStringTupleFields.Sequence].AsNullableNumber(); set => this.Set((int)SqlStringTupleFields.Sequence, value); } } diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config index d73f4d3a..1e5a9850 100644 --- a/src/wixlib/packages.config +++ b/src/wixlib/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/src/wixlib/sql.wixproj b/src/wixlib/sql.wixproj index 7274acff..e4efb34e 100644 --- a/src/wixlib/sql.wixproj +++ b/src/wixlib/sql.wixproj @@ -1,7 +1,7 @@ - + {9ACF1A20-D801-45CC-A463-F9D13E506AA3} @@ -40,7 +40,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From bbbe36aed1ac5a1b27314a9f9658f49ef08fbb41 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 30 May 2020 15:22:41 -0700 Subject: Add NCrunch configuration --- src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.v3.ncrunchproject | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.v3.ncrunchproject (limited to 'src') diff --git a/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.v3.ncrunchproject b/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.v3.ncrunchproject new file mode 100644 index 00000000..7b5b2139 --- /dev/null +++ b/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file -- cgit v1.2.3-55-g6feb From c57f5bc9caad2adf1b0fe8fedc1003e49e272080 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 27 Jun 2020 15:00:38 -0700 Subject: The Great Tuple to Symbol Rename (tm) --- src/wixext/SqlCompiler.cs | 32 +++++++-------- src/wixext/SqlExtensionData.cs | 10 ++--- src/wixext/SqlTableDefinitions.cs | 16 ++++---- src/wixext/Tuples/SqlDatabaseTuple.cs | 70 ++++++++++++++++---------------- src/wixext/Tuples/SqlFileSpecTuple.cs | 52 ++++++++++++------------ src/wixext/Tuples/SqlScriptTuple.cs | 58 +++++++++++++------------- src/wixext/Tuples/SqlStringTuple.cs | 58 +++++++++++++------------- src/wixext/Tuples/SqlTupleDefinitions.cs | 26 ++++++------ 8 files changed, 161 insertions(+), 161 deletions(-) (limited to 'src') diff --git a/src/wixext/SqlCompiler.cs b/src/wixext/SqlCompiler.cs index 22b533de..2c0f914a 100644 --- a/src/wixext/SqlCompiler.cs +++ b/src/wixext/SqlCompiler.cs @@ -7,7 +7,7 @@ namespace WixToolset.Sql using System.Xml.Linq; using WixToolset.Data; using WixToolset.Extensibility; - using WixToolset.Sql.Tuples; + using WixToolset.Sql.Symbols; /// /// The compiler for the WiX Toolset SQL Server Extension. @@ -319,7 +319,7 @@ namespace WixToolset.Sql if (!this.Messaging.EncounteredError) { - var tuple = section.AddTuple(new SqlDatabaseTuple(sourceLineNumbers, id) + var symbol = section.AddSymbol(new SqlDatabaseSymbol(sourceLineNumbers, id) { Server = server, Instance = instance, @@ -332,7 +332,7 @@ namespace WixToolset.Sql if (0 != attributes) { - tuple.Attributes = attributes; + symbol.Attributes = attributes; } } } @@ -408,7 +408,7 @@ namespace WixToolset.Sql if (!this.Messaging.EncounteredError) { - var tuple = section.AddTuple(new SqlFileSpecTuple(sourceLineNumbers, id) + var symbol = section.AddSymbol(new SqlFileSpecSymbol(sourceLineNumbers, id) { Name = name, Filename = fileName, @@ -416,17 +416,17 @@ namespace WixToolset.Sql if (null != size) { - tuple.Size = size; + symbol.Size = size; } if (null != maxSize) { - tuple.MaxSize = maxSize; + symbol.MaxSize = maxSize; } if (null != growthSize) { - tuple.GrowthSize = growthSize; + symbol.GrowthSize = growthSize; } } @@ -461,7 +461,7 @@ namespace WixToolset.Sql break; case "BinaryKey": binary = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.Binary, binary); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.Binary, binary); break; case "Sequence": sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); @@ -472,7 +472,7 @@ namespace WixToolset.Sql this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, element.Parent.Name.LocalName)); } sqlDb = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SqlTupleDefinitions.SqlDatabase, sqlDb); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SqlSymbolDefinitions.SqlDatabase, sqlDb); break; case "User": user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); @@ -599,7 +599,7 @@ namespace WixToolset.Sql if (!this.Messaging.EncounteredError) { - var tuple = section.AddTuple(new SqlScriptTuple(sourceLineNumbers, id) + var symbol = section.AddSymbol(new SqlScriptSymbol(sourceLineNumbers, id) { SqlDbRef = sqlDb, ComponentRef = componentId, @@ -610,7 +610,7 @@ namespace WixToolset.Sql if (CompilerConstants.IntegerNotSet != sequence) { - tuple.Sequence = sequence; + symbol.Sequence = sequence; } } } @@ -735,7 +735,7 @@ namespace WixToolset.Sql } sqlDb = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SqlTupleDefinitions.SqlDatabase, sqlDb); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SqlSymbolDefinitions.SqlDatabase, sqlDb); break; case "User": user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); @@ -779,7 +779,7 @@ namespace WixToolset.Sql if (!this.Messaging.EncounteredError) { - var tuple = section.AddTuple(new SqlStringTuple(sourceLineNumbers, id) + var symbol = section.AddSymbol(new SqlStringSymbol(sourceLineNumbers, id) { SqlDbRef = sqlDb, ComponentRef = componentId, @@ -790,15 +790,15 @@ namespace WixToolset.Sql if (CompilerConstants.IntegerNotSet != sequence) { - tuple.Sequence = sequence; + symbol.Sequence = sequence; } } } private void AddReferenceToInstallSqlData(IntermediateSection section, SourceLineNumber sourceLineNumbers) { - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "InstallSqlData"); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, TupleDefinitions.CustomAction, "UninstallSqlData"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, "InstallSqlData"); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, "UninstallSqlData"); } } } diff --git a/src/wixext/SqlExtensionData.cs b/src/wixext/SqlExtensionData.cs index e27b698f..60de94fe 100644 --- a/src/wixext/SqlExtensionData.cs +++ b/src/wixext/SqlExtensionData.cs @@ -16,15 +16,15 @@ namespace WixToolset.Sql /// The default culture. public override string DefaultCulture => "en-US"; - public override bool TryGetTupleDefinitionByName(string name, out IntermediateTupleDefinition tupleDefinition) + public override bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) { - tupleDefinition = SqlTupleDefinitions.ByName(name); - return tupleDefinition != null; + symbolDefinition = SqlSymbolDefinitions.ByName(name); + return symbolDefinition != null; } - public override Intermediate GetLibrary(ITupleDefinitionCreator tupleDefinitions) + public override Intermediate GetLibrary(ISymbolDefinitionCreator symbolDefinitions) { - return Intermediate.Load(typeof(SqlExtensionData).Assembly, "WixToolset.Sql.sql.wixlib", tupleDefinitions); + return Intermediate.Load(typeof(SqlExtensionData).Assembly, "WixToolset.Sql.sql.wixlib", symbolDefinitions); } } } diff --git a/src/wixext/SqlTableDefinitions.cs b/src/wixext/SqlTableDefinitions.cs index 3d1daee0..0ab6f989 100644 --- a/src/wixext/SqlTableDefinitions.cs +++ b/src/wixext/SqlTableDefinitions.cs @@ -8,7 +8,7 @@ namespace WixToolset.Sql { public static readonly TableDefinition SqlDatabase = new TableDefinition( "SqlDatabase", - SqlTupleDefinitions.SqlDatabase, + SqlSymbolDefinitions.SqlDatabase, new[] { new ColumnDefinition("SqlDb", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token", modularizeType: ColumnModularizeType.Column), @@ -21,12 +21,12 @@ namespace WixToolset.Sql new ColumnDefinition("FileSpec_Log", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "SqlFileSpec", keyColumn: 1, description: "Foreign key referencing SqlFileSpec.", modularizeType: ColumnModularizeType.Column), new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, minValue: 0, maxValue: 255, description: "1 == create on install, 2 == drop on uninstall, 4 == continue on error, 8 == drop on install, 16 == create on uninstall, 32 == confirm update existing table, 64 == create on reinstall, 128 == drop on reinstall"), }, - tupleIdIsPrimaryKey: true + symbolIdIsPrimaryKey: true ); public static readonly TableDefinition SqlFileSpec = new TableDefinition( "SqlFileSpec", - SqlTupleDefinitions.SqlFileSpec, + SqlSymbolDefinitions.SqlFileSpec, new[] { new ColumnDefinition("FileSpec", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token", modularizeType: ColumnModularizeType.Column), @@ -36,12 +36,12 @@ namespace WixToolset.Sql new ColumnDefinition("MaxSize", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Maximum size for file", modularizeType: ColumnModularizeType.Property), new ColumnDefinition("GrowthSize", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Size file should grow when necessary", modularizeType: ColumnModularizeType.Property), }, - tupleIdIsPrimaryKey: true + symbolIdIsPrimaryKey: true ); public static readonly TableDefinition SqlScript = new TableDefinition( "SqlScript", - SqlTupleDefinitions.SqlScript, + SqlSymbolDefinitions.SqlScript, new[] { new ColumnDefinition("Script", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token"), @@ -52,12 +52,12 @@ namespace WixToolset.Sql new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, possibilities: "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31", description: "1 == execute on install, 2 == execute on uninstall, 4 == continue on error, 8 == rollback on install, 16 == rollback on uninstall"), new ColumnDefinition("Sequence", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Order to execute SQL Queries in"), }, - tupleIdIsPrimaryKey: true + symbolIdIsPrimaryKey: true ); public static readonly TableDefinition SqlString = new TableDefinition( "SqlString", - SqlTupleDefinitions.SqlString, + SqlSymbolDefinitions.SqlString, new[] { new ColumnDefinition("String", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Id for the SqlString", modularizeType: ColumnModularizeType.Column), @@ -68,7 +68,7 @@ namespace WixToolset.Sql new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, possibilities: "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31", description: "1 == execute on install, 2 == execute on uninstall, 4 == continue on error, 8 == rollback on install, 16 == rollback on uninstall"), new ColumnDefinition("Sequence", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Order to execute SQL Queries in"), }, - tupleIdIsPrimaryKey: true + symbolIdIsPrimaryKey: true ); public static readonly TableDefinition[] All = new[] diff --git a/src/wixext/Tuples/SqlDatabaseTuple.cs b/src/wixext/Tuples/SqlDatabaseTuple.cs index 1e056212..6f0820ac 100644 --- a/src/wixext/Tuples/SqlDatabaseTuple.cs +++ b/src/wixext/Tuples/SqlDatabaseTuple.cs @@ -3,32 +3,32 @@ namespace WixToolset.Sql { using WixToolset.Data; - using WixToolset.Sql.Tuples; + using WixToolset.Sql.Symbols; - public static partial class SqlTupleDefinitions + public static partial class SqlSymbolDefinitions { - public static readonly IntermediateTupleDefinition SqlDatabase = new IntermediateTupleDefinition( - SqlTupleDefinitionType.SqlDatabase.ToString(), + public static readonly IntermediateSymbolDefinition SqlDatabase = new IntermediateSymbolDefinition( + SqlSymbolDefinitionType.SqlDatabase.ToString(), new[] { - new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Server), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Instance), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Database), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.ComponentRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.UserRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.FileSpecRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.LogFileSpecRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseTupleFields.Attributes), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Server), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Instance), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Database), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.ComponentRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.UserRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.FileSpecRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.LogFileSpecRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Attributes), IntermediateFieldType.Number), }, - typeof(SqlDatabaseTuple)); + typeof(SqlDatabaseSymbol)); } } -namespace WixToolset.Sql.Tuples +namespace WixToolset.Sql.Symbols { using WixToolset.Data; - public enum SqlDatabaseTupleFields + public enum SqlDatabaseSymbolFields { Server, Instance, @@ -40,64 +40,64 @@ namespace WixToolset.Sql.Tuples Attributes, } - public class SqlDatabaseTuple : IntermediateTuple + public class SqlDatabaseSymbol : IntermediateSymbol { - public SqlDatabaseTuple() : base(SqlTupleDefinitions.SqlDatabase, null, null) + public SqlDatabaseSymbol() : base(SqlSymbolDefinitions.SqlDatabase, null, null) { } - public SqlDatabaseTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlTupleDefinitions.SqlDatabase, sourceLineNumber, id) + public SqlDatabaseSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlDatabase, sourceLineNumber, id) { } - public IntermediateField this[SqlDatabaseTupleFields index] => this.Fields[(int)index]; + public IntermediateField this[SqlDatabaseSymbolFields index] => this.Fields[(int)index]; public string Server { - get => this.Fields[(int)SqlDatabaseTupleFields.Server].AsString(); - set => this.Set((int)SqlDatabaseTupleFields.Server, value); + get => this.Fields[(int)SqlDatabaseSymbolFields.Server].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.Server, value); } public string Instance { - get => this.Fields[(int)SqlDatabaseTupleFields.Instance].AsString(); - set => this.Set((int)SqlDatabaseTupleFields.Instance, value); + get => this.Fields[(int)SqlDatabaseSymbolFields.Instance].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.Instance, value); } public string Database { - get => this.Fields[(int)SqlDatabaseTupleFields.Database].AsString(); - set => this.Set((int)SqlDatabaseTupleFields.Database, value); + get => this.Fields[(int)SqlDatabaseSymbolFields.Database].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.Database, value); } public string ComponentRef { - get => this.Fields[(int)SqlDatabaseTupleFields.ComponentRef].AsString(); - set => this.Set((int)SqlDatabaseTupleFields.ComponentRef, value); + get => this.Fields[(int)SqlDatabaseSymbolFields.ComponentRef].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.ComponentRef, value); } public string UserRef { - get => this.Fields[(int)SqlDatabaseTupleFields.UserRef].AsString(); - set => this.Set((int)SqlDatabaseTupleFields.UserRef, value); + get => this.Fields[(int)SqlDatabaseSymbolFields.UserRef].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.UserRef, value); } public string FileSpecRef { - get => this.Fields[(int)SqlDatabaseTupleFields.FileSpecRef].AsString(); - set => this.Set((int)SqlDatabaseTupleFields.FileSpecRef, value); + get => this.Fields[(int)SqlDatabaseSymbolFields.FileSpecRef].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.FileSpecRef, value); } public string LogFileSpecRef { - get => this.Fields[(int)SqlDatabaseTupleFields.LogFileSpecRef].AsString(); - set => this.Set((int)SqlDatabaseTupleFields.LogFileSpecRef, value); + get => this.Fields[(int)SqlDatabaseSymbolFields.LogFileSpecRef].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.LogFileSpecRef, value); } public int Attributes { - get => this.Fields[(int)SqlDatabaseTupleFields.Attributes].AsNumber(); - set => this.Set((int)SqlDatabaseTupleFields.Attributes, value); + get => this.Fields[(int)SqlDatabaseSymbolFields.Attributes].AsNumber(); + set => this.Set((int)SqlDatabaseSymbolFields.Attributes, value); } } } \ No newline at end of file diff --git a/src/wixext/Tuples/SqlFileSpecTuple.cs b/src/wixext/Tuples/SqlFileSpecTuple.cs index 98a3002b..d9eecc62 100644 --- a/src/wixext/Tuples/SqlFileSpecTuple.cs +++ b/src/wixext/Tuples/SqlFileSpecTuple.cs @@ -3,29 +3,29 @@ namespace WixToolset.Sql { using WixToolset.Data; - using WixToolset.Sql.Tuples; + using WixToolset.Sql.Symbols; - public static partial class SqlTupleDefinitions + public static partial class SqlSymbolDefinitions { - public static readonly IntermediateTupleDefinition SqlFileSpec = new IntermediateTupleDefinition( - SqlTupleDefinitionType.SqlFileSpec.ToString(), + public static readonly IntermediateSymbolDefinition SqlFileSpec = new IntermediateSymbolDefinition( + SqlSymbolDefinitionType.SqlFileSpec.ToString(), new[] { - new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Name), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Filename), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.Size), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.MaxSize), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlFileSpecTupleFields.GrowthSize), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.Name), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.Filename), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.Size), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.MaxSize), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.GrowthSize), IntermediateFieldType.String), }, - typeof(SqlFileSpecTuple)); + typeof(SqlFileSpecSymbol)); } } -namespace WixToolset.Sql.Tuples +namespace WixToolset.Sql.Symbols { using WixToolset.Data; - public enum SqlFileSpecTupleFields + public enum SqlFileSpecSymbolFields { Name, Filename, @@ -34,46 +34,46 @@ namespace WixToolset.Sql.Tuples GrowthSize, } - public class SqlFileSpecTuple : IntermediateTuple + public class SqlFileSpecSymbol : IntermediateSymbol { - public SqlFileSpecTuple() : base(SqlTupleDefinitions.SqlFileSpec, null, null) + public SqlFileSpecSymbol() : base(SqlSymbolDefinitions.SqlFileSpec, null, null) { } - public SqlFileSpecTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlTupleDefinitions.SqlFileSpec, sourceLineNumber, id) + public SqlFileSpecSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlFileSpec, sourceLineNumber, id) { } - public IntermediateField this[SqlFileSpecTupleFields index] => this.Fields[(int)index]; + public IntermediateField this[SqlFileSpecSymbolFields index] => this.Fields[(int)index]; public string Name { - get => this.Fields[(int)SqlFileSpecTupleFields.Name].AsString(); - set => this.Set((int)SqlFileSpecTupleFields.Name, value); + get => this.Fields[(int)SqlFileSpecSymbolFields.Name].AsString(); + set => this.Set((int)SqlFileSpecSymbolFields.Name, value); } public string Filename { - get => this.Fields[(int)SqlFileSpecTupleFields.Filename].AsString(); - set => this.Set((int)SqlFileSpecTupleFields.Filename, value); + get => this.Fields[(int)SqlFileSpecSymbolFields.Filename].AsString(); + set => this.Set((int)SqlFileSpecSymbolFields.Filename, value); } public string Size { - get => this.Fields[(int)SqlFileSpecTupleFields.Size].AsString(); - set => this.Set((int)SqlFileSpecTupleFields.Size, value); + get => this.Fields[(int)SqlFileSpecSymbolFields.Size].AsString(); + set => this.Set((int)SqlFileSpecSymbolFields.Size, value); } public string MaxSize { - get => this.Fields[(int)SqlFileSpecTupleFields.MaxSize].AsString(); - set => this.Set((int)SqlFileSpecTupleFields.MaxSize, value); + get => this.Fields[(int)SqlFileSpecSymbolFields.MaxSize].AsString(); + set => this.Set((int)SqlFileSpecSymbolFields.MaxSize, value); } public string GrowthSize { - get => this.Fields[(int)SqlFileSpecTupleFields.GrowthSize].AsString(); - set => this.Set((int)SqlFileSpecTupleFields.GrowthSize, value); + get => this.Fields[(int)SqlFileSpecSymbolFields.GrowthSize].AsString(); + set => this.Set((int)SqlFileSpecSymbolFields.GrowthSize, value); } } } \ No newline at end of file diff --git a/src/wixext/Tuples/SqlScriptTuple.cs b/src/wixext/Tuples/SqlScriptTuple.cs index 6e4e484b..94c70390 100644 --- a/src/wixext/Tuples/SqlScriptTuple.cs +++ b/src/wixext/Tuples/SqlScriptTuple.cs @@ -3,30 +3,30 @@ namespace WixToolset.Sql { using WixToolset.Data; - using WixToolset.Sql.Tuples; + using WixToolset.Sql.Symbols; - public static partial class SqlTupleDefinitions + public static partial class SqlSymbolDefinitions { - public static readonly IntermediateTupleDefinition SqlScript = new IntermediateTupleDefinition( - SqlTupleDefinitionType.SqlScript.ToString(), + public static readonly IntermediateSymbolDefinition SqlScript = new IntermediateSymbolDefinition( + SqlSymbolDefinitionType.SqlScript.ToString(), new[] { - new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.SqlDbRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.ComponentRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.ScriptBinaryRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.UserRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Attributes), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(SqlScriptTupleFields.Sequence), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.SqlDbRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.ComponentRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.ScriptBinaryRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.UserRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.Attributes), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.Sequence), IntermediateFieldType.Number), }, - typeof(SqlScriptTuple)); + typeof(SqlScriptSymbol)); } } -namespace WixToolset.Sql.Tuples +namespace WixToolset.Sql.Symbols { using WixToolset.Data; - public enum SqlScriptTupleFields + public enum SqlScriptSymbolFields { SqlDbRef, ComponentRef, @@ -36,52 +36,52 @@ namespace WixToolset.Sql.Tuples Sequence, } - public class SqlScriptTuple : IntermediateTuple + public class SqlScriptSymbol : IntermediateSymbol { - public SqlScriptTuple() : base(SqlTupleDefinitions.SqlScript, null, null) + public SqlScriptSymbol() : base(SqlSymbolDefinitions.SqlScript, null, null) { } - public SqlScriptTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlTupleDefinitions.SqlScript, sourceLineNumber, id) + public SqlScriptSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlScript, sourceLineNumber, id) { } - public IntermediateField this[SqlScriptTupleFields index] => this.Fields[(int)index]; + public IntermediateField this[SqlScriptSymbolFields index] => this.Fields[(int)index]; public string SqlDbRef { - get => this.Fields[(int)SqlScriptTupleFields.SqlDbRef].AsString(); - set => this.Set((int)SqlScriptTupleFields.SqlDbRef, value); + get => this.Fields[(int)SqlScriptSymbolFields.SqlDbRef].AsString(); + set => this.Set((int)SqlScriptSymbolFields.SqlDbRef, value); } public string ComponentRef { - get => this.Fields[(int)SqlScriptTupleFields.ComponentRef].AsString(); - set => this.Set((int)SqlScriptTupleFields.ComponentRef, value); + get => this.Fields[(int)SqlScriptSymbolFields.ComponentRef].AsString(); + set => this.Set((int)SqlScriptSymbolFields.ComponentRef, value); } public string ScriptBinaryRef { - get => this.Fields[(int)SqlScriptTupleFields.ScriptBinaryRef].AsString(); - set => this.Set((int)SqlScriptTupleFields.ScriptBinaryRef, value); + get => this.Fields[(int)SqlScriptSymbolFields.ScriptBinaryRef].AsString(); + set => this.Set((int)SqlScriptSymbolFields.ScriptBinaryRef, value); } public string UserRef { - get => this.Fields[(int)SqlScriptTupleFields.UserRef].AsString(); - set => this.Set((int)SqlScriptTupleFields.UserRef, value); + get => this.Fields[(int)SqlScriptSymbolFields.UserRef].AsString(); + set => this.Set((int)SqlScriptSymbolFields.UserRef, value); } public int Attributes { - get => this.Fields[(int)SqlScriptTupleFields.Attributes].AsNumber(); - set => this.Set((int)SqlScriptTupleFields.Attributes, value); + get => this.Fields[(int)SqlScriptSymbolFields.Attributes].AsNumber(); + set => this.Set((int)SqlScriptSymbolFields.Attributes, value); } public int? Sequence { - get => this.Fields[(int)SqlScriptTupleFields.Sequence].AsNullableNumber(); - set => this.Set((int)SqlScriptTupleFields.Sequence, value); + get => this.Fields[(int)SqlScriptSymbolFields.Sequence].AsNullableNumber(); + set => this.Set((int)SqlScriptSymbolFields.Sequence, value); } } } \ No newline at end of file diff --git a/src/wixext/Tuples/SqlStringTuple.cs b/src/wixext/Tuples/SqlStringTuple.cs index 7a73f271..73a8206e 100644 --- a/src/wixext/Tuples/SqlStringTuple.cs +++ b/src/wixext/Tuples/SqlStringTuple.cs @@ -3,30 +3,30 @@ namespace WixToolset.Sql { using WixToolset.Data; - using WixToolset.Sql.Tuples; + using WixToolset.Sql.Symbols; - public static partial class SqlTupleDefinitions + public static partial class SqlSymbolDefinitions { - public static readonly IntermediateTupleDefinition SqlString = new IntermediateTupleDefinition( - SqlTupleDefinitionType.SqlString.ToString(), + public static readonly IntermediateSymbolDefinition SqlString = new IntermediateSymbolDefinition( + SqlSymbolDefinitionType.SqlString.ToString(), new[] { - new IntermediateFieldDefinition(nameof(SqlStringTupleFields.SqlDbRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlStringTupleFields.ComponentRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlStringTupleFields.SQL), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlStringTupleFields.UserRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlStringTupleFields.Attributes), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(SqlStringTupleFields.Sequence), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.SqlDbRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.ComponentRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.SQL), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.UserRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.Attributes), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.Sequence), IntermediateFieldType.Number), }, - typeof(SqlStringTuple)); + typeof(SqlStringSymbol)); } } -namespace WixToolset.Sql.Tuples +namespace WixToolset.Sql.Symbols { using WixToolset.Data; - public enum SqlStringTupleFields + public enum SqlStringSymbolFields { SqlDbRef, ComponentRef, @@ -36,52 +36,52 @@ namespace WixToolset.Sql.Tuples Sequence, } - public class SqlStringTuple : IntermediateTuple + public class SqlStringSymbol : IntermediateSymbol { - public SqlStringTuple() : base(SqlTupleDefinitions.SqlString, null, null) + public SqlStringSymbol() : base(SqlSymbolDefinitions.SqlString, null, null) { } - public SqlStringTuple(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlTupleDefinitions.SqlString, sourceLineNumber, id) + public SqlStringSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlString, sourceLineNumber, id) { } - public IntermediateField this[SqlStringTupleFields index] => this.Fields[(int)index]; + public IntermediateField this[SqlStringSymbolFields index] => this.Fields[(int)index]; public string SqlDbRef { - get => this.Fields[(int)SqlStringTupleFields.SqlDbRef].AsString(); - set => this.Set((int)SqlStringTupleFields.SqlDbRef, value); + get => this.Fields[(int)SqlStringSymbolFields.SqlDbRef].AsString(); + set => this.Set((int)SqlStringSymbolFields.SqlDbRef, value); } public string ComponentRef { - get => this.Fields[(int)SqlStringTupleFields.ComponentRef].AsString(); - set => this.Set((int)SqlStringTupleFields.ComponentRef, value); + get => this.Fields[(int)SqlStringSymbolFields.ComponentRef].AsString(); + set => this.Set((int)SqlStringSymbolFields.ComponentRef, value); } public string SQL { - get => this.Fields[(int)SqlStringTupleFields.SQL].AsString(); - set => this.Set((int)SqlStringTupleFields.SQL, value); + get => this.Fields[(int)SqlStringSymbolFields.SQL].AsString(); + set => this.Set((int)SqlStringSymbolFields.SQL, value); } public string UserRef { - get => this.Fields[(int)SqlStringTupleFields.UserRef].AsString(); - set => this.Set((int)SqlStringTupleFields.UserRef, value); + get => this.Fields[(int)SqlStringSymbolFields.UserRef].AsString(); + set => this.Set((int)SqlStringSymbolFields.UserRef, value); } public int Attributes { - get => this.Fields[(int)SqlStringTupleFields.Attributes].AsNumber(); - set => this.Set((int)SqlStringTupleFields.Attributes, value); + get => this.Fields[(int)SqlStringSymbolFields.Attributes].AsNumber(); + set => this.Set((int)SqlStringSymbolFields.Attributes, value); } public int? Sequence { - get => this.Fields[(int)SqlStringTupleFields.Sequence].AsNullableNumber(); - set => this.Set((int)SqlStringTupleFields.Sequence, value); + get => this.Fields[(int)SqlStringSymbolFields.Sequence].AsNullableNumber(); + set => this.Set((int)SqlStringSymbolFields.Sequence, value); } } } \ No newline at end of file diff --git a/src/wixext/Tuples/SqlTupleDefinitions.cs b/src/wixext/Tuples/SqlTupleDefinitions.cs index b99b96a7..336f1546 100644 --- a/src/wixext/Tuples/SqlTupleDefinitions.cs +++ b/src/wixext/Tuples/SqlTupleDefinitions.cs @@ -5,7 +5,7 @@ namespace WixToolset.Sql using System; using WixToolset.Data; - public enum SqlTupleDefinitionType + public enum SqlSymbolDefinitionType { SqlDatabase, SqlFileSpec, @@ -13,13 +13,13 @@ namespace WixToolset.Sql SqlString, } - public static partial class SqlTupleDefinitions + public static partial class SqlSymbolDefinitions { public static readonly Version Version = new Version("4.0.0"); - public static IntermediateTupleDefinition ByName(string name) + public static IntermediateSymbolDefinition ByName(string name) { - if (!Enum.TryParse(name, out SqlTupleDefinitionType type)) + if (!Enum.TryParse(name, out SqlSymbolDefinitionType type)) { return null; } @@ -27,21 +27,21 @@ namespace WixToolset.Sql return ByType(type); } - public static IntermediateTupleDefinition ByType(SqlTupleDefinitionType type) + public static IntermediateSymbolDefinition ByType(SqlSymbolDefinitionType type) { switch (type) { - case SqlTupleDefinitionType.SqlDatabase: - return SqlTupleDefinitions.SqlDatabase; + case SqlSymbolDefinitionType.SqlDatabase: + return SqlSymbolDefinitions.SqlDatabase; - case SqlTupleDefinitionType.SqlFileSpec: - return SqlTupleDefinitions.SqlFileSpec; + case SqlSymbolDefinitionType.SqlFileSpec: + return SqlSymbolDefinitions.SqlFileSpec; - case SqlTupleDefinitionType.SqlScript: - return SqlTupleDefinitions.SqlScript; + case SqlSymbolDefinitionType.SqlScript: + return SqlSymbolDefinitions.SqlScript; - case SqlTupleDefinitionType.SqlString: - return SqlTupleDefinitions.SqlString; + case SqlSymbolDefinitionType.SqlString: + return SqlSymbolDefinitions.SqlString; default: throw new ArgumentOutOfRangeException(nameof(type)); -- cgit v1.2.3-55-g6feb From a10ff79543ee924954a6e6ae2199495996a1eec9 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 27 Jun 2020 15:01:37 -0700 Subject: The Great Tuple to Symbol File Rename (tm) --- src/wixext/Symbols/SqlDatabaseSymbol.cs | 103 +++++++++++++++++++++++++++++ src/wixext/Symbols/SqlFileSpecSymbol.cs | 79 ++++++++++++++++++++++ src/wixext/Symbols/SqlScriptSymbol.cs | 87 ++++++++++++++++++++++++ src/wixext/Symbols/SqlStringSymbol.cs | 87 ++++++++++++++++++++++++ src/wixext/Symbols/SqlSymbolDefinitions.cs | 51 ++++++++++++++ src/wixext/Tuples/SqlDatabaseTuple.cs | 103 ----------------------------- src/wixext/Tuples/SqlFileSpecTuple.cs | 79 ---------------------- src/wixext/Tuples/SqlScriptTuple.cs | 87 ------------------------ src/wixext/Tuples/SqlStringTuple.cs | 87 ------------------------ src/wixext/Tuples/SqlTupleDefinitions.cs | 51 -------------- 10 files changed, 407 insertions(+), 407 deletions(-) create mode 100644 src/wixext/Symbols/SqlDatabaseSymbol.cs create mode 100644 src/wixext/Symbols/SqlFileSpecSymbol.cs create mode 100644 src/wixext/Symbols/SqlScriptSymbol.cs create mode 100644 src/wixext/Symbols/SqlStringSymbol.cs create mode 100644 src/wixext/Symbols/SqlSymbolDefinitions.cs delete mode 100644 src/wixext/Tuples/SqlDatabaseTuple.cs delete mode 100644 src/wixext/Tuples/SqlFileSpecTuple.cs delete mode 100644 src/wixext/Tuples/SqlScriptTuple.cs delete mode 100644 src/wixext/Tuples/SqlStringTuple.cs delete mode 100644 src/wixext/Tuples/SqlTupleDefinitions.cs (limited to 'src') diff --git a/src/wixext/Symbols/SqlDatabaseSymbol.cs b/src/wixext/Symbols/SqlDatabaseSymbol.cs new file mode 100644 index 00000000..6f0820ac --- /dev/null +++ b/src/wixext/Symbols/SqlDatabaseSymbol.cs @@ -0,0 +1,103 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using WixToolset.Data; + using WixToolset.Sql.Symbols; + + public static partial class SqlSymbolDefinitions + { + public static readonly IntermediateSymbolDefinition SqlDatabase = new IntermediateSymbolDefinition( + SqlSymbolDefinitionType.SqlDatabase.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Server), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Instance), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Database), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.ComponentRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.UserRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.FileSpecRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.LogFileSpecRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Attributes), IntermediateFieldType.Number), + }, + typeof(SqlDatabaseSymbol)); + } +} + +namespace WixToolset.Sql.Symbols +{ + using WixToolset.Data; + + public enum SqlDatabaseSymbolFields + { + Server, + Instance, + Database, + ComponentRef, + UserRef, + FileSpecRef, + LogFileSpecRef, + Attributes, + } + + public class SqlDatabaseSymbol : IntermediateSymbol + { + public SqlDatabaseSymbol() : base(SqlSymbolDefinitions.SqlDatabase, null, null) + { + } + + public SqlDatabaseSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlDatabase, sourceLineNumber, id) + { + } + + public IntermediateField this[SqlDatabaseSymbolFields index] => this.Fields[(int)index]; + + public string Server + { + get => this.Fields[(int)SqlDatabaseSymbolFields.Server].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.Server, value); + } + + public string Instance + { + get => this.Fields[(int)SqlDatabaseSymbolFields.Instance].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.Instance, value); + } + + public string Database + { + get => this.Fields[(int)SqlDatabaseSymbolFields.Database].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.Database, value); + } + + public string ComponentRef + { + get => this.Fields[(int)SqlDatabaseSymbolFields.ComponentRef].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.ComponentRef, value); + } + + public string UserRef + { + get => this.Fields[(int)SqlDatabaseSymbolFields.UserRef].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.UserRef, value); + } + + public string FileSpecRef + { + get => this.Fields[(int)SqlDatabaseSymbolFields.FileSpecRef].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.FileSpecRef, value); + } + + public string LogFileSpecRef + { + get => this.Fields[(int)SqlDatabaseSymbolFields.LogFileSpecRef].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.LogFileSpecRef, value); + } + + public int Attributes + { + get => this.Fields[(int)SqlDatabaseSymbolFields.Attributes].AsNumber(); + set => this.Set((int)SqlDatabaseSymbolFields.Attributes, value); + } + } +} \ No newline at end of file diff --git a/src/wixext/Symbols/SqlFileSpecSymbol.cs b/src/wixext/Symbols/SqlFileSpecSymbol.cs new file mode 100644 index 00000000..d9eecc62 --- /dev/null +++ b/src/wixext/Symbols/SqlFileSpecSymbol.cs @@ -0,0 +1,79 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using WixToolset.Data; + using WixToolset.Sql.Symbols; + + public static partial class SqlSymbolDefinitions + { + public static readonly IntermediateSymbolDefinition SqlFileSpec = new IntermediateSymbolDefinition( + SqlSymbolDefinitionType.SqlFileSpec.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.Name), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.Filename), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.Size), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.MaxSize), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.GrowthSize), IntermediateFieldType.String), + }, + typeof(SqlFileSpecSymbol)); + } +} + +namespace WixToolset.Sql.Symbols +{ + using WixToolset.Data; + + public enum SqlFileSpecSymbolFields + { + Name, + Filename, + Size, + MaxSize, + GrowthSize, + } + + public class SqlFileSpecSymbol : IntermediateSymbol + { + public SqlFileSpecSymbol() : base(SqlSymbolDefinitions.SqlFileSpec, null, null) + { + } + + public SqlFileSpecSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlFileSpec, sourceLineNumber, id) + { + } + + public IntermediateField this[SqlFileSpecSymbolFields index] => this.Fields[(int)index]; + + public string Name + { + get => this.Fields[(int)SqlFileSpecSymbolFields.Name].AsString(); + set => this.Set((int)SqlFileSpecSymbolFields.Name, value); + } + + public string Filename + { + get => this.Fields[(int)SqlFileSpecSymbolFields.Filename].AsString(); + set => this.Set((int)SqlFileSpecSymbolFields.Filename, value); + } + + public string Size + { + get => this.Fields[(int)SqlFileSpecSymbolFields.Size].AsString(); + set => this.Set((int)SqlFileSpecSymbolFields.Size, value); + } + + public string MaxSize + { + get => this.Fields[(int)SqlFileSpecSymbolFields.MaxSize].AsString(); + set => this.Set((int)SqlFileSpecSymbolFields.MaxSize, value); + } + + public string GrowthSize + { + get => this.Fields[(int)SqlFileSpecSymbolFields.GrowthSize].AsString(); + set => this.Set((int)SqlFileSpecSymbolFields.GrowthSize, value); + } + } +} \ No newline at end of file diff --git a/src/wixext/Symbols/SqlScriptSymbol.cs b/src/wixext/Symbols/SqlScriptSymbol.cs new file mode 100644 index 00000000..94c70390 --- /dev/null +++ b/src/wixext/Symbols/SqlScriptSymbol.cs @@ -0,0 +1,87 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using WixToolset.Data; + using WixToolset.Sql.Symbols; + + public static partial class SqlSymbolDefinitions + { + public static readonly IntermediateSymbolDefinition SqlScript = new IntermediateSymbolDefinition( + SqlSymbolDefinitionType.SqlScript.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.SqlDbRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.ComponentRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.ScriptBinaryRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.UserRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.Attributes), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.Sequence), IntermediateFieldType.Number), + }, + typeof(SqlScriptSymbol)); + } +} + +namespace WixToolset.Sql.Symbols +{ + using WixToolset.Data; + + public enum SqlScriptSymbolFields + { + SqlDbRef, + ComponentRef, + ScriptBinaryRef, + UserRef, + Attributes, + Sequence, + } + + public class SqlScriptSymbol : IntermediateSymbol + { + public SqlScriptSymbol() : base(SqlSymbolDefinitions.SqlScript, null, null) + { + } + + public SqlScriptSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlScript, sourceLineNumber, id) + { + } + + public IntermediateField this[SqlScriptSymbolFields index] => this.Fields[(int)index]; + + public string SqlDbRef + { + get => this.Fields[(int)SqlScriptSymbolFields.SqlDbRef].AsString(); + set => this.Set((int)SqlScriptSymbolFields.SqlDbRef, value); + } + + public string ComponentRef + { + get => this.Fields[(int)SqlScriptSymbolFields.ComponentRef].AsString(); + set => this.Set((int)SqlScriptSymbolFields.ComponentRef, value); + } + + public string ScriptBinaryRef + { + get => this.Fields[(int)SqlScriptSymbolFields.ScriptBinaryRef].AsString(); + set => this.Set((int)SqlScriptSymbolFields.ScriptBinaryRef, value); + } + + public string UserRef + { + get => this.Fields[(int)SqlScriptSymbolFields.UserRef].AsString(); + set => this.Set((int)SqlScriptSymbolFields.UserRef, value); + } + + public int Attributes + { + get => this.Fields[(int)SqlScriptSymbolFields.Attributes].AsNumber(); + set => this.Set((int)SqlScriptSymbolFields.Attributes, value); + } + + public int? Sequence + { + get => this.Fields[(int)SqlScriptSymbolFields.Sequence].AsNullableNumber(); + set => this.Set((int)SqlScriptSymbolFields.Sequence, value); + } + } +} \ No newline at end of file diff --git a/src/wixext/Symbols/SqlStringSymbol.cs b/src/wixext/Symbols/SqlStringSymbol.cs new file mode 100644 index 00000000..73a8206e --- /dev/null +++ b/src/wixext/Symbols/SqlStringSymbol.cs @@ -0,0 +1,87 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using WixToolset.Data; + using WixToolset.Sql.Symbols; + + public static partial class SqlSymbolDefinitions + { + public static readonly IntermediateSymbolDefinition SqlString = new IntermediateSymbolDefinition( + SqlSymbolDefinitionType.SqlString.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.SqlDbRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.ComponentRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.SQL), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.UserRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.Attributes), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.Sequence), IntermediateFieldType.Number), + }, + typeof(SqlStringSymbol)); + } +} + +namespace WixToolset.Sql.Symbols +{ + using WixToolset.Data; + + public enum SqlStringSymbolFields + { + SqlDbRef, + ComponentRef, + SQL, + UserRef, + Attributes, + Sequence, + } + + public class SqlStringSymbol : IntermediateSymbol + { + public SqlStringSymbol() : base(SqlSymbolDefinitions.SqlString, null, null) + { + } + + public SqlStringSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlString, sourceLineNumber, id) + { + } + + public IntermediateField this[SqlStringSymbolFields index] => this.Fields[(int)index]; + + public string SqlDbRef + { + get => this.Fields[(int)SqlStringSymbolFields.SqlDbRef].AsString(); + set => this.Set((int)SqlStringSymbolFields.SqlDbRef, value); + } + + public string ComponentRef + { + get => this.Fields[(int)SqlStringSymbolFields.ComponentRef].AsString(); + set => this.Set((int)SqlStringSymbolFields.ComponentRef, value); + } + + public string SQL + { + get => this.Fields[(int)SqlStringSymbolFields.SQL].AsString(); + set => this.Set((int)SqlStringSymbolFields.SQL, value); + } + + public string UserRef + { + get => this.Fields[(int)SqlStringSymbolFields.UserRef].AsString(); + set => this.Set((int)SqlStringSymbolFields.UserRef, value); + } + + public int Attributes + { + get => this.Fields[(int)SqlStringSymbolFields.Attributes].AsNumber(); + set => this.Set((int)SqlStringSymbolFields.Attributes, value); + } + + public int? Sequence + { + get => this.Fields[(int)SqlStringSymbolFields.Sequence].AsNullableNumber(); + set => this.Set((int)SqlStringSymbolFields.Sequence, value); + } + } +} \ No newline at end of file diff --git a/src/wixext/Symbols/SqlSymbolDefinitions.cs b/src/wixext/Symbols/SqlSymbolDefinitions.cs new file mode 100644 index 00000000..336f1546 --- /dev/null +++ b/src/wixext/Symbols/SqlSymbolDefinitions.cs @@ -0,0 +1,51 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using System; + using WixToolset.Data; + + public enum SqlSymbolDefinitionType + { + SqlDatabase, + SqlFileSpec, + SqlScript, + SqlString, + } + + public static partial class SqlSymbolDefinitions + { + public static readonly Version Version = new Version("4.0.0"); + + public static IntermediateSymbolDefinition ByName(string name) + { + if (!Enum.TryParse(name, out SqlSymbolDefinitionType type)) + { + return null; + } + + return ByType(type); + } + + public static IntermediateSymbolDefinition ByType(SqlSymbolDefinitionType type) + { + switch (type) + { + case SqlSymbolDefinitionType.SqlDatabase: + return SqlSymbolDefinitions.SqlDatabase; + + case SqlSymbolDefinitionType.SqlFileSpec: + return SqlSymbolDefinitions.SqlFileSpec; + + case SqlSymbolDefinitionType.SqlScript: + return SqlSymbolDefinitions.SqlScript; + + case SqlSymbolDefinitionType.SqlString: + return SqlSymbolDefinitions.SqlString; + + default: + throw new ArgumentOutOfRangeException(nameof(type)); + } + } + } +} diff --git a/src/wixext/Tuples/SqlDatabaseTuple.cs b/src/wixext/Tuples/SqlDatabaseTuple.cs deleted file mode 100644 index 6f0820ac..00000000 --- a/src/wixext/Tuples/SqlDatabaseTuple.cs +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Sql -{ - using WixToolset.Data; - using WixToolset.Sql.Symbols; - - public static partial class SqlSymbolDefinitions - { - public static readonly IntermediateSymbolDefinition SqlDatabase = new IntermediateSymbolDefinition( - SqlSymbolDefinitionType.SqlDatabase.ToString(), - new[] - { - new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Server), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Instance), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Database), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.ComponentRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.UserRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.FileSpecRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.LogFileSpecRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Attributes), IntermediateFieldType.Number), - }, - typeof(SqlDatabaseSymbol)); - } -} - -namespace WixToolset.Sql.Symbols -{ - using WixToolset.Data; - - public enum SqlDatabaseSymbolFields - { - Server, - Instance, - Database, - ComponentRef, - UserRef, - FileSpecRef, - LogFileSpecRef, - Attributes, - } - - public class SqlDatabaseSymbol : IntermediateSymbol - { - public SqlDatabaseSymbol() : base(SqlSymbolDefinitions.SqlDatabase, null, null) - { - } - - public SqlDatabaseSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlDatabase, sourceLineNumber, id) - { - } - - public IntermediateField this[SqlDatabaseSymbolFields index] => this.Fields[(int)index]; - - public string Server - { - get => this.Fields[(int)SqlDatabaseSymbolFields.Server].AsString(); - set => this.Set((int)SqlDatabaseSymbolFields.Server, value); - } - - public string Instance - { - get => this.Fields[(int)SqlDatabaseSymbolFields.Instance].AsString(); - set => this.Set((int)SqlDatabaseSymbolFields.Instance, value); - } - - public string Database - { - get => this.Fields[(int)SqlDatabaseSymbolFields.Database].AsString(); - set => this.Set((int)SqlDatabaseSymbolFields.Database, value); - } - - public string ComponentRef - { - get => this.Fields[(int)SqlDatabaseSymbolFields.ComponentRef].AsString(); - set => this.Set((int)SqlDatabaseSymbolFields.ComponentRef, value); - } - - public string UserRef - { - get => this.Fields[(int)SqlDatabaseSymbolFields.UserRef].AsString(); - set => this.Set((int)SqlDatabaseSymbolFields.UserRef, value); - } - - public string FileSpecRef - { - get => this.Fields[(int)SqlDatabaseSymbolFields.FileSpecRef].AsString(); - set => this.Set((int)SqlDatabaseSymbolFields.FileSpecRef, value); - } - - public string LogFileSpecRef - { - get => this.Fields[(int)SqlDatabaseSymbolFields.LogFileSpecRef].AsString(); - set => this.Set((int)SqlDatabaseSymbolFields.LogFileSpecRef, value); - } - - public int Attributes - { - get => this.Fields[(int)SqlDatabaseSymbolFields.Attributes].AsNumber(); - set => this.Set((int)SqlDatabaseSymbolFields.Attributes, value); - } - } -} \ No newline at end of file diff --git a/src/wixext/Tuples/SqlFileSpecTuple.cs b/src/wixext/Tuples/SqlFileSpecTuple.cs deleted file mode 100644 index d9eecc62..00000000 --- a/src/wixext/Tuples/SqlFileSpecTuple.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Sql -{ - using WixToolset.Data; - using WixToolset.Sql.Symbols; - - public static partial class SqlSymbolDefinitions - { - public static readonly IntermediateSymbolDefinition SqlFileSpec = new IntermediateSymbolDefinition( - SqlSymbolDefinitionType.SqlFileSpec.ToString(), - new[] - { - new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.Name), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.Filename), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.Size), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.MaxSize), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.GrowthSize), IntermediateFieldType.String), - }, - typeof(SqlFileSpecSymbol)); - } -} - -namespace WixToolset.Sql.Symbols -{ - using WixToolset.Data; - - public enum SqlFileSpecSymbolFields - { - Name, - Filename, - Size, - MaxSize, - GrowthSize, - } - - public class SqlFileSpecSymbol : IntermediateSymbol - { - public SqlFileSpecSymbol() : base(SqlSymbolDefinitions.SqlFileSpec, null, null) - { - } - - public SqlFileSpecSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlFileSpec, sourceLineNumber, id) - { - } - - public IntermediateField this[SqlFileSpecSymbolFields index] => this.Fields[(int)index]; - - public string Name - { - get => this.Fields[(int)SqlFileSpecSymbolFields.Name].AsString(); - set => this.Set((int)SqlFileSpecSymbolFields.Name, value); - } - - public string Filename - { - get => this.Fields[(int)SqlFileSpecSymbolFields.Filename].AsString(); - set => this.Set((int)SqlFileSpecSymbolFields.Filename, value); - } - - public string Size - { - get => this.Fields[(int)SqlFileSpecSymbolFields.Size].AsString(); - set => this.Set((int)SqlFileSpecSymbolFields.Size, value); - } - - public string MaxSize - { - get => this.Fields[(int)SqlFileSpecSymbolFields.MaxSize].AsString(); - set => this.Set((int)SqlFileSpecSymbolFields.MaxSize, value); - } - - public string GrowthSize - { - get => this.Fields[(int)SqlFileSpecSymbolFields.GrowthSize].AsString(); - set => this.Set((int)SqlFileSpecSymbolFields.GrowthSize, value); - } - } -} \ No newline at end of file diff --git a/src/wixext/Tuples/SqlScriptTuple.cs b/src/wixext/Tuples/SqlScriptTuple.cs deleted file mode 100644 index 94c70390..00000000 --- a/src/wixext/Tuples/SqlScriptTuple.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Sql -{ - using WixToolset.Data; - using WixToolset.Sql.Symbols; - - public static partial class SqlSymbolDefinitions - { - public static readonly IntermediateSymbolDefinition SqlScript = new IntermediateSymbolDefinition( - SqlSymbolDefinitionType.SqlScript.ToString(), - new[] - { - new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.SqlDbRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.ComponentRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.ScriptBinaryRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.UserRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.Attributes), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.Sequence), IntermediateFieldType.Number), - }, - typeof(SqlScriptSymbol)); - } -} - -namespace WixToolset.Sql.Symbols -{ - using WixToolset.Data; - - public enum SqlScriptSymbolFields - { - SqlDbRef, - ComponentRef, - ScriptBinaryRef, - UserRef, - Attributes, - Sequence, - } - - public class SqlScriptSymbol : IntermediateSymbol - { - public SqlScriptSymbol() : base(SqlSymbolDefinitions.SqlScript, null, null) - { - } - - public SqlScriptSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlScript, sourceLineNumber, id) - { - } - - public IntermediateField this[SqlScriptSymbolFields index] => this.Fields[(int)index]; - - public string SqlDbRef - { - get => this.Fields[(int)SqlScriptSymbolFields.SqlDbRef].AsString(); - set => this.Set((int)SqlScriptSymbolFields.SqlDbRef, value); - } - - public string ComponentRef - { - get => this.Fields[(int)SqlScriptSymbolFields.ComponentRef].AsString(); - set => this.Set((int)SqlScriptSymbolFields.ComponentRef, value); - } - - public string ScriptBinaryRef - { - get => this.Fields[(int)SqlScriptSymbolFields.ScriptBinaryRef].AsString(); - set => this.Set((int)SqlScriptSymbolFields.ScriptBinaryRef, value); - } - - public string UserRef - { - get => this.Fields[(int)SqlScriptSymbolFields.UserRef].AsString(); - set => this.Set((int)SqlScriptSymbolFields.UserRef, value); - } - - public int Attributes - { - get => this.Fields[(int)SqlScriptSymbolFields.Attributes].AsNumber(); - set => this.Set((int)SqlScriptSymbolFields.Attributes, value); - } - - public int? Sequence - { - get => this.Fields[(int)SqlScriptSymbolFields.Sequence].AsNullableNumber(); - set => this.Set((int)SqlScriptSymbolFields.Sequence, value); - } - } -} \ No newline at end of file diff --git a/src/wixext/Tuples/SqlStringTuple.cs b/src/wixext/Tuples/SqlStringTuple.cs deleted file mode 100644 index 73a8206e..00000000 --- a/src/wixext/Tuples/SqlStringTuple.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Sql -{ - using WixToolset.Data; - using WixToolset.Sql.Symbols; - - public static partial class SqlSymbolDefinitions - { - public static readonly IntermediateSymbolDefinition SqlString = new IntermediateSymbolDefinition( - SqlSymbolDefinitionType.SqlString.ToString(), - new[] - { - new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.SqlDbRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.ComponentRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.SQL), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.UserRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.Attributes), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.Sequence), IntermediateFieldType.Number), - }, - typeof(SqlStringSymbol)); - } -} - -namespace WixToolset.Sql.Symbols -{ - using WixToolset.Data; - - public enum SqlStringSymbolFields - { - SqlDbRef, - ComponentRef, - SQL, - UserRef, - Attributes, - Sequence, - } - - public class SqlStringSymbol : IntermediateSymbol - { - public SqlStringSymbol() : base(SqlSymbolDefinitions.SqlString, null, null) - { - } - - public SqlStringSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlString, sourceLineNumber, id) - { - } - - public IntermediateField this[SqlStringSymbolFields index] => this.Fields[(int)index]; - - public string SqlDbRef - { - get => this.Fields[(int)SqlStringSymbolFields.SqlDbRef].AsString(); - set => this.Set((int)SqlStringSymbolFields.SqlDbRef, value); - } - - public string ComponentRef - { - get => this.Fields[(int)SqlStringSymbolFields.ComponentRef].AsString(); - set => this.Set((int)SqlStringSymbolFields.ComponentRef, value); - } - - public string SQL - { - get => this.Fields[(int)SqlStringSymbolFields.SQL].AsString(); - set => this.Set((int)SqlStringSymbolFields.SQL, value); - } - - public string UserRef - { - get => this.Fields[(int)SqlStringSymbolFields.UserRef].AsString(); - set => this.Set((int)SqlStringSymbolFields.UserRef, value); - } - - public int Attributes - { - get => this.Fields[(int)SqlStringSymbolFields.Attributes].AsNumber(); - set => this.Set((int)SqlStringSymbolFields.Attributes, value); - } - - public int? Sequence - { - get => this.Fields[(int)SqlStringSymbolFields.Sequence].AsNullableNumber(); - set => this.Set((int)SqlStringSymbolFields.Sequence, value); - } - } -} \ No newline at end of file diff --git a/src/wixext/Tuples/SqlTupleDefinitions.cs b/src/wixext/Tuples/SqlTupleDefinitions.cs deleted file mode 100644 index 336f1546..00000000 --- a/src/wixext/Tuples/SqlTupleDefinitions.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Sql -{ - using System; - using WixToolset.Data; - - public enum SqlSymbolDefinitionType - { - SqlDatabase, - SqlFileSpec, - SqlScript, - SqlString, - } - - public static partial class SqlSymbolDefinitions - { - public static readonly Version Version = new Version("4.0.0"); - - public static IntermediateSymbolDefinition ByName(string name) - { - if (!Enum.TryParse(name, out SqlSymbolDefinitionType type)) - { - return null; - } - - return ByType(type); - } - - public static IntermediateSymbolDefinition ByType(SqlSymbolDefinitionType type) - { - switch (type) - { - case SqlSymbolDefinitionType.SqlDatabase: - return SqlSymbolDefinitions.SqlDatabase; - - case SqlSymbolDefinitionType.SqlFileSpec: - return SqlSymbolDefinitions.SqlFileSpec; - - case SqlSymbolDefinitionType.SqlScript: - return SqlSymbolDefinitions.SqlScript; - - case SqlSymbolDefinitionType.SqlString: - return SqlSymbolDefinitions.SqlString; - - default: - throw new ArgumentOutOfRangeException(nameof(type)); - } - } - } -} -- cgit v1.2.3-55-g6feb From 2a0da3642381d8e52e841b72d049049009f84a71 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 27 Jun 2020 15:02:35 -0700 Subject: Build wixlib with WixToolset.Sdk --- global.json | 5 +++++ src/FindLocalWix.props | 8 -------- src/wixlib/packages.config | 5 ----- src/wixlib/sql.wixproj | 44 ++++++++------------------------------------ 4 files changed, 13 insertions(+), 49 deletions(-) create mode 100644 global.json delete mode 100644 src/FindLocalWix.props delete mode 100644 src/wixlib/packages.config (limited to 'src') diff --git a/global.json b/global.json new file mode 100644 index 00000000..7a995d0a --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "msbuild-sdks": { + "WixToolset.Sdk": "4.0.0-build-0143" + } +} diff --git a/src/FindLocalWix.props b/src/FindLocalWix.props deleted file mode 100644 index 1666e4fe..00000000 --- a/src/FindLocalWix.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - $(MSBuildThisFileDirectory)..\..\Tools\build\Debug\net461\wix.targets - - diff --git a/src/wixlib/packages.config b/src/wixlib/packages.config deleted file mode 100644 index 1e5a9850..00000000 --- a/src/wixlib/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/wixlib/sql.wixproj b/src/wixlib/sql.wixproj index e4efb34e..b4a37d6c 100644 --- a/src/wixlib/sql.wixproj +++ b/src/wixlib/sql.wixproj @@ -1,46 +1,18 @@ - - - - + + - {9ACF1A20-D801-45CC-A463-F9D13E506AA3} - sql Library true - true en-us + - - - - - - - - + + - + - - - sqlca - {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935} - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - \ No newline at end of file + + -- cgit v1.2.3-55-g6feb From 4d9c4bc0c4ac264bd90a3d85c27c109619a82874 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 27 Jun 2020 15:02:47 -0700 Subject: Update to latest dutil and wcautil --- src/ca/packages.config | 4 ++-- src/ca/sqlca.vcxproj | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ca/packages.config b/src/ca/packages.config index 4e9403bf..e3dc0e43 100644 --- a/src/ca/packages.config +++ b/src/ca/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/src/ca/sqlca.vcxproj b/src/ca/sqlca.vcxproj index 1c176d80..3c8c1a6c 100644 --- a/src/ca/sqlca.vcxproj +++ b/src/ca/sqlca.vcxproj @@ -2,8 +2,8 @@ - - + + @@ -66,7 +66,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + -- cgit v1.2.3-55-g6feb From c134594328bd63fb19b88239694523f04108030e Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Mon, 6 Jul 2020 12:34:48 -0400 Subject: Add per-platform custom action support. --- Sql.wixext.sln | 5 +++-- src/ca/caDecor.h | 13 +++++++++++++ src/ca/precomp.h | 2 ++ src/ca/scadb.cpp | 6 +++--- src/ca/scasqlstr.cpp | 4 ++-- src/ca/sqlca.vcxproj | 26 ++++++++++++++++++++++++- src/wixext/SqlCompiler.cs | 5 +++-- src/wixlib/SqlExtension.wxi | 36 +++++++++++++++++++++++++++++++++++ src/wixlib/SqlExtension.wxs | 29 ---------------------------- src/wixlib/SqlExtension_arm.wxs | 8 ++++++++ src/wixlib/SqlExtension_arm64.wxs | 8 ++++++++ src/wixlib/SqlExtension_x64.wxs | 8 ++++++++ src/wixlib/SqlExtension_x86.wxs | 8 ++++++++ src/wixlib/caDecor.wxi | 40 +++++++++++++++++++++++++++++++++++++++ src/wixlib/sql.wixproj | 13 +++++++------ 15 files changed, 166 insertions(+), 45 deletions(-) create mode 100644 src/ca/caDecor.h create mode 100644 src/wixlib/SqlExtension.wxi create mode 100644 src/wixlib/SqlExtension_arm.wxs create mode 100644 src/wixlib/SqlExtension_arm64.wxs create mode 100644 src/wixlib/SqlExtension_x64.wxs create mode 100644 src/wixlib/SqlExtension_x86.wxs create mode 100644 src/wixlib/caDecor.wxi (limited to 'src') diff --git a/Sql.wixext.sln b/Sql.wixext.sln index f033987f..cfa9ad4f 100644 --- a/Sql.wixext.sln +++ b/Sql.wixext.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28010.2016 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30204.135 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlca", "src\ca\sqlca.vcxproj", "{4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}" EndProject @@ -20,6 +20,7 @@ Global EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Debug|Any CPU.Build.0 = Debug|Win32 {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Debug|x86.ActiveCfg = Debug|Win32 {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Debug|x86.Build.0 = Debug|Win32 {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Release|Any CPU.ActiveCfg = Release|Win32 diff --git a/src/ca/caDecor.h b/src/ca/caDecor.h new file mode 100644 index 00000000..da274650 --- /dev/null +++ b/src/ca/caDecor.h @@ -0,0 +1,13 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +#if defined(_M_ARM64) +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_A64" +#elif defined(_M_AMD64) +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_X64" +#elif defined(_M_ARM) +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_ARM" +#else +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_X86" +#endif diff --git a/src/ca/precomp.h b/src/ca/precomp.h index 08454d3a..266d543c 100644 --- a/src/ca/precomp.h +++ b/src/ca/precomp.h @@ -24,3 +24,5 @@ #include "sca.h" #include "scacost.h" #include "scasqlstr.h" + +#include "caDecor.h" diff --git a/src/ca/scadb.cpp b/src/ca/scadb.cpp index 9f9efca2..68f7b10b 100644 --- a/src/ca/scadb.cpp +++ b/src/ca/scadb.cpp @@ -385,7 +385,7 @@ static HRESULT SchedCreateDatabase( hr = SqlDatabaseExists(psd->wzServer, psd->wzInstance, psd->wzDatabase, psd->fUseIntegratedAuth, psd->scau.wzName, psd->scau.wzPassword, NULL); if (S_FALSE == hr) { - hr = WcaDoDeferredAction(L"RollbackCreateDatabase", pwzCustomActionData, COST_SQL_CREATEDB); + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"RollbackCreateDatabase"), pwzCustomActionData, COST_SQL_CREATEDB); ExitOnFailure(hr, "Failed to schedule RollbackCreateDatabase action"); } @@ -444,7 +444,7 @@ static HRESULT SchedCreateDatabase( } // schedule the CreateDatabase action - hr = WcaDoDeferredAction(L"CreateDatabase", pwzCustomActionData, COST_SQL_CREATEDB); + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"CreateDatabase"), pwzCustomActionData, COST_SQL_CREATEDB); ExitOnFailure(hr, "Failed to schedule CreateDatabase action"); LExit: @@ -491,7 +491,7 @@ HRESULT SchedDropDatabase( hr = WcaWriteStringToCaData(wzPassword, &pwzCustomActionData); ExitOnFailure(hr, "Failed to add user password to CustomActionData"); - hr = WcaDoDeferredAction(L"DropDatabase", pwzCustomActionData, COST_SQL_DROPDB); + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"DropDatabase"), pwzCustomActionData, COST_SQL_DROPDB); ExitOnFailure(hr, "Failed to schedule DropDatabase action"); LExit: diff --git a/src/ca/scasqlstr.cpp b/src/ca/scasqlstr.cpp index 3108e307..6ac526a6 100644 --- a/src/ca/scasqlstr.cpp +++ b/src/ca/scasqlstr.cpp @@ -654,7 +654,7 @@ static HRESULT ExecuteStrings( { Assert(pwzCustomActionData && *pwzCustomActionData && uiCost); - hr = WcaDoDeferredAction(1 == iOldRollback ? L"RollbackExecuteSqlStrings" : L"ExecuteSqlStrings", pwzCustomActionData, uiCost); + hr = WcaDoDeferredAction(1 == iOldRollback ? CUSTOM_ACTION_DECORATION(L"RollbackExecuteSqlStrings") : CUSTOM_ACTION_DECORATION(L"ExecuteSqlStrings"), pwzCustomActionData, uiCost); ExitOnFailure(hr, "failed to schedule ExecuteSqlStrings action, rollback: %d", iOldRollback); iOldRollback = iRollback; @@ -714,7 +714,7 @@ static HRESULT ExecuteStrings( if (pwzCustomActionData && *pwzCustomActionData) { Assert(pwzCustomActionData && *pwzCustomActionData && uiCost); - hr = WcaDoDeferredAction(1 == iRollback ? L"RollbackExecuteSqlStrings" : L"ExecuteSqlStrings", pwzCustomActionData, uiCost); + hr = WcaDoDeferredAction(1 == iRollback ? CUSTOM_ACTION_DECORATION(L"RollbackExecuteSqlStrings") : CUSTOM_ACTION_DECORATION(L"ExecuteSqlStrings"), pwzCustomActionData, uiCost); ExitOnFailure(hr, "Failed to schedule ExecuteSqlStrings action"); *pwzCustomActionData = L'\0'; diff --git a/src/ca/sqlca.vcxproj b/src/ca/sqlca.vcxproj index 3c8c1a6c..e1c5beea 100644 --- a/src/ca/sqlca.vcxproj +++ b/src/ca/sqlca.vcxproj @@ -14,13 +14,37 @@ Release Win32 + + Debug + x64 + + + Release + x64 + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935} DynamicLibrary sqlca - v141 + v142 Unicode sqlca.def WiX Toolset Sql CustomAction diff --git a/src/wixext/SqlCompiler.cs b/src/wixext/SqlCompiler.cs index 2c0f914a..bbcdc87d 100644 --- a/src/wixext/SqlCompiler.cs +++ b/src/wixext/SqlCompiler.cs @@ -7,6 +7,7 @@ namespace WixToolset.Sql using System.Xml.Linq; using WixToolset.Data; using WixToolset.Extensibility; + using WixToolset.Extensibility.Data; using WixToolset.Sql.Symbols; /// @@ -797,8 +798,8 @@ namespace WixToolset.Sql private void AddReferenceToInstallSqlData(IntermediateSection section, SourceLineNumber sourceLineNumbers) { - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, "InstallSqlData"); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, "UninstallSqlData"); + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "InstallSqlData", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM | CustomActionPlatforms.ARM64); + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "UninstallSqlData", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM | CustomActionPlatforms.ARM64); } } } diff --git a/src/wixlib/SqlExtension.wxi b/src/wixlib/SqlExtension.wxi new file mode 100644 index 00000000..43b91fba --- /dev/null +++ b/src/wixlib/SqlExtension.wxi @@ -0,0 +1,36 @@ + + + + + + + + + !(loc.ConfigureSql) + !(loc.ConfigureSql) + !(loc.CreateDatabase) + !(loc.DropDatabase) + !(loc.ExecuteSqlStrings) + !(loc.RollbackExecuteSqlStrings) + + + + + + + + + + + + + NOT SKIPUNINSTALLSQLDATA AND VersionNT > 400 + NOT SKIPINSTALLSQLDATA AND VersionNT > 400 + + + + + + + + diff --git a/src/wixlib/SqlExtension.wxs b/src/wixlib/SqlExtension.wxs index 6e08b7fa..00a6edcb 100644 --- a/src/wixlib/SqlExtension.wxs +++ b/src/wixlib/SqlExtension.wxs @@ -1,12 +1,9 @@ - - - !(loc.msierrSQLFailedCreateDatabase) @@ -14,32 +11,6 @@ !(loc.msierrSQLFailedConnectDatabase) !(loc.msierrSQLFailedExecString) !(loc.msierrSQLDatabaseAlreadyExists) - - !(loc.ConfigureSql) - !(loc.ConfigureSql) - !(loc.CreateDatabase) - !(loc.DropDatabase) - !(loc.ExecuteSqlStrings) - !(loc.RollbackExecuteSqlStrings) - - - - - - - - - - - - NOT SKIPUNINSTALLSQLDATA AND VersionNT > 400 - NOT SKIPINSTALLSQLDATA AND VersionNT > 400 - - - - - - diff --git a/src/wixlib/SqlExtension_arm.wxs b/src/wixlib/SqlExtension_arm.wxs new file mode 100644 index 00000000..b5f903f6 --- /dev/null +++ b/src/wixlib/SqlExtension_arm.wxs @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/wixlib/SqlExtension_arm64.wxs b/src/wixlib/SqlExtension_arm64.wxs new file mode 100644 index 00000000..08394685 --- /dev/null +++ b/src/wixlib/SqlExtension_arm64.wxs @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/wixlib/SqlExtension_x64.wxs b/src/wixlib/SqlExtension_x64.wxs new file mode 100644 index 00000000..d7ba8e46 --- /dev/null +++ b/src/wixlib/SqlExtension_x64.wxs @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/wixlib/SqlExtension_x86.wxs b/src/wixlib/SqlExtension_x86.wxs new file mode 100644 index 00000000..70aae67c --- /dev/null +++ b/src/wixlib/SqlExtension_x86.wxs @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/wixlib/caDecor.wxi b/src/wixlib/caDecor.wxi new file mode 100644 index 00000000..1d00df8f --- /dev/null +++ b/src/wixlib/caDecor.wxi @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/wixlib/sql.wixproj b/src/wixlib/sql.wixproj index b4a37d6c..96673563 100644 --- a/src/wixlib/sql.wixproj +++ b/src/wixlib/sql.wixproj @@ -1,18 +1,19 @@ - Library true en-us - + - + + + + - + - - + \ No newline at end of file -- cgit v1.2.3-55-g6feb From ebf83fdc9814dfdfc74f4e215f749a4366421677 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Wed, 2 Sep 2020 13:40:46 -0400 Subject: Fix Condition authoring. --- src/wixlib/SqlExtension.wxi | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/wixlib/SqlExtension.wxi b/src/wixlib/SqlExtension.wxi index 43b91fba..9d7d2495 100644 --- a/src/wixlib/SqlExtension.wxi +++ b/src/wixlib/SqlExtension.wxi @@ -1,17 +1,16 @@ - - + - !(loc.ConfigureSql) - !(loc.ConfigureSql) - !(loc.CreateDatabase) - !(loc.DropDatabase) - !(loc.ExecuteSqlStrings) - !(loc.RollbackExecuteSqlStrings) + + + + + + @@ -24,8 +23,8 @@ - NOT SKIPUNINSTALLSQLDATA AND VersionNT > 400 - NOT SKIPINSTALLSQLDATA AND VersionNT > 400 + + -- cgit v1.2.3-55-g6feb From 0016b37f80e0d1d1fa5c2ab803042456eafbb9e8 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sun, 6 Sep 2020 21:23:24 -0400 Subject: Replace BinaryKey with BinaryRef and FileKey with FileRef. --- src/wixext/SqlCompiler.cs | 16 +- src/wixext/WixToolset.Sql.wixext.csproj | 1 - src/wixext/sql.xsd | 342 -------------------------------- 3 files changed, 8 insertions(+), 351 deletions(-) delete mode 100644 src/wixext/sql.xsd (limited to 'src') diff --git a/src/wixext/SqlCompiler.cs b/src/wixext/SqlCompiler.cs index bbcdc87d..534fcc27 100644 --- a/src/wixext/SqlCompiler.cs +++ b/src/wixext/SqlCompiler.cs @@ -447,7 +447,7 @@ namespace WixToolset.Sql int attributes = 0; var rollbackAttribute = false; var nonRollbackAttribute = false; - string binary = null; + string binaryRef = null; var sequence = CompilerConstants.IntegerNotSet; string user = null; @@ -460,9 +460,9 @@ namespace WixToolset.Sql case "Id": id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); break; - case "BinaryKey": - binary = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.Binary, binary); + case "BinaryRef": + binaryRef = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.Binary, binaryRef); break; case "Sequence": sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); @@ -575,12 +575,12 @@ namespace WixToolset.Sql if (null == id) { - id = this.ParseHelper.CreateIdentifier("ssc", componentId, binary, sqlDb); + id = this.ParseHelper.CreateIdentifier("ssc", componentId, binaryRef, sqlDb); } - if (null == binary) + if (null == binaryRef) { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "BinaryKey")); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "BinaryRef")); } if (null == sqlDb) @@ -604,7 +604,7 @@ namespace WixToolset.Sql { SqlDbRef = sqlDb, ComponentRef = componentId, - ScriptBinaryRef = binary, + ScriptBinaryRef = binaryRef, UserRef = user, Attributes = attributes, }); diff --git a/src/wixext/WixToolset.Sql.wixext.csproj b/src/wixext/WixToolset.Sql.wixext.csproj index 73c7a4e5..01ab5504 100644 --- a/src/wixext/WixToolset.Sql.wixext.csproj +++ b/src/wixext/WixToolset.Sql.wixext.csproj @@ -13,7 +13,6 @@ - diff --git a/src/wixext/sql.xsd b/src/wixext/sql.xsd deleted file mode 100644 index 161607c9..00000000 --- a/src/wixext/sql.xsd +++ /dev/null @@ -1,342 +0,0 @@ - - - - - - - - The source code schema for the WiX Toolset SQL Server Extension. - - - - - - - - - - - - - - - Nesting SqlDatabase under a Component element will result in a SqlDatabase being installed to the machine as the package is installed. - - Nesting SqlDatabase under Product, Fragment, or Module - results in a database "locator" record being created in - the SqlDatabase table. This means that the database - itself is neither installed nor uninstalled by the MSI - package. It does make the database available for referencing - from a SqlString or SqlScript record. This allows MSI to install - SqlScripts or SqlStrings to already existing databases on the machine. - The install will fail if the database does not exist in these cases. - - - The User attribute references credentials specified in a User element. - If a user is not specified then Windows Authentication will be used by default - using the credentials of the user performing the install to execute sql - strings, etc. - - - - - - SQL Database - - - - - - - - - - - - - - - - - - - The name of the database. The value can be a literal value or derived from a - Property element using the Formatted - syntax. - - - - - - - - - - - Specifies whether to create the database when the associated component is reinstalled. Setting CreateOnInstall to yes does not imply CreateOnReinstall is set to yes. CreateOnReinstall must be set in addition to CreateOnInstall for it to be created during both install and reinstall. - - - - - - - - - - - Specifies whether to drop the database when the associated component is reinstalled. Setting DropOnInstall to yes does not imply DropOnReinstall is set to yes. DropOnReinstall must be set in addition to DropOnInstall for it to be dropped during both install and reinstall. - - - - - - - - - - - - - - - File specification for a Sql database. - - - - - ID of the file specification. - - - - - Specifies the logical name for the database file. - - - - - Specifies the operating-system file name for the database file. - - - - - - Specifies the size of the database file. The GB, MB and KB suffixes can be used to specify gigabytes, - megabytes or kilobytes. The default is megabytes if no suffix is specified. When a Size is not - supplied for a database file, SQL Server uses the size of the primary file in the model database. - - - - - - - Specifies the maximum size to which the database file can grow. The GB, MB and KB suffixes can be used to - to specify gigabytes, megabytes or kilobytes. The default is megabytes if no suffix is specified. If - MaxSize is not specified, the file will grow until the disk is full. - - - - - - - Specifies the growth increment of the database file. The GB, MB and KB and % suffixes can be used to - specify gigabytes, megabytes, kilobytes or a percentage of the current file size to grow. The default is - megabytes if no suffix is specified. The default value is 10% if GrowthSize is not specified, and the - minimum value is 64 KB. The GrowthSize setting for a file cannot exceed the MaxSize setting. - - - - - - - - - File specification for a Sql database. - - - - - ID of the log file specification. - - - - - Specifies the logical name for the log file. - - - - - Specifies the operating-system file name for the log file. - - - - - - Specifies the size of the log file. The GB, MB and KB suffixes can be used to specify gigabytes, - megabytes or kilobytes. The default is megabytes if no suffix is specified. When a Size is not - supplied for a log file, SQL Server makes the file 1 MB. - - - - - - - Specifies the maximum size to which the log file can grow. The GB, MB and KB suffixes can be used to - to specify gigabytes, megabytes or kilobytes. The default is megabytes if no suffix is specified. If - MaxSize is not specified, the file will grow until the disk is full. - - - - - - - Specifies the growth increment of the log file. The GB, MB and KB and % suffixes can be used to - specify gigabytes, megabytes, kilobytes or a percentage of the current file size to grow. The default is - megabytes if no suffix is specified. The default value is 10% if GrowthSize is not specified, and the - minimum value is 64 KB. The GrowthSize setting for a file cannot exceed the MaxSize setting. - - - - - - - - - - - - SQL Script - - - - - - required when not child of SqlDatabase - - - - - - - Reference to Binary stream that contains the SQL script to execute. - - - - - Specifies to execute the script when the associated component is installed. This attribute is mutually exclusive with the RollbackOnInstall, RollbackOnReinstall and RollbackOnUninstall attributes. - - - - - Specifies whether to execute the script when the associated component is reinstalled. Setting ExecuteOnInstall to yes does not imply ExecuteOnReinstall is set to yes. ExecuteOnReinstall must be set in addition to ExecuteOnInstall for it to be executed during both install and reinstall. This attribute is mutually exclusive with the RollbackOnInstall, RollbackOnReinstall and RollbackOnUninstall attributes. - - - - - Specifies to execute the script when the associated component is uninstalled. This attribute is mutually exclusive with the RollbackOnInstall, RollbackOnReinstall and RollbackOnUninstall attributes. - - - - - Specifies whether to execute the script on rollback if an attempt is made to install the associated component. This attribute is mutually exclusive with the ExecuteOnInstall, ExecuteOnReinstall and ExecuteOnUninstall attributes. - - - - - Specifies whether to execute the script on rollback if an attempt is made to reinstall the associated component. This attribute is mutually exclusive with the ExecuteOnInstall, ExecuteOnReinstall and ExecuteOnUninstall attributes. - - - - - Specifies whether to execute the script on rollback if an attempt is made to uninstall the associated component. This attribute is mutually exclusive with the ExecuteOnInstall, ExecuteOnReinstall and ExecuteOnUninstall attributes. - - - - - Continue executing scripts even if this one fails. - - - - - Specifes the order to run the SQL Scripts. It is recommended that rollback scripts be scheduled before their complementary execution script. This order is also relative across the SqlString element. - - - - - - - - - - - SQL String - - - - - - - - - - - - - Specifies to execute the string when the associated component is installed. This attribute is mutually exclusive with the RollbackOnInstall, RollbackOnReinstall and RollbackOnUninstall attributes. - - - - - - Specifies whether to execute the string when the associated component is reinstalled. Setting ExecuteOnInstall to yes does not imply ExecuteOnReinstall is set to yes. ExecuteOnReinstall must be set in addition to ExecuteOnInstall for it to be executed during both install and reinstall. This attribute is mutually exclusive with the RollbackOnInstall, RollbackOnReinstall and RollbackOnUninstall attributes. - - - - - - Specifies to execute the string when the associated component is uninstalled. This attribute is mutually exclusive with the RollbackOnInstall, RollbackOnReinstall and RollbackOnUninstall attributes. - - - - - Specifies whether to execute the string on rollback if an attempt is made to install the associated component. This attribute is mutually exclusive with the ExecuteOnInstall, ExecuteOnReinstall and ExecuteOnUninstall attributes. - - - - - Specifies whether to execute the string on rollback if an attempt is made to reinstall the associated component. This attribute is mutually exclusive with the ExecuteOnInstall, ExecuteOnReinstall and ExecuteOnUninstall attributes. - - - - - Specifies whether to execute the string on rollback if an attempt is made to uninstall the associated component. This attribute is mutually exclusive with the ExecuteOnInstall, ExecuteOnReinstall and ExecuteOnUninstall attributes. - - - - - Continue executing strings even if this one fails. - - - - - Specifes the order to run the SQL Strings. It is recommended that rollback strings be scheduled before their complementary execution string. This order is also relative across the SqlScript element. - - - - - - - - Values of this type will either be "yes" or "no". - - - - - - - - -- cgit v1.2.3-55-g6feb From d70e9e5ab5866c8e35b696fd169c9b62c6f5ee74 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sun, 20 Sep 2020 17:09:52 -0400 Subject: Remove 32-bit ARM support. --- global.json | 2 +- src/ca/sqlca.vcxproj | 8 -------- src/wixext/SqlCompiler.cs | 4 ++-- src/wixlib/SqlExtension.wxi | 14 +++++++------- src/wixlib/SqlExtension.wxs | 13 ++++++------- src/wixlib/SqlExtension_arm.wxs | 8 -------- src/wixlib/SqlExtension_arm64.wxs | 3 +-- src/wixlib/SqlExtension_x64.wxs | 3 +-- src/wixlib/SqlExtension_x86.wxs | 3 +-- src/wixlib/caDecor.wxi | 21 ++++++++++----------- src/wixlib/caerr.wxi | 2 +- src/wixlib/de-de.wxl | 3 +-- src/wixlib/en-us.wxl | 3 +-- src/wixlib/es-es.wxl | 3 +-- src/wixlib/ja-jp.wxl | 3 +-- src/wixlib/pl-pl.wxl | 3 +-- src/wixlib/pt-br.wxl | 3 +-- src/wixlib/pt-pt.wxl | 3 +-- src/wixlib/sql.wixproj | 7 ++++++- 19 files changed, 43 insertions(+), 66 deletions(-) delete mode 100644 src/wixlib/SqlExtension_arm.wxs (limited to 'src') diff --git a/global.json b/global.json index 7a995d0a..4d9df50b 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "msbuild-sdks": { - "WixToolset.Sdk": "4.0.0-build-0143" + "WixToolset.Sdk": "4.0.0-build-0157" } } diff --git a/src/ca/sqlca.vcxproj b/src/ca/sqlca.vcxproj index e1c5beea..112ad18b 100644 --- a/src/ca/sqlca.vcxproj +++ b/src/ca/sqlca.vcxproj @@ -22,14 +22,6 @@ Release x64 - - Debug - ARM - - - Release - ARM - Debug ARM64 diff --git a/src/wixext/SqlCompiler.cs b/src/wixext/SqlCompiler.cs index 534fcc27..162306b8 100644 --- a/src/wixext/SqlCompiler.cs +++ b/src/wixext/SqlCompiler.cs @@ -798,8 +798,8 @@ namespace WixToolset.Sql private void AddReferenceToInstallSqlData(IntermediateSection section, SourceLineNumber sourceLineNumbers) { - this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "InstallSqlData", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM | CustomActionPlatforms.ARM64); - this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "UninstallSqlData", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM | CustomActionPlatforms.ARM64); + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "InstallSqlData", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "UninstallSqlData", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); } } } diff --git a/src/wixlib/SqlExtension.wxi b/src/wixlib/SqlExtension.wxi index 9d7d2495..c9261f1d 100644 --- a/src/wixlib/SqlExtension.wxi +++ b/src/wixlib/SqlExtension.wxi @@ -14,13 +14,13 @@ - - - - - - - + + + + + + + diff --git a/src/wixlib/SqlExtension.wxs b/src/wixlib/SqlExtension.wxs index 00a6edcb..8b5320fa 100644 --- a/src/wixlib/SqlExtension.wxs +++ b/src/wixlib/SqlExtension.wxs @@ -1,16 +1,15 @@ - - + - !(loc.msierrSQLFailedCreateDatabase) - !(loc.msierrSQLFailedDropDatabase) - !(loc.msierrSQLFailedConnectDatabase) - !(loc.msierrSQLFailedExecString) - !(loc.msierrSQLDatabaseAlreadyExists) + + + + + diff --git a/src/wixlib/SqlExtension_arm.wxs b/src/wixlib/SqlExtension_arm.wxs deleted file mode 100644 index b5f903f6..00000000 --- a/src/wixlib/SqlExtension_arm.wxs +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/wixlib/SqlExtension_arm64.wxs b/src/wixlib/SqlExtension_arm64.wxs index 08394685..e8d22f69 100644 --- a/src/wixlib/SqlExtension_arm64.wxs +++ b/src/wixlib/SqlExtension_arm64.wxs @@ -1,5 +1,4 @@ - - + diff --git a/src/wixlib/SqlExtension_x64.wxs b/src/wixlib/SqlExtension_x64.wxs index d7ba8e46..e55a14e4 100644 --- a/src/wixlib/SqlExtension_x64.wxs +++ b/src/wixlib/SqlExtension_x64.wxs @@ -1,5 +1,4 @@ - - + diff --git a/src/wixlib/SqlExtension_x86.wxs b/src/wixlib/SqlExtension_x86.wxs index 70aae67c..1a51ed91 100644 --- a/src/wixlib/SqlExtension_x86.wxs +++ b/src/wixlib/SqlExtension_x86.wxs @@ -1,5 +1,4 @@ - - + diff --git a/src/wixlib/caDecor.wxi b/src/wixlib/caDecor.wxi index 1d00df8f..b1711518 100644 --- a/src/wixlib/caDecor.wxi +++ b/src/wixlib/caDecor.wxi @@ -1,40 +1,39 @@ - - + - + - + - + - + - + - + - + - + - + diff --git a/src/wixlib/caerr.wxi b/src/wixlib/caerr.wxi index 141942f2..ff7ec121 100644 --- a/src/wixlib/caerr.wxi +++ b/src/wixlib/caerr.wxi @@ -1,4 +1,4 @@ - + diff --git a/src/wixlib/de-de.wxl b/src/wixlib/de-de.wxl index 39a73e8c..ed2313a4 100644 --- a/src/wixlib/de-de.wxl +++ b/src/wixlib/de-de.wxl @@ -1,5 +1,4 @@ - - + diff --git a/src/wixlib/en-us.wxl b/src/wixlib/en-us.wxl index d89b1c6c..d3ffd5eb 100644 --- a/src/wixlib/en-us.wxl +++ b/src/wixlib/en-us.wxl @@ -1,5 +1,4 @@ - - + diff --git a/src/wixlib/es-es.wxl b/src/wixlib/es-es.wxl index bc5d0582..b2e5d499 100644 --- a/src/wixlib/es-es.wxl +++ b/src/wixlib/es-es.wxl @@ -1,5 +1,4 @@ - - + diff --git a/src/wixlib/ja-jp.wxl b/src/wixlib/ja-jp.wxl index 23c9aebe..6e35fd17 100644 --- a/src/wixlib/ja-jp.wxl +++ b/src/wixlib/ja-jp.wxl @@ -1,5 +1,4 @@ - - + diff --git a/src/wixlib/pl-pl.wxl b/src/wixlib/pl-pl.wxl index 4f0c7f75..6200e0e9 100644 --- a/src/wixlib/pl-pl.wxl +++ b/src/wixlib/pl-pl.wxl @@ -1,5 +1,4 @@ - - + diff --git a/src/wixlib/pt-br.wxl b/src/wixlib/pt-br.wxl index 63bbc21e..74c53313 100644 --- a/src/wixlib/pt-br.wxl +++ b/src/wixlib/pt-br.wxl @@ -1,5 +1,4 @@ - - + diff --git a/src/wixlib/pt-pt.wxl b/src/wixlib/pt-pt.wxl index 28c43878..90d9df4f 100644 --- a/src/wixlib/pt-pt.wxl +++ b/src/wixlib/pt-pt.wxl @@ -1,5 +1,4 @@ - - + diff --git a/src/wixlib/sql.wixproj b/src/wixlib/sql.wixproj index 96673563..7462f684 100644 --- a/src/wixlib/sql.wixproj +++ b/src/wixlib/sql.wixproj @@ -7,7 +7,12 @@ - + + + + + + -- cgit v1.2.3-55-g6feb From 9fc7ed95c8fd9337c10bb44dc42786b9fe0121a2 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Tue, 27 Oct 2020 16:13:06 -0400 Subject: Update project for Package/SummaryInformation change (and others). --- global.json | 2 +- src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs | 11 +++++------ src/wixext/SqlCompiler.cs | 3 +-- 3 files changed, 7 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/global.json b/global.json index 4d9df50b..f94ab6df 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "msbuild-sdks": { - "WixToolset.Sdk": "4.0.0-build-0157" + "WixToolset.Sdk": "4.0.0-build-0162" } } diff --git a/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs b/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs index 68ff98fd..44820bdd 100644 --- a/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs +++ b/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs @@ -1,16 +1,15 @@ - - - - + + + - + - + diff --git a/src/wixext/SqlCompiler.cs b/src/wixext/SqlCompiler.cs index 162306b8..4618eaba 100644 --- a/src/wixext/SqlCompiler.cs +++ b/src/wixext/SqlCompiler.cs @@ -48,7 +48,6 @@ namespace WixToolset.Sql { case "Component": var componentId = context["ComponentId"]; - var directoryId = context["DirectoryId"]; switch (element.Name.LocalName) { @@ -68,7 +67,7 @@ namespace WixToolset.Sql break; case "Fragment": case "Module": - case "Product": + case "Package": switch (element.Name.LocalName) { case "SqlDatabase": -- cgit v1.2.3-55-g6feb From 466c8aec96987f9c43b577204c12b5157527a405 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sat, 31 Oct 2020 21:56:05 -0400 Subject: Strong-name sign WiX assemblies. --- global.json | 2 +- src/CSharp.Build.props | 11 +++++++++++ src/Directory.Build.props | 1 + src/wix.snk | Bin 0 -> 596 bytes 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/CSharp.Build.props create mode 100644 src/wix.snk (limited to 'src') diff --git a/global.json b/global.json index f94ab6df..10345833 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "msbuild-sdks": { - "WixToolset.Sdk": "4.0.0-build-0162" + "WixToolset.Sdk": "4.0.0-build-0163" } } diff --git a/src/CSharp.Build.props b/src/CSharp.Build.props new file mode 100644 index 00000000..b12f4c6e --- /dev/null +++ b/src/CSharp.Build.props @@ -0,0 +1,11 @@ + + + + + true + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index a22f4470..f83cc154 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -22,6 +22,7 @@ WiX Toolset + diff --git a/src/wix.snk b/src/wix.snk new file mode 100644 index 00000000..3908a66a Binary files /dev/null and b/src/wix.snk differ -- cgit v1.2.3-55-g6feb From 85e8091e50d85f19515be70e85aff70e86b1906c Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Tue, 23 Feb 2021 19:03:35 -0500 Subject: Add custom action prefixes. --- global.json | 2 +- src/wixext/SqlCompiler.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/global.json b/global.json index 10345833..32e88652 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "msbuild-sdks": { - "WixToolset.Sdk": "4.0.0-build-0163" + "WixToolset.Sdk": "4.0.0-build-0190" } } diff --git a/src/wixext/SqlCompiler.cs b/src/wixext/SqlCompiler.cs index 4618eaba..46196e95 100644 --- a/src/wixext/SqlCompiler.cs +++ b/src/wixext/SqlCompiler.cs @@ -797,8 +797,8 @@ namespace WixToolset.Sql private void AddReferenceToInstallSqlData(IntermediateSection section, SourceLineNumber sourceLineNumbers) { - this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "InstallSqlData", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); - this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "UninstallSqlData", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4InstallSqlData", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4UninstallSqlData", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); } } } -- cgit v1.2.3-55-g6feb From babe3697ec562d6f93f209e23dc03ba77fa57805 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 7 Apr 2021 23:44:12 -0700 Subject: Update dependencies --- .gitignore | 43 ++++++-- appveyor.cmd | 17 ++-- global.json | 2 +- src/CSharp.Build.props | 11 -- src/Cpp.Build.props | 86 ---------------- src/Directory.Build.props | 4 +- src/Directory.Build.targets | 5 +- src/Directory.csproj.props | 13 +++ src/Directory.csproj.targets | 26 +++++ src/Directory.vcxproj.props | 111 +++++++++++++++++++++ src/ca/packages.config | 5 - src/ca/sqlca.vcxproj | 21 ++-- .../TestData/UsingSql/Package.wxs | 8 +- .../WixToolsetTest.Sql/WixToolsetTest.Sql.csproj | 5 +- src/wixext/WixToolset.Sql.wixext.csproj | 12 +-- src/wixext/WixToolset.Sql.wixext.nuspec | 25 +++++ src/wixlib/sql.wixproj | 16 +-- 17 files changed, 250 insertions(+), 160 deletions(-) delete mode 100644 src/CSharp.Build.props delete mode 100644 src/Cpp.Build.props create mode 100644 src/Directory.csproj.props create mode 100644 src/Directory.csproj.targets create mode 100644 src/Directory.vcxproj.props delete mode 100644 src/ca/packages.config create mode 100644 src/wixext/WixToolset.Sql.wixext.nuspec (limited to 'src') diff --git a/.gitignore b/.gitignore index 3e8a1553..1ee53850 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,9 @@ # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs +# Mono auto generated files +mono_crash.* + # Build results [Dd]ebug/ [Dd]ebugPublic/ @@ -20,12 +23,14 @@ [Rr]eleases/ x64/ x86/ +[Ww][Ii][Nn]32/ [Aa][Rr][Mm]/ [Aa][Rr][Mm]64/ bld/ [Bb]in/ [Oo]bj/ [Ll]og/ +[Ll]ogs/ # Visual Studio 2015/2017 cache/options directory .vs/ @@ -39,9 +44,10 @@ Generated\ Files/ [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* -# NUNIT +# NUnit *.VisualState.xml TestResult.xml +nunit-*.xml # Build Results of an ATL Project [Dd]ebugPS/ @@ -56,6 +62,9 @@ project.lock.json project.fragment.lock.json artifacts/ +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + # StyleCop StyleCopReport.xml @@ -122,9 +131,6 @@ _ReSharper*/ *.[Rr]e[Ss]harper *.DotSettings.user -# JustCode is a .NET coding add-in -.JustCode - # TeamCity is a build add-in _TeamCity* @@ -135,6 +141,11 @@ _TeamCity* .axoCover/* !.axoCover/settings.json +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + # Visual Studio code coverage results *.coverage *.coveragexml @@ -182,6 +193,8 @@ PublishScripts/ # NuGet Packages *.nupkg +# NuGet Symbol Packages +*.snupkg # The packages folder can be ignored because of Package Restore **/[Pp]ackages/* # except build/, which is used as an MSBuild target. @@ -206,6 +219,8 @@ BundleArtifacts/ Package.StoreAssociation.xml _pkginfo.txt *.appx +*.appxbundle +*.appxupload # Visual Studio cache files # files ending in .cache can be ignored @@ -231,8 +246,6 @@ orleans.codegen.cs # Since there are multiple workflows, uncomment next line to ignore bower_components # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) #bower_components/ -# ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true -**/wwwroot/lib/ # RIA/Silverlight projects Generated_Code/ @@ -257,6 +270,9 @@ ServiceFabricBackup/ *.bim.layout *.bim_*.settings *.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl # Microsoft Fakes FakesAssemblies/ @@ -292,10 +308,6 @@ paket-files/ # FAKE - F# Make .fake/ -# JetBrains Rider -.idea/ -*.sln.iml - # CodeRush personal settings .cr/personal @@ -337,5 +349,14 @@ ASALocalRun/ # Local History for Visual Studio .localhistory/ -# BeatPulse healthcheck temp database +# BeatPulse healthcheck temp database healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd diff --git a/appveyor.cmd b/appveyor.cmd index 26804036..f21449d2 100644 --- a/appveyor.cmd +++ b/appveyor.cmd @@ -1,14 +1,19 @@ @setlocal @pushd %~dp0 +@set _C=Release +@if /i "%1"=="debug" set _C=Debug -nuget restore || exit /b +:: Restore +msbuild -p:Configuration=%_C% -t:Restore || exit /b -msbuild -p:Configuration=Release -t:Restore || exit /b +:: Build +msbuild -p:Configuration=%_C% src\test\WixToolsetTest.Sql\WixToolsetTest.Sql.csproj || exit /b -msbuild -p:Configuration=Release src\test\WixToolsetTest.Sql\WixToolsetTest.Sql.csproj || exit /b -dotnet test -c Release --no-build src\test\WixToolsetTest.Sql || exit /b +:: Test +dotnet test -c %_C% --no-build src\test\WixToolsetTest.Sql || exit /b -msbuild -p:Configuration=Release -t:Pack src\wixext\WixToolset.Sql.wixext.csproj || exit /b +:: Pack +msbuild -p:Configuration=%_C% -p:NoBuild=true -t:Pack src\wixext\WixToolset.Sql.wixext.csproj || exit /b @popd -@endlocal \ No newline at end of file +@endlocal diff --git a/global.json b/global.json index 32e88652..fc26eb6e 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "msbuild-sdks": { - "WixToolset.Sdk": "4.0.0-build-0190" + "WixToolset.Sdk": "4.0.0-build-0206" } } diff --git a/src/CSharp.Build.props b/src/CSharp.Build.props deleted file mode 100644 index b12f4c6e..00000000 --- a/src/CSharp.Build.props +++ /dev/null @@ -1,11 +0,0 @@ - - - - - true - $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) - - diff --git a/src/Cpp.Build.props b/src/Cpp.Build.props deleted file mode 100644 index 9b7a1bb5..00000000 --- a/src/Cpp.Build.props +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - Win32 - $(BaseIntermediateOutputPath)$(Configuration)\$(Platform)\ - $(OutputPath)$(Platform)\ - - - - $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) - - - - - $(DisableSpecificCompilerWarnings) - Level4 - $(ProjectDir)inc;$(MSBuildProjectDirectory);$(IntDir);$(SqlCESdkIncludePath);$(ProjectAdditionalIncludeDirectories);%(AdditionalIncludeDirectories) - WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) - Use - precomp.h - StdCall - true - false - -YlprecompDefine - /Zc:threadSafeInit- %(AdditionalOptions) - true - - - $(ArmPreprocessorDefinitions);%(PreprocessorDefinitions) - $(ProjectAdditionalResourceIncludeDirectories);%(AdditionalIncludeDirectories) - - - $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ProjectAdditionalLibraryDirectories);%(AdditionalLibraryDirectories) - - - $(ProjectSubSystem) - $(ProjectModuleDefinitionFile) - $(ResourceOnlyDll) - true - $(ProjectAdditionalLinkLibraries);advapi32.lib;comdlg32.lib;user32.lib;oleaut32.lib;gdi32.lib;shell32.lib;ole32.lib;version.lib;%(AdditionalDependencies) - $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ArmLibraryDirectories);$(ProjectAdditionalLinkLibraryDirectories);%(AdditionalLibraryDirectories) - /IGNORE:4099 %(AdditionalOptions) - - - - - - NoExtensions - - - - - CDecl - - - - - OldStyle - true - true - - - - - Disabled - EnableFastChecks - _DEBUG;DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebug - - - - - MinSpace - NDEBUG;%(PreprocessorDefinitions) - true - true - MultiThreaded - - - true - true - - - diff --git a/src/Directory.Build.props b/src/Directory.Build.props index f83cc154..b3c6287c 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -22,8 +22,6 @@ WiX Toolset - - - + diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index dac7452a..2fcc765a 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -40,9 +40,12 @@ - + + + + diff --git a/src/Directory.csproj.props b/src/Directory.csproj.props new file mode 100644 index 00000000..81d24ad1 --- /dev/null +++ b/src/Directory.csproj.props @@ -0,0 +1,13 @@ + + + + + true + true + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) + false + + diff --git a/src/Directory.csproj.targets b/src/Directory.csproj.targets new file mode 100644 index 00000000..c3270426 --- /dev/null +++ b/src/Directory.csproj.targets @@ -0,0 +1,26 @@ + + + + + false + $(OutputPath)\$(AssemblyName).xml + + + + + $(PrivateRepositoryUrl.Replace('.git','')) + + $(MSBuildProjectName).nuspec + $(OutputPath)..\ + $(NuspecProperties);Id=$(PackageId);Authors=$(Authors);Copyright=$(Copyright);Description=$(Description);Title=$(Title) + $(NuspecProperties);Version=$(PackageVersion);RepositoryCommit=$(SourceRevisionId);RepositoryType=$(RepositoryType);RepositoryUrl=$(PrivateRepositoryUrl);ProjectFolder=$(MSBuildProjectDirectory)\;ProjectUrl=$(ProjectUrl) + true + snupkg + + + + diff --git a/src/Directory.vcxproj.props b/src/Directory.vcxproj.props new file mode 100644 index 00000000..bcf26c57 --- /dev/null +++ b/src/Directory.vcxproj.props @@ -0,0 +1,111 @@ + + + + + + Win32 + $(BaseIntermediateOutputPath)$(Configuration)\$(Platform)\ + $(OutputPath)$(Platform)\ + + + $(Company) + $(Copyright) + + win-x86;win-x64;win-arm64 + native,Version=v0.0 + + + + $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) + + + + + $(DisableSpecificCompilerWarnings) + Level4 + $(ProjectDir)inc;$(MSBuildProjectDirectory);$(IntDir);$(SqlCESdkIncludePath);$(ProjectAdditionalIncludeDirectories);%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + Use + precomp.h + StdCall + true + false + -YlprecompDefine + /Zc:threadSafeInit- %(AdditionalOptions) + true + + + $(ArmPreprocessorDefinitions);%(PreprocessorDefinitions) + $(ProjectAdditionalResourceIncludeDirectories);%(AdditionalIncludeDirectories) + + + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ProjectAdditionalLibraryDirectories);%(AdditionalLibraryDirectories) + + + $(ProjectSubSystem) + $(ProjectModuleDefinitionFile) + $(ResourceOnlyDll) + true + $(ProjectAdditionalLinkLibraries);advapi32.lib;comdlg32.lib;user32.lib;oleaut32.lib;gdi32.lib;shell32.lib;ole32.lib;version.lib;%(AdditionalDependencies) + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ArmLibraryDirectories);$(ProjectAdditionalLinkLibraryDirectories);%(AdditionalLibraryDirectories) + /IGNORE:4099 %(AdditionalOptions) + + + + + + NoExtensions + + + + + CDecl + + + + + OldStyle + true + true + + + + + Disabled + EnableFastChecks + _DEBUG;DEBUG;%(PreprocessorDefinitions) + MultiThreadedDebug + + + + + + MultiThreadedDebugDll + + + + + MinSpace + NDEBUG;%(PreprocessorDefinitions) + true + true + MultiThreaded + + + true + true + + + + + + MultiThreadedDll + + + + + $(LinkKeyFile) + $(LinkDelaySign) + + + diff --git a/src/ca/packages.config b/src/ca/packages.config deleted file mode 100644 index e3dc0e43..00000000 --- a/src/ca/packages.config +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/ca/sqlca.vcxproj b/src/ca/sqlca.vcxproj index 112ad18b..18becc5f 100644 --- a/src/ca/sqlca.vcxproj +++ b/src/ca/sqlca.vcxproj @@ -1,10 +1,7 @@ - - - - + Debug @@ -72,17 +69,15 @@ - - + + + + + + - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - + diff --git a/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs b/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs index 44820bdd..ee3bc921 100644 --- a/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs +++ b/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs @@ -12,10 +12,8 @@ - - - - - + + + diff --git a/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj b/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj index a845e563..bbf3041d 100644 --- a/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj +++ b/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj @@ -12,10 +12,7 @@ - - - - + diff --git a/src/wixext/WixToolset.Sql.wixext.csproj b/src/wixext/WixToolset.Sql.wixext.csproj index 01ab5504..5a1ebeb0 100644 --- a/src/wixext/WixToolset.Sql.wixext.csproj +++ b/src/wixext/WixToolset.Sql.wixext.csproj @@ -7,24 +7,24 @@ WixToolset.Sql WiX Toolset Sql Extension WiX Toolset Sql Extension - true - build + embedded + true - - + - + - + + diff --git a/src/wixext/WixToolset.Sql.wixext.nuspec b/src/wixext/WixToolset.Sql.wixext.nuspec new file mode 100644 index 00000000..ba3eaade --- /dev/null +++ b/src/wixext/WixToolset.Sql.wixext.nuspec @@ -0,0 +1,25 @@ + + + + $id$ + $version$ + $title$ + $description$ + $authors$ + MS-RL + false + $copyright$ + $projectUrl$ + + + + + + + + + + + + + diff --git a/src/wixlib/sql.wixproj b/src/wixlib/sql.wixproj index 7462f684..ac994e6b 100644 --- a/src/wixlib/sql.wixproj +++ b/src/wixlib/sql.wixproj @@ -1,11 +1,11 @@ + Library true - en-us - + @@ -13,12 +13,12 @@ - - - + + + - + - + - \ No newline at end of file + -- cgit v1.2.3-55-g6feb From 594bb035b8f27d341c982dc0754589a447b9abd6 Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sun, 18 Apr 2021 21:09:37 -0400 Subject: Add `Wix4` table prefixes. Per https://github.com/wixtoolset/issues/issues/5933. --- src/ca/scadb.cpp | 39 +++++++-------- src/ca/scaexec.cpp | 2 +- src/ca/scasql.cpp | 10 ++-- src/ca/scasqlstr.cpp | 56 +++++++++++----------- src/ca/scasqlstr.h | 2 +- src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs | 12 +++-- .../TestData/UsingSql/PackageComponents.wxs | 12 ++++- src/wixext/SqlTableDefinitions.cs | 18 +++---- 8 files changed, 82 insertions(+), 69 deletions(-) (limited to 'src') diff --git a/src/ca/scadb.cpp b/src/ca/scadb.cpp index 68f7b10b..288b9efe 100644 --- a/src/ca/scadb.cpp +++ b/src/ca/scadb.cpp @@ -5,12 +5,12 @@ // sql queries LPCWSTR vcsSqlDatabaseQuery = L"SELECT `SqlDb`, `Server`, `Instance`, `Database`, " L"`Component_`, `User_`, `FileSpec_`, `FileSpec_Log`, `Attributes` " - L"FROM `SqlDatabase`"; + L"FROM `Wix4SqlDatabase`"; enum eSqlDatabaseQuery { sdqSqlDb = 1, sdqServer, sdqInstance, sdqDatabase, sdqComponent, sdqUser, sdqDbFileSpec, sdqLogFileSpec, sdqAttributes }; LPCWSTR vcsSqlFileSpecQuery = L"SELECT `FileSpec`, `Name`, `Filename`, `Size`, " - L"`MaxSize`, `GrowthSize` FROM `SqlFileSpec` WHERE `FileSpec`=?"; + L"`MaxSize`, `GrowthSize` FROM `Wix4SqlFileSpec` WHERE `FileSpec`=?"; enum eSqlFileSpecQuery { sfsqFileSpec = 1, sfsqName, sfsqFilename, sfsqSize, sfsqMaxSize, sfsqGrowth }; @@ -63,21 +63,21 @@ HRESULT ScaDbsRead( SCA_DB* psd = NULL; - if (S_OK != WcaTableExists(L"SqlDatabase")) + if (S_OK != WcaTableExists(L"Wix4SqlDatabase")) { - WcaLog(LOGMSG_VERBOSE, "Skipping ScaCreateDatabase() - SqlDatabase table not present"); + WcaLog(LOGMSG_VERBOSE, "Skipping ScaCreateDatabase() - Wix4SqlDatabase table not present"); ExitFunction1(hr = S_FALSE); } - if (S_OK == WcaTableExists(L"SqlFileSpec")) + if (S_OK == WcaTableExists(L"Wix4SqlFileSpec")) { hr = WcaOpenView(vcsSqlFileSpecQuery, &hViewFileSpec); - ExitOnFailure(hr, "failed to open view on SqlFileSpec table"); + ExitOnFailure(hr, "failed to open view on Wix4SqlFileSpec table"); } // loop through all the sql databases hr = WcaOpenExecuteView(vcsSqlDatabaseQuery, &hView); - ExitOnFailure(hr, "Failed to open view on SqlDatabase table"); + ExitOnFailure(hr, "Failed to open view on Wix4SqlDatabase table"); while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) { BOOL fHasComponent = FALSE; @@ -85,7 +85,7 @@ HRESULT ScaDbsRead( INSTALLSTATE isAction = INSTALLSTATE_UNKNOWN; hr = WcaGetRecordString(hRec, sdqSqlDb, &pwzId); - ExitOnFailure(hr, "Failed to get SqlDatabase.SqlDb"); + ExitOnFailure(hr, "Failed to get Wix4SqlDatabase.SqlDb"); hr = WcaGetRecordString(hRec, sdqComponent, &pwzComponent); ExitOnFailure(hr, "Failed to get Component for database: '%ls'", psd->wzKey); @@ -110,10 +110,10 @@ HRESULT ScaDbsRead( ExitOnFailure(hr, "Failed to allocate memory for new database: %D", pwzId); hr = ::StringCchCopyW(psd->wzKey, countof(psd->wzKey), pwzId); - ExitOnFailure(hr, "Failed to copy SqlDatabase.SqlDbL: %ls", pwzId); + ExitOnFailure(hr, "Failed to copy Wix4SqlDatabase.SqlDbL: %ls", pwzId); hr = ::StringCchCopyW(psd->wzComponent, countof(psd->wzComponent), pwzComponent); - ExitOnFailure(hr, "Failed to copy SqlDatabase.Component_: %ls", pwzComponent); + ExitOnFailure(hr, "Failed to copy Wix4SqlDatabase.Component_: %ls", pwzComponent); psd->fHasComponent = fHasComponent; psd->isInstalled = isInstalled; @@ -135,7 +135,7 @@ HRESULT ScaDbsRead( ExitOnFailure(hr, "Failed to copy database string to database object:%ls", pwzData); hr = WcaGetRecordInteger(hRec, sdqAttributes, &psd->iAttributes); - ExitOnFailure(hr, "Failed to get SqlDatabase.Attributes"); + ExitOnFailure(hr, "Failed to get Wix4SqlDatabase.Attributes"); hr = WcaGetRecordFormattedString(hRec, sdqUser, &pwzData); ExitOnFailure(hr, "Failed to get User record for database: '%ls'", psd->wzKey); @@ -189,7 +189,7 @@ HRESULT ScaDbsRead( { hr = S_OK; } - ExitOnFailure(hr, "Failure occured while processing SqlDatabase table"); + ExitOnFailure(hr, "Failure occured while processing Wix4SqlDatabase table"); LExit: if (psd) @@ -521,18 +521,18 @@ HRESULT GetFileSpec( // get the FileSpec record hr = WcaExecuteView(hViewFileSpec, hRecFileSpec); - ExitOnFailure(hr, "failed to execute view on SqlFileSpec table for filespec: %ls", wzKey); + ExitOnFailure(hr, "failed to execute view on Wix4SqlFileSpec table for filespec: %ls", wzKey); hr = WcaFetchSingleRecord(hViewFileSpec, &hRec); ExitOnFailure(hr, "failed to get record for filespec: %ls", wzKey); // read the data out of the filespec record hr = WcaGetRecordFormattedString(hRec, sfsqName, &pwzData); - ExitOnFailure(hr, "Failed to get SqlFileSpec.Name for filespec: %ls", wzKey); + ExitOnFailure(hr, "Failed to get Wix4SqlFileSpec.Name for filespec: %ls", wzKey); hr = ::StringCchCopyW(psf->wzName, countof(psf->wzName), pwzData); - ExitOnFailure(hr, "Failed to copy SqlFileSpec.Name string: %ls", pwzData); + ExitOnFailure(hr, "Failed to copy Wix4SqlFileSpec.Name string: %ls", pwzData); hr = WcaGetRecordFormattedString(hRec, sfsqFilename, &pwzData); - ExitOnFailure(hr, "Failed to get SqlFileSpec.Filename for filespec: %ls", wzKey); + ExitOnFailure(hr, "Failed to get Wix4SqlFileSpec.Filename for filespec: %ls", wzKey); if (*pwzData) { hr = ::StringCchCopyW(psf->wzFilename, countof(psf->wzFilename), pwzData); @@ -545,7 +545,7 @@ HRESULT GetFileSpec( } hr = WcaGetRecordFormattedString(hRec, sfsqSize, &pwzData); - ExitOnFailure(hr, "Failed to get SqlFileSpec.Size for filespec: %ls", wzKey); + ExitOnFailure(hr, "Failed to get Wix4SqlFileSpec.Size for filespec: %ls", wzKey); if (*pwzData) { hr = ::StringCchCopyW(psf->wzSize, countof(psf->wzSize), pwzData); @@ -557,7 +557,7 @@ HRESULT GetFileSpec( } hr = WcaGetRecordFormattedString(hRec, sfsqMaxSize, &pwzData); - ExitOnFailure(hr, "Failed to get SqlFileSpec.MaxSize for filespec: %ls", wzKey); + ExitOnFailure(hr, "Failed to get Wix4SqlFileSpec.MaxSize for filespec: %ls", wzKey); if (*pwzData) { hr = ::StringCchCopyW(psf->wzMaxSize, countof(psf->wzMaxSize), pwzData); @@ -569,7 +569,7 @@ HRESULT GetFileSpec( } hr = WcaGetRecordFormattedString(hRec, sfsqGrowth, &pwzData); - ExitOnFailure(hr, "Failed to get SqlFileSpec.GrowthSize for filespec: %ls", wzKey); + ExitOnFailure(hr, "Failed to get Wix4SqlFileSpec.GrowthSize for filespec: %ls", wzKey); if (*pwzData) { hr = ::StringCchCopyW(psf->wzGrow, countof(psf->wzGrow), pwzData); @@ -581,6 +581,7 @@ HRESULT GetFileSpec( } hr = S_OK; + LExit: ReleaseStr(pwzData); return hr; diff --git a/src/ca/scaexec.cpp b/src/ca/scaexec.cpp index 7a30f52a..b2648361 100644 --- a/src/ca/scaexec.cpp +++ b/src/ca/scaexec.cpp @@ -342,7 +342,7 @@ extern "C" UINT __stdcall ExecuteSqlStrings(MSIHANDLE hInstall) hr = WcaReadStringFromCaData(&pwz, &pwzSql); ExitOnFailure(hr, "failed to read SQL string for key: %ls", pwzSqlKey); - // If the SqlString row is set to continue on error and the DB connection failed, skip attempting to execute + // If the Wix4SqlString row is set to continue on error and the DB connection failed, skip attempting to execute if ((iAttributesSQL & SCASQL_CONTINUE_ON_ERROR) && FAILED(hrDB)) { WcaLog(LOGMSG_STANDARD, "Error 0x%x: continuing after failure to connect to database: %ls", hrDB, pwzDatabase); diff --git a/src/ca/scasql.cpp b/src/ca/scasql.cpp index 5e3edd1c..b0216950 100644 --- a/src/ca/scasql.cpp +++ b/src/ca/scasql.cpp @@ -67,21 +67,21 @@ static HRESULT ConfigureSqlData( SCA_SQLSTR* psssList = NULL; // check for the prerequsite tables - if (S_OK != WcaTableExists(L"SqlDatabase")) + if (S_OK != WcaTableExists(L"Wix4SqlDatabase")) { - WcaLog(LOGMSG_VERBOSE, "skipping SQL CustomAction, no SqlDatabase table"); + WcaLog(LOGMSG_VERBOSE, "skipping SQL CustomAction, no Wix4SqlDatabase table"); ExitFunction1(hr = S_FALSE); } // read tables hr = ScaDbsRead(&psdList, saAction); - ExitOnFailure(hr, "failed to read SqlDatabase table"); + ExitOnFailure(hr, "failed to read Wix4SqlDatabase table"); hr = ScaSqlStrsRead(&psssList, saAction); - ExitOnFailure(hr, "failed to read SqlStrings table"); + ExitOnFailure(hr, "failed to read Wix4SqlString table"); hr = ScaSqlStrsReadScripts(&psssList, saAction); - ExitOnFailure(hr, "failed to read SqlScripts table"); + ExitOnFailure(hr, "failed to read Wix4SqlScript table"); if (SCA_ACTION_UNINSTALL == saAction) { diff --git a/src/ca/scasqlstr.cpp b/src/ca/scasqlstr.cpp index 6ac526a6..c3ebd43d 100644 --- a/src/ca/scasqlstr.cpp +++ b/src/ca/scasqlstr.cpp @@ -4,11 +4,11 @@ // sql queries LPCWSTR vcsSqlStringQuery = L"SELECT `String`, `SqlDb_`, `Component_`,`SQL`,`User_`,`Attributes`,`Sequence` " -L"FROM `SqlString` ORDER BY `SqlDb_`,`Sequence`"; +L"FROM `Wix4SqlString` ORDER BY `SqlDb_`,`Sequence`"; enum eSqlStringQuery { ssqSqlString = 1, ssqSqlDb, ssqComponent, ssqSQL, ssqUser, ssqAttributes, ssqSequence }; LPCWSTR vcsSqlScriptQuery = L"SELECT `ScriptBinary_`,`Script`, `SqlDb_`, `Component_`,`User_`,`Attributes`,`Sequence` " -L"FROM `SqlScript` ORDER BY `SqlDb_`,`Sequence`"; +L"FROM `Wix4SqlScript` ORDER BY `SqlDb_`,`Sequence`"; enum eSqlScriptQuery { sscrqScriptBinary=1, sscrqSqlScript, sscrqSqlDb, sscrqComponent, sscrqUser, sscrqAttributes, sscrqSequence }; LPCWSTR vcsSqlBinaryScriptQuery = L"SELECT `Data` FROM `Binary` WHERE `Name`=?"; @@ -44,15 +44,15 @@ HRESULT ScaSqlStrsRead( SCA_SQLSTR* psss = NULL; - if (S_OK != WcaTableExists(L"SqlString") || S_OK != WcaTableExists(L"SqlDatabase")) + if (S_OK != WcaTableExists(L"Wix4SqlString") || S_OK != WcaTableExists(L"Wix4SqlDatabase")) { - WcaLog(LOGMSG_VERBOSE, "Skipping ScaSqlStrsRead() - SqlString and/or SqlDatabase table not present"); + WcaLog(LOGMSG_VERBOSE, "Skipping ScaSqlStrsRead() - Wix4SqlString and/or Wix4SqlDatabase table not present"); ExitFunction1(hr = S_FALSE); } // loop through all the sql strings hr = WcaOpenExecuteView(vcsSqlStringQuery, &hView); - ExitOnFailure(hr, "Failed to open view on SqlString table"); + ExitOnFailure(hr, "Failed to open view on Wix4SqlString table"); while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) { INSTALLSTATE isInstalled = INSTALLSTATE_UNKNOWN; @@ -80,30 +80,30 @@ HRESULT ScaSqlStrsRead( psss->isAction = isAction; hr = WcaGetRecordString(hRec, ssqSqlString, &pwzData); - ExitOnFailure(hr, "Failed to get SqlString.String"); + ExitOnFailure(hr, "Failed to get Wix4SqlString.String"); hr = ::StringCchCopyW(psss->wzKey, countof(psss->wzKey), pwzData); - ExitOnFailure(hr, "Failed to copy SqlString.String: %ls", pwzData); + ExitOnFailure(hr, "Failed to copy Wix4SqlString.String: %ls", pwzData); // find the database information for this string hr = WcaGetRecordString(hRec, ssqSqlDb, &pwzData); - ExitOnFailure(hr, "Failed to get SqlString.SqlDb_ for SqlString '%ls'", psss->wzKey); + ExitOnFailure(hr, "Failed to get Wix4SqlString.SqlDb_ for SqlString '%ls'", psss->wzKey); hr = ::StringCchCopyW(psss->wzSqlDb, countof(psss->wzSqlDb), pwzData); - ExitOnFailure(hr, "Failed to copy SqlString.SqlDb_: %ls", pwzData); + ExitOnFailure(hr, "Failed to copy Wix4SqlString.SqlDb_: %ls", pwzData); hr = WcaGetRecordInteger(hRec, ssqAttributes, &psss->iAttributes); - ExitOnFailure(hr, "Failed to get SqlString.Attributes for SqlString '%ls'", psss->wzKey); + ExitOnFailure(hr, "Failed to get Wix4SqlString.Attributes for SqlString '%ls'", psss->wzKey); //get the sequence number for the string (note that this will be sequenced with scripts too) hr = WcaGetRecordInteger(hRec, ssqSequence, &psss->iSequence); - ExitOnFailure(hr, "Failed to get SqlString.Sequence for SqlString '%ls'", psss->wzKey); + ExitOnFailure(hr, "Failed to get Wix4SqlString.Sequence for SqlString '%ls'", psss->wzKey); // execute SQL hr = WcaGetRecordFormattedString(hRec, ssqSQL, &pwzData); - ExitOnFailure(hr, "Failed to get SqlString.SQL for SqlString '%ls'", psss->wzKey); + ExitOnFailure(hr, "Failed to get Wix4SqlString.SQL for SQL string '%ls'", psss->wzKey); Assert(!psss->pwzSql); hr = StrAllocString(&psss->pwzSql, pwzData, 0); - ExitOnFailure(hr, "Failed to alloc string for SqlString '%ls'", psss->wzKey); + ExitOnFailure(hr, "Failed to alloc string for SQL string '%ls'", psss->wzKey); *ppsssList = AddSqlStrToList(*ppsssList, psss); psss = NULL; // set the sss to NULL so it doesn't get freed below @@ -113,7 +113,7 @@ HRESULT ScaSqlStrsRead( { hr = S_OK; } - ExitOnFailure(hr, "Failure occured while reading SqlString table"); + ExitOnFailure(hr, "Failure occured while reading Wix4SqlString table"); LExit: // if anything was left over after an error clean it all up @@ -157,19 +157,19 @@ HRESULT ScaSqlStrsReadScripts( SCA_SQLSTR sss; SCA_SQLSTR* psss = NULL; - if (S_OK != WcaTableExists(L"SqlScript") || S_OK != WcaTableExists(L"SqlDatabase") || S_OK != WcaTableExists(L"Binary")) + if (S_OK != WcaTableExists(L"Wix4SqlScript") || S_OK != WcaTableExists(L"Wix4SqlDatabase") || S_OK != WcaTableExists(L"Binary")) { - WcaLog(LOGMSG_VERBOSE, "Skipping ScaSqlStrsReadScripts() - SqlScripts and/or SqlDatabase table not present"); + WcaLog(LOGMSG_VERBOSE, "Skipping ScaSqlStrsReadScripts() - Wix4SqlScript and/or Wix4SqlDatabase table not present"); ExitFunction1(hr = S_FALSE); } // open a view on the binary table hr = WcaOpenView(vcsSqlBinaryScriptQuery, &hViewBinary); - ExitOnFailure(hr, "Failed to open view on Binary table for SqlScripts"); + ExitOnFailure(hr, "Failed to open view on Binary table for SQL scripts"); // loop through all the sql scripts hr = WcaOpenExecuteView(vcsSqlScriptQuery, &hView); - ExitOnFailure(hr, "Failed to open view on SqlScript table"); + ExitOnFailure(hr, "Failed to open view on Wix4SqlScript table"); while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) { INSTALLSTATE isInstalled = INSTALLSTATE_UNKNOWN; @@ -196,33 +196,33 @@ HRESULT ScaSqlStrsReadScripts( sss.isAction = isAction; hr = WcaGetRecordString(hRec, sscrqSqlScript, &pwzData); - ExitOnFailure(hr, "Failed to get SqlScript.Script"); + ExitOnFailure(hr, "Failed to get Wix4SqlScript.Script"); hr = ::StringCchCopyW(sss.wzKey, countof(sss.wzKey), pwzData); - ExitOnFailure(hr, "Failed to copy SqlScript.Script: %ls", pwzData); + ExitOnFailure(hr, "Failed to copy Wix4SqlScript.Script: %ls", pwzData); // find the database information for this string hr = WcaGetRecordString(hRec, sscrqSqlDb, &pwzData); - ExitOnFailure(hr, "Failed to get SqlScript.SqlDb_ for SqlScript '%ls'", sss.wzKey); + ExitOnFailure(hr, "Failed to get Wix4SqlScript.SqlDb_ for SqlScript '%ls'", sss.wzKey); hr = ::StringCchCopyW(sss.wzSqlDb, countof(sss.wzSqlDb), pwzData); - ExitOnFailure(hr, "Failed to copy SqlScritp.SqlDbb: %ls", pwzData); + ExitOnFailure(hr, "Failed to copy Wix4SqlScript.SqlDbb: %ls", pwzData); hr = WcaGetRecordInteger(hRec, sscrqAttributes, &sss.iAttributes); - ExitOnFailure(hr, "Failed to get SqlScript.Attributes for SqlScript '%ls'", sss.wzKey); + ExitOnFailure(hr, "Failed to get Wix4SqlScript.Attributes for SqlScript '%ls'", sss.wzKey); hr = WcaGetRecordInteger(hRec, sscrqSequence, &sss.iSequence); - ExitOnFailure(hr, "Failed to get SqlScript.Sequence for SqlScript '%ls'", sss.wzKey); + ExitOnFailure(hr, "Failed to get Wix4SqlScript.Sequence for SqlScript '%ls'", sss.wzKey); // get the sql script out of the binary stream hr = WcaExecuteView(hViewBinary, hRec); - ExitOnFailure(hr, "Failed to open SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey); + ExitOnFailure(hr, "Failed to open Wix4SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey); hr = WcaFetchSingleRecord(hViewBinary, &hRecBinary); - ExitOnFailure(hr, "Failed to fetch SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey); + ExitOnFailure(hr, "Failed to fetch Wix4SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey); // Note: We need to allocate an extra character on the stream to NULL terminate the SQL script. // The WcaGetRecordStream() function won't let us add extra space on the end of the stream // so we'll read the stream "the old fashioned way". //hr = WcaGetRecordStream(hRecBinary, ssbsqData, (BYTE**)&pbScript, &cbScript); - //ExitOnFailure(hr, "Failed to read SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey); + //ExitOnFailure(hr, "Failed to read Wix4SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey); er = ::MsiRecordReadStream(hRecBinary, ssbsqData, NULL, &cbRead); hr = HRESULT_FROM_WIN32(er); ExitOnFailure(hr, "failed to get size of stream"); @@ -472,7 +472,7 @@ HRESULT ScaSqlStrsReadScripts( { hr = S_OK; } - ExitOnFailure(hr, "Failure occured while reading SqlString table"); + ExitOnFailure(hr, "Failure occured while reading Wix4SqlScript table"); LExit: // if anything was left over after an error clean it all up diff --git a/src/ca/scasqlstr.h b/src/ca/scasqlstr.h index a6f6df1c..72c1d770 100644 --- a/src/ca/scasqlstr.h +++ b/src/ca/scasqlstr.h @@ -18,7 +18,7 @@ struct SCA_SQLSTR LPWSTR pwzSql; int iAttributes; - int iSequence; //used to sequence SqlString and SqlScript tables together + int iSequence; //used to sequence Wix4SqlString and Wix4SqlScript tables together SCA_SQLSTR* psssNext; }; diff --git a/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs b/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs index 7d51c0fb..aa9d7a1f 100644 --- a/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs +++ b/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs @@ -11,15 +11,19 @@ namespace WixToolsetTest.Sql public class SqlExtensionFixture { [Fact] - public void CanBuildUsingSqlString() + public void CanBuildUsingSqlStuff() { var folder = TestData.Get(@"TestData\UsingSql"); var build = new Builder(folder, typeof(SqlExtensionFactory), new[] { folder }); - var results = build.BuildAndQuery(Build, "SqlString"); - Assert.Equal(new[] + var results = build.BuildAndQuery(Build, "Wix4SqlDatabase", "Wix4SqlFileSpec", "Wix4SqlScript", "Wix4SqlString"); + WixAssert.CompareLineByLine(new[] { - "SqlString:TestString\tTestDB\tfilF5_pLhBuF5b4N9XEo52g_hUM5Lo\tCREATE TABLE TestTable1(name varchar(20), value varchar(20))\t\t1\t", + "Wix4SqlDatabase:TestDB\tMySQLHostName\tMyInstanceName\tMyDB\tDatabaseComponent\t\tTestFileSpecId\tTestLogFileSpecId\t35", + "Wix4SqlFileSpec:TestFileSpecId\tTestFileSpecLogicalName\tTestFileSpec\t10MB\t100MB\t10%", + "Wix4SqlFileSpec:TestLogFileSpecId\tTestLogFileSpecLogicalName\tTestLogFileSpec\t1MB\t10MB\t1%", + "Wix4SqlScript:TestScript\tTestDB\tDatabaseComponent\tScriptBinary\t\t1\t", + "Wix4SqlString:TestString\tTestDB\tDatabaseComponent\tCREATE TABLE TestTable1(name varchar(20), value varchar(20))\t\t1\t", }, results.ToArray()); } diff --git a/src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs b/src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs index 653f7e02..f7626926 100644 --- a/src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs +++ b/src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs @@ -2,12 +2,20 @@ + + - - + + + + + + + + diff --git a/src/wixext/SqlTableDefinitions.cs b/src/wixext/SqlTableDefinitions.cs index 0ab6f989..029a092e 100644 --- a/src/wixext/SqlTableDefinitions.cs +++ b/src/wixext/SqlTableDefinitions.cs @@ -7,7 +7,7 @@ namespace WixToolset.Sql public static class SqlTableDefinitions { public static readonly TableDefinition SqlDatabase = new TableDefinition( - "SqlDatabase", + "Wix4SqlDatabase", SqlSymbolDefinitions.SqlDatabase, new[] { @@ -17,15 +17,15 @@ namespace WixToolset.Sql new ColumnDefinition("Database", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Primary key, name of database in a SQL Server"), new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key, Component used to determine install state ", modularizeType: ColumnModularizeType.Column), new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "User", keyColumn: 1, description: "Foreign key, User used to log into database", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("FileSpec_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "SqlFileSpec", keyColumn: 1, description: "Foreign key referencing SqlFileSpec.", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("FileSpec_Log", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "SqlFileSpec", keyColumn: 1, description: "Foreign key referencing SqlFileSpec.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("FileSpec_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "Wix4SqlFileSpec", keyColumn: 1, description: "Foreign key referencing SqlFileSpec.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("FileSpec_Log", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "Wix4SqlFileSpec", keyColumn: 1, description: "Foreign key referencing SqlFileSpec.", modularizeType: ColumnModularizeType.Column), new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, minValue: 0, maxValue: 255, description: "1 == create on install, 2 == drop on uninstall, 4 == continue on error, 8 == drop on install, 16 == create on uninstall, 32 == confirm update existing table, 64 == create on reinstall, 128 == drop on reinstall"), }, symbolIdIsPrimaryKey: true ); public static readonly TableDefinition SqlFileSpec = new TableDefinition( - "SqlFileSpec", + "Wix4SqlFileSpec", SqlSymbolDefinitions.SqlFileSpec, new[] { @@ -40,12 +40,12 @@ namespace WixToolset.Sql ); public static readonly TableDefinition SqlScript = new TableDefinition( - "SqlScript", + "Wix4SqlScript", SqlSymbolDefinitions.SqlScript, new[] { new ColumnDefinition("Script", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token"), - new ColumnDefinition("SqlDb_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "SqlDatabase", keyColumn: 1, description: "Foreign key, SQL Server key", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("SqlDb_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Wix4SqlDatabase", keyColumn: 1, description: "Foreign key, SQL Server key", modularizeType: ColumnModularizeType.Column), new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key, Component used to determine install state", modularizeType: ColumnModularizeType.Column), new ColumnDefinition("ScriptBinary_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Binary", keyColumn: 1, description: "Foreign key, Binary stream that contains SQL Script to execute", modularizeType: ColumnModularizeType.Column), new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "User", keyColumn: 1, description: "Foreign key, User used to log into database", modularizeType: ColumnModularizeType.Column), @@ -56,12 +56,12 @@ namespace WixToolset.Sql ); public static readonly TableDefinition SqlString = new TableDefinition( - "SqlString", + "Wix4SqlString", SqlSymbolDefinitions.SqlString, new[] { - new ColumnDefinition("String", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Id for the SqlString", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("SqlDb_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "SqlDatabase", keyColumn: 1, description: "Foreign key, SQL Server key", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("String", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Id for the Wix4SqlString", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("SqlDb_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Wix4SqlDatabase", keyColumn: 1, description: "Foreign key, SQL Server key", modularizeType: ColumnModularizeType.Column), new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key, Component used to determine install state", modularizeType: ColumnModularizeType.Column), new ColumnDefinition("SQL", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "SQL query to execute"), new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "User", keyColumn: 1, description: "Foreign key, User used to log into database", modularizeType: ColumnModularizeType.Column), -- cgit v1.2.3-55-g6feb From 2977d0ffabcd6d68790e711736d2edd1fe0cc0af Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 20 Apr 2021 13:09:11 -0700 Subject: Integrate latest tooling --- global.json | 2 +- src/wixext/SqlExtensionFactory.cs | 2 +- src/wixext/SqlWindowsInstallerBackendExtension.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/global.json b/global.json index fc26eb6e..23dd3fa6 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "msbuild-sdks": { - "WixToolset.Sdk": "4.0.0-build-0206" + "WixToolset.Sdk": "4.0.0-build-0211" } } diff --git a/src/wixext/SqlExtensionFactory.cs b/src/wixext/SqlExtensionFactory.cs index e7fafed2..279106d3 100644 --- a/src/wixext/SqlExtensionFactory.cs +++ b/src/wixext/SqlExtensionFactory.cs @@ -8,7 +8,7 @@ namespace WixToolset.Sql public class SqlExtensionFactory : BaseExtensionFactory { - protected override IEnumerable ExtensionTypes => new[] + protected override IReadOnlyCollection ExtensionTypes => new[] { typeof(SqlCompiler), typeof(SqlExtensionData), diff --git a/src/wixext/SqlWindowsInstallerBackendExtension.cs b/src/wixext/SqlWindowsInstallerBackendExtension.cs index b679e871..2ccdcc56 100644 --- a/src/wixext/SqlWindowsInstallerBackendExtension.cs +++ b/src/wixext/SqlWindowsInstallerBackendExtension.cs @@ -8,6 +8,6 @@ namespace WixToolset.Sql public class SqlWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension { - public override IEnumerable TableDefinitions => SqlTableDefinitions.All; + public override IReadOnlyCollection TableDefinitions => SqlTableDefinitions.All; } } -- cgit v1.2.3-55-g6feb From e713e6695bd531d1021482d454401b86c84f3f2d Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 4 May 2021 22:50:16 -0700 Subject: Move Sql.wixext into ext --- .editorconfig | 37 - README.md | 2 - Sql.wixext.sln | 59 -- appveyor.cmd | 19 - appveyor.yml | 40 - global.json | 5 - nuget.config | 17 - src/.editorconfig | 37 + src/Directory.Build.props | 27 - src/Directory.Build.targets | 51 -- src/Directory.csproj.props | 13 - src/Directory.csproj.targets | 26 - src/Directory.vcxproj.props | 111 --- src/ca/CustomMsiErrors.h | 10 - src/ca/caDecor.h | 13 - src/ca/dllmain.cpp | 26 - src/ca/precomp.h | 28 - src/ca/sca.h | 33 - src/ca/scacost.h | 7 - src/ca/scadb.cpp | 588 --------------- src/ca/scadb.h | 55 -- src/ca/scaexec.cpp | 393 ---------- src/ca/scasql.cpp | 113 --- src/ca/scasqlstr.cpp | 728 ------------------- src/ca/scasqlstr.h | 51 -- src/ca/scauser.cpp | 82 --- src/ca/scauser.h | 40 - src/ca/sqlca.cpp | 3 - src/ca/sqlca.def | 13 - src/ca/sqlca.vcxproj | 83 --- src/ext/Sql/Directory.Build.props | 27 + src/ext/Sql/Directory.Build.targets | 51 ++ src/ext/Sql/Directory.csproj.props | 13 + src/ext/Sql/Directory.csproj.targets | 26 + src/ext/Sql/Directory.vcxproj.props | 111 +++ src/ext/Sql/README.md | 2 + src/ext/Sql/Sql.wixext.sln | 59 ++ src/ext/Sql/appveyor.cmd | 19 + src/ext/Sql/appveyor.yml | 40 + src/ext/Sql/ca/CustomMsiErrors.h | 10 + src/ext/Sql/ca/caDecor.h | 13 + src/ext/Sql/ca/dllmain.cpp | 26 + src/ext/Sql/ca/precomp.h | 28 + src/ext/Sql/ca/sca.h | 33 + src/ext/Sql/ca/scacost.h | 7 + src/ext/Sql/ca/scadb.cpp | 588 +++++++++++++++ src/ext/Sql/ca/scadb.h | 55 ++ src/ext/Sql/ca/scaexec.cpp | 393 ++++++++++ src/ext/Sql/ca/scasql.cpp | 113 +++ src/ext/Sql/ca/scasqlstr.cpp | 728 +++++++++++++++++++ src/ext/Sql/ca/scasqlstr.h | 51 ++ src/ext/Sql/ca/scauser.cpp | 82 +++ src/ext/Sql/ca/scauser.h | 40 + src/ext/Sql/ca/sqlca.cpp | 3 + src/ext/Sql/ca/sqlca.def | 13 + src/ext/Sql/ca/sqlca.vcxproj | 83 +++ src/ext/Sql/nuget.config | 17 + .../test/WixToolsetTest.Sql/SqlExtensionFixture.cs | 36 + .../TestData/UsingSql/Package.en-us.wxl | 11 + .../TestData/UsingSql/Package.wxs | 19 + .../TestData/UsingSql/PackageComponents.wxs | 22 + .../TestData/UsingSql/example.txt | 1 + .../WixToolsetTest.Sql/WixToolsetTest.Sql.csproj | 38 + .../WixToolsetTest.Sql.v3.ncrunchproject | 5 + src/ext/Sql/wix.snk | Bin 0 -> 596 bytes src/ext/Sql/wixext/SqlCompiler.cs | 804 +++++++++++++++++++++ src/ext/Sql/wixext/SqlDecompiler.cs | 514 +++++++++++++ src/ext/Sql/wixext/SqlErrors.cs | 48 ++ src/ext/Sql/wixext/SqlExtensionData.cs | 30 + src/ext/Sql/wixext/SqlExtensionFactory.cs | 18 + src/ext/Sql/wixext/SqlTableDefinitions.cs | 82 +++ .../wixext/SqlWindowsInstallerBackendExtension.cs | 13 + src/ext/Sql/wixext/Symbols/SqlDatabaseSymbol.cs | 103 +++ src/ext/Sql/wixext/Symbols/SqlFileSpecSymbol.cs | 79 ++ src/ext/Sql/wixext/Symbols/SqlScriptSymbol.cs | 87 +++ src/ext/Sql/wixext/Symbols/SqlStringSymbol.cs | 87 +++ src/ext/Sql/wixext/Symbols/SqlSymbolDefinitions.cs | 51 ++ src/ext/Sql/wixext/WixToolset.Sql.wixext.csproj | 30 + src/ext/Sql/wixext/WixToolset.Sql.wixext.nuspec | 25 + src/ext/Sql/wixext/WixToolset.Sql.wixext.targets | 11 + src/ext/Sql/wixlib/SqlExtension.wxi | 35 + src/ext/Sql/wixlib/SqlExtension.wxs | 15 + src/ext/Sql/wixlib/SqlExtension_arm64.wxs | 7 + src/ext/Sql/wixlib/SqlExtension_x64.wxs | 7 + src/ext/Sql/wixlib/SqlExtension_x86.wxs | 7 + src/ext/Sql/wixlib/caDecor.wxi | 39 + src/ext/Sql/wixlib/caerr.wxi | 96 +++ src/ext/Sql/wixlib/de-de.wxl | 16 + src/ext/Sql/wixlib/en-us.wxl | 16 + src/ext/Sql/wixlib/es-es.wxl | 17 + src/ext/Sql/wixlib/ja-jp.wxl | 16 + src/ext/Sql/wixlib/pl-pl.wxl | 16 + src/ext/Sql/wixlib/pt-br.wxl | 16 + src/ext/Sql/wixlib/pt-pt.wxl | 16 + src/ext/Sql/wixlib/sql.v3.ncrunchproject | 5 + src/ext/Sql/wixlib/sql.wixproj | 24 + src/ext/global.json | 5 + src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs | 36 - .../TestData/UsingSql/Package.en-us.wxl | 11 - .../TestData/UsingSql/Package.wxs | 19 - .../TestData/UsingSql/PackageComponents.wxs | 22 - .../TestData/UsingSql/example.txt | 1 - .../WixToolsetTest.Sql/WixToolsetTest.Sql.csproj | 38 - .../WixToolsetTest.Sql.v3.ncrunchproject | 5 - src/version.json | 11 + src/wix.snk | Bin 596 -> 0 bytes src/wixext/SqlCompiler.cs | 804 --------------------- src/wixext/SqlDecompiler.cs | 514 ------------- src/wixext/SqlErrors.cs | 48 -- src/wixext/SqlExtensionData.cs | 30 - src/wixext/SqlExtensionFactory.cs | 18 - src/wixext/SqlTableDefinitions.cs | 82 --- src/wixext/SqlWindowsInstallerBackendExtension.cs | 13 - src/wixext/Symbols/SqlDatabaseSymbol.cs | 103 --- src/wixext/Symbols/SqlFileSpecSymbol.cs | 79 -- src/wixext/Symbols/SqlScriptSymbol.cs | 87 --- src/wixext/Symbols/SqlStringSymbol.cs | 87 --- src/wixext/Symbols/SqlSymbolDefinitions.cs | 51 -- src/wixext/WixToolset.Sql.wixext.csproj | 30 - src/wixext/WixToolset.Sql.wixext.nuspec | 25 - src/wixext/WixToolset.Sql.wixext.targets | 11 - src/wixlib/SqlExtension.wxi | 35 - src/wixlib/SqlExtension.wxs | 15 - src/wixlib/SqlExtension_arm64.wxs | 7 - src/wixlib/SqlExtension_x64.wxs | 7 - src/wixlib/SqlExtension_x86.wxs | 7 - src/wixlib/caDecor.wxi | 39 - src/wixlib/caerr.wxi | 96 --- src/wixlib/de-de.wxl | 16 - src/wixlib/en-us.wxl | 16 - src/wixlib/es-es.wxl | 17 - src/wixlib/ja-jp.wxl | 16 - src/wixlib/pl-pl.wxl | 16 - src/wixlib/pt-br.wxl | 16 - src/wixlib/pt-pt.wxl | 16 - src/wixlib/sql.v3.ncrunchproject | 5 - src/wixlib/sql.wixproj | 24 - version.json | 11 - 138 files changed, 5146 insertions(+), 5146 deletions(-) delete mode 100644 .editorconfig delete mode 100644 README.md delete mode 100644 Sql.wixext.sln delete mode 100644 appveyor.cmd delete mode 100644 appveyor.yml delete mode 100644 global.json delete mode 100644 nuget.config create mode 100644 src/.editorconfig delete mode 100644 src/Directory.Build.props delete mode 100644 src/Directory.Build.targets delete mode 100644 src/Directory.csproj.props delete mode 100644 src/Directory.csproj.targets delete mode 100644 src/Directory.vcxproj.props delete mode 100644 src/ca/CustomMsiErrors.h delete mode 100644 src/ca/caDecor.h delete mode 100644 src/ca/dllmain.cpp delete mode 100644 src/ca/precomp.h delete mode 100644 src/ca/sca.h delete mode 100644 src/ca/scacost.h delete mode 100644 src/ca/scadb.cpp delete mode 100644 src/ca/scadb.h delete mode 100644 src/ca/scaexec.cpp delete mode 100644 src/ca/scasql.cpp delete mode 100644 src/ca/scasqlstr.cpp delete mode 100644 src/ca/scasqlstr.h delete mode 100644 src/ca/scauser.cpp delete mode 100644 src/ca/scauser.h delete mode 100644 src/ca/sqlca.cpp delete mode 100644 src/ca/sqlca.def delete mode 100644 src/ca/sqlca.vcxproj create mode 100644 src/ext/Sql/Directory.Build.props create mode 100644 src/ext/Sql/Directory.Build.targets create mode 100644 src/ext/Sql/Directory.csproj.props create mode 100644 src/ext/Sql/Directory.csproj.targets create mode 100644 src/ext/Sql/Directory.vcxproj.props create mode 100644 src/ext/Sql/README.md create mode 100644 src/ext/Sql/Sql.wixext.sln create mode 100644 src/ext/Sql/appveyor.cmd create mode 100644 src/ext/Sql/appveyor.yml create mode 100644 src/ext/Sql/ca/CustomMsiErrors.h create mode 100644 src/ext/Sql/ca/caDecor.h create mode 100644 src/ext/Sql/ca/dllmain.cpp create mode 100644 src/ext/Sql/ca/precomp.h create mode 100644 src/ext/Sql/ca/sca.h create mode 100644 src/ext/Sql/ca/scacost.h create mode 100644 src/ext/Sql/ca/scadb.cpp create mode 100644 src/ext/Sql/ca/scadb.h create mode 100644 src/ext/Sql/ca/scaexec.cpp create mode 100644 src/ext/Sql/ca/scasql.cpp create mode 100644 src/ext/Sql/ca/scasqlstr.cpp create mode 100644 src/ext/Sql/ca/scasqlstr.h create mode 100644 src/ext/Sql/ca/scauser.cpp create mode 100644 src/ext/Sql/ca/scauser.h create mode 100644 src/ext/Sql/ca/sqlca.cpp create mode 100644 src/ext/Sql/ca/sqlca.def create mode 100644 src/ext/Sql/ca/sqlca.vcxproj create mode 100644 src/ext/Sql/nuget.config create mode 100644 src/ext/Sql/test/WixToolsetTest.Sql/SqlExtensionFixture.cs create mode 100644 src/ext/Sql/test/WixToolsetTest.Sql/TestData/UsingSql/Package.en-us.wxl create mode 100644 src/ext/Sql/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs create mode 100644 src/ext/Sql/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs create mode 100644 src/ext/Sql/test/WixToolsetTest.Sql/TestData/UsingSql/example.txt create mode 100644 src/ext/Sql/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj create mode 100644 src/ext/Sql/test/WixToolsetTest.Sql/WixToolsetTest.Sql.v3.ncrunchproject create mode 100644 src/ext/Sql/wix.snk create mode 100644 src/ext/Sql/wixext/SqlCompiler.cs create mode 100644 src/ext/Sql/wixext/SqlDecompiler.cs create mode 100644 src/ext/Sql/wixext/SqlErrors.cs create mode 100644 src/ext/Sql/wixext/SqlExtensionData.cs create mode 100644 src/ext/Sql/wixext/SqlExtensionFactory.cs create mode 100644 src/ext/Sql/wixext/SqlTableDefinitions.cs create mode 100644 src/ext/Sql/wixext/SqlWindowsInstallerBackendExtension.cs create mode 100644 src/ext/Sql/wixext/Symbols/SqlDatabaseSymbol.cs create mode 100644 src/ext/Sql/wixext/Symbols/SqlFileSpecSymbol.cs create mode 100644 src/ext/Sql/wixext/Symbols/SqlScriptSymbol.cs create mode 100644 src/ext/Sql/wixext/Symbols/SqlStringSymbol.cs create mode 100644 src/ext/Sql/wixext/Symbols/SqlSymbolDefinitions.cs create mode 100644 src/ext/Sql/wixext/WixToolset.Sql.wixext.csproj create mode 100644 src/ext/Sql/wixext/WixToolset.Sql.wixext.nuspec create mode 100644 src/ext/Sql/wixext/WixToolset.Sql.wixext.targets create mode 100644 src/ext/Sql/wixlib/SqlExtension.wxi create mode 100644 src/ext/Sql/wixlib/SqlExtension.wxs create mode 100644 src/ext/Sql/wixlib/SqlExtension_arm64.wxs create mode 100644 src/ext/Sql/wixlib/SqlExtension_x64.wxs create mode 100644 src/ext/Sql/wixlib/SqlExtension_x86.wxs create mode 100644 src/ext/Sql/wixlib/caDecor.wxi create mode 100644 src/ext/Sql/wixlib/caerr.wxi create mode 100644 src/ext/Sql/wixlib/de-de.wxl create mode 100644 src/ext/Sql/wixlib/en-us.wxl create mode 100644 src/ext/Sql/wixlib/es-es.wxl create mode 100644 src/ext/Sql/wixlib/ja-jp.wxl create mode 100644 src/ext/Sql/wixlib/pl-pl.wxl create mode 100644 src/ext/Sql/wixlib/pt-br.wxl create mode 100644 src/ext/Sql/wixlib/pt-pt.wxl create mode 100644 src/ext/Sql/wixlib/sql.v3.ncrunchproject create mode 100644 src/ext/Sql/wixlib/sql.wixproj create mode 100644 src/ext/global.json delete mode 100644 src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs delete mode 100644 src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.en-us.wxl delete mode 100644 src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs delete mode 100644 src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs delete mode 100644 src/test/WixToolsetTest.Sql/TestData/UsingSql/example.txt delete mode 100644 src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj delete mode 100644 src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.v3.ncrunchproject create mode 100644 src/version.json delete mode 100644 src/wix.snk delete mode 100644 src/wixext/SqlCompiler.cs delete mode 100644 src/wixext/SqlDecompiler.cs delete mode 100644 src/wixext/SqlErrors.cs delete mode 100644 src/wixext/SqlExtensionData.cs delete mode 100644 src/wixext/SqlExtensionFactory.cs delete mode 100644 src/wixext/SqlTableDefinitions.cs delete mode 100644 src/wixext/SqlWindowsInstallerBackendExtension.cs delete mode 100644 src/wixext/Symbols/SqlDatabaseSymbol.cs delete mode 100644 src/wixext/Symbols/SqlFileSpecSymbol.cs delete mode 100644 src/wixext/Symbols/SqlScriptSymbol.cs delete mode 100644 src/wixext/Symbols/SqlStringSymbol.cs delete mode 100644 src/wixext/Symbols/SqlSymbolDefinitions.cs delete mode 100644 src/wixext/WixToolset.Sql.wixext.csproj delete mode 100644 src/wixext/WixToolset.Sql.wixext.nuspec delete mode 100644 src/wixext/WixToolset.Sql.wixext.targets delete mode 100644 src/wixlib/SqlExtension.wxi delete mode 100644 src/wixlib/SqlExtension.wxs delete mode 100644 src/wixlib/SqlExtension_arm64.wxs delete mode 100644 src/wixlib/SqlExtension_x64.wxs delete mode 100644 src/wixlib/SqlExtension_x86.wxs delete mode 100644 src/wixlib/caDecor.wxi delete mode 100644 src/wixlib/caerr.wxi delete mode 100644 src/wixlib/de-de.wxl delete mode 100644 src/wixlib/en-us.wxl delete mode 100644 src/wixlib/es-es.wxl delete mode 100644 src/wixlib/ja-jp.wxl delete mode 100644 src/wixlib/pl-pl.wxl delete mode 100644 src/wixlib/pt-br.wxl delete mode 100644 src/wixlib/pt-pt.wxl delete mode 100644 src/wixlib/sql.v3.ncrunchproject delete mode 100644 src/wixlib/sql.wixproj delete mode 100644 version.json (limited to 'src') diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 1d72e683..00000000 --- a/.editorconfig +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -# -# Do NOT modify this file. Update the canonical version in Home\repo-template\src\.editorconfig -# then update all of the repos. - -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true - -[*.{cs,vb}] -dotnet_sort_system_directives_first = true - -[*.cs] -csharp_indent_case_contents = true : error -csharp_indent_switch_labels = true : error -csharp_new_line_before_open_brace = all -csharp_prefer_braces = true : error -csharp_style_expression_bodied_methods = when_on_single_line : suggestion -csharp_style_expression_bodied_constructors = when_on_single_line : suggestion -csharp_style_expression_bodied_operators = when_on_single_line : suggestion -csharp_style_expression_bodied_properties = when_on_single_line : suggestion -csharp_style_expression_bodied_indexers = when_on_single_line : suggestion -csharp_style_expression_bodied_accessors = when_on_single_line : suggestion -csharp_style_var_elsewhere = true : suggestion -csharp_style_var_for_built_in_types = true : suggestion -csharp_style_var_when_type_is_apparent = true : suggestion -dotnet_style_qualification_for_event = true : error -dotnet_style_qualification_for_field = true : error -dotnet_style_qualification_for_method = true : error -dotnet_style_qualification_for_property = true : error - -[*.targets] -indent_size = 2 diff --git a/README.md b/README.md deleted file mode 100644 index 377c9032..00000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# Sql.wixext -WixToolset.Sql.wixext - Sql WiX Toolset Extension diff --git a/Sql.wixext.sln b/Sql.wixext.sln deleted file mode 100644 index cfa9ad4f..00000000 --- a/Sql.wixext.sln +++ /dev/null @@ -1,59 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30204.135 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlca", "src\ca\sqlca.vcxproj", "{4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}" -EndProject -Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "sql", "src\wixlib\sql.wixproj", "{9ACF1A20-D801-45CC-A463-F9D13E506AA3}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Sql.wixext", "src\wixext\WixToolset.Sql.wixext.csproj", "{0E05519A-0045-4AEC-BD0C-D9205FF1468F}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.Sql", "src\test\WixToolsetTest.Sql\WixToolsetTest.Sql.csproj", "{FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Debug|Any CPU.ActiveCfg = Debug|Win32 - {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Debug|Any CPU.Build.0 = Debug|Win32 - {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Debug|x86.ActiveCfg = Debug|Win32 - {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Debug|x86.Build.0 = Debug|Win32 - {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Release|Any CPU.ActiveCfg = Release|Win32 - {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Release|x86.ActiveCfg = Release|Win32 - {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Release|x86.Build.0 = Release|Win32 - {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Debug|Any CPU.ActiveCfg = Debug|x86 - {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Debug|Any CPU.Build.0 = Debug|x86 - {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Debug|x86.ActiveCfg = Debug|x86 - {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Debug|x86.Build.0 = Debug|x86 - {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Release|Any CPU.ActiveCfg = Release|x86 - {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Release|x86.ActiveCfg = Release|x86 - {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Release|x86.Build.0 = Release|x86 - {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Debug|x86.ActiveCfg = Debug|Any CPU - {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Debug|x86.Build.0 = Debug|Any CPU - {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Release|Any CPU.Build.0 = Release|Any CPU - {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Release|x86.ActiveCfg = Release|Any CPU - {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Release|x86.Build.0 = Release|Any CPU - {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Debug|x86.ActiveCfg = Debug|Any CPU - {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Debug|x86.Build.0 = Debug|Any CPU - {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Release|Any CPU.Build.0 = Release|Any CPU - {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Release|x86.ActiveCfg = Release|Any CPU - {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Release|x86.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {DEFEE3BB-E557-4B77-A85C-ECA19D6F5DF5} - EndGlobalSection -EndGlobal diff --git a/appveyor.cmd b/appveyor.cmd deleted file mode 100644 index f21449d2..00000000 --- a/appveyor.cmd +++ /dev/null @@ -1,19 +0,0 @@ -@setlocal -@pushd %~dp0 -@set _C=Release -@if /i "%1"=="debug" set _C=Debug - -:: Restore -msbuild -p:Configuration=%_C% -t:Restore || exit /b - -:: Build -msbuild -p:Configuration=%_C% src\test\WixToolsetTest.Sql\WixToolsetTest.Sql.csproj || exit /b - -:: Test -dotnet test -c %_C% --no-build src\test\WixToolsetTest.Sql || exit /b - -:: Pack -msbuild -p:Configuration=%_C% -p:NoBuild=true -t:Pack src\wixext\WixToolset.Sql.wixext.csproj || exit /b - -@popd -@endlocal diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 7c686b04..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -# -# Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml -# then update all of the repos. - -branches: - only: - - master - - develop - -image: Visual Studio 2019 - -version: 0.0.0.{build} -configuration: Release - -environment: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - DOTNET_CLI_TELEMETRY_OPTOUT: 1 - NUGET_XMLDOC_MODE: skip - -build_script: - - appveyor.cmd - -pull_requests: - do_not_increment_build_number: true - -nuget: - disable_publish_on_pr: true - -skip_branch_with_pr: true -skip_tags: true - -artifacts: -- path: build\Release\**\*.nupkg - name: nuget - -notifications: -- provider: Slack - incoming_webhook: - secure: p5xuu+4x2JHfwGDMDe5KcG1k7gZxqYc4jWVwvyNZv5cvkubPD2waJs5yXMAXZNN7Z63/3PWHb7q4KoY/99AjauYa1nZ4c5qYqRPFRBKTHfA= diff --git a/global.json b/global.json deleted file mode 100644 index 23dd3fa6..00000000 --- a/global.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "msbuild-sdks": { - "WixToolset.Sdk": "4.0.0-build-0211" - } -} diff --git a/nuget.config b/nuget.config deleted file mode 100644 index db7aba29..00000000 --- a/nuget.config +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/.editorconfig b/src/.editorconfig new file mode 100644 index 00000000..1d72e683 --- /dev/null +++ b/src/.editorconfig @@ -0,0 +1,37 @@ +# Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\.editorconfig +# then update all of the repos. + +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.{cs,vb}] +dotnet_sort_system_directives_first = true + +[*.cs] +csharp_indent_case_contents = true : error +csharp_indent_switch_labels = true : error +csharp_new_line_before_open_brace = all +csharp_prefer_braces = true : error +csharp_style_expression_bodied_methods = when_on_single_line : suggestion +csharp_style_expression_bodied_constructors = when_on_single_line : suggestion +csharp_style_expression_bodied_operators = when_on_single_line : suggestion +csharp_style_expression_bodied_properties = when_on_single_line : suggestion +csharp_style_expression_bodied_indexers = when_on_single_line : suggestion +csharp_style_expression_bodied_accessors = when_on_single_line : suggestion +csharp_style_var_elsewhere = true : suggestion +csharp_style_var_for_built_in_types = true : suggestion +csharp_style_var_when_type_is_apparent = true : suggestion +dotnet_style_qualification_for_event = true : error +dotnet_style_qualification_for_field = true : error +dotnet_style_qualification_for_method = true : error +dotnet_style_qualification_for_property = true : error + +[*.targets] +indent_size = 2 diff --git a/src/Directory.Build.props b/src/Directory.Build.props deleted file mode 100644 index b3c6287c..00000000 --- a/src/Directory.Build.props +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - Debug - false - MSB3246 - - $(MSBuildProjectName) - $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) - $(BaseOutputPath)obj\$(ProjectName)\ - $(BaseOutputPath)$(Configuration)\ - - WiX Toolset Team - WiX Toolset - Copyright (c) .NET Foundation and contributors. All rights reserved. - MS-RL - WiX Toolset - - - - - diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets deleted file mode 100644 index 2fcc765a..00000000 --- a/src/Directory.Build.targets +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - true - $(SolutionPath) - $(NCrunchOriginalSolutionPath) - - - - - - - $([System.IO.File]::ReadAllText($(TheSolutionPath))) - $([System.IO.Path]::GetDirectoryName( $(TheSolutionPath) )) - (?<="[PackageName]", ")(.*)(?=", ") - - - - - - %(Identity) - $(SolutionFileContent.Contains('\%(Identity).csproj')) - - - - - $(RegexPattern.Replace('[PackageName]','%(PackageName)') ) - $([System.Text.RegularExpressions.Regex]::Match('$(SolutionFileContent)', '%(Pattern)')) - - - - - - - - - - - - - - diff --git a/src/Directory.csproj.props b/src/Directory.csproj.props deleted file mode 100644 index 81d24ad1..00000000 --- a/src/Directory.csproj.props +++ /dev/null @@ -1,13 +0,0 @@ - - - - - true - true - $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) - false - - diff --git a/src/Directory.csproj.targets b/src/Directory.csproj.targets deleted file mode 100644 index c3270426..00000000 --- a/src/Directory.csproj.targets +++ /dev/null @@ -1,26 +0,0 @@ - - - - - false - $(OutputPath)\$(AssemblyName).xml - - - - - $(PrivateRepositoryUrl.Replace('.git','')) - - $(MSBuildProjectName).nuspec - $(OutputPath)..\ - $(NuspecProperties);Id=$(PackageId);Authors=$(Authors);Copyright=$(Copyright);Description=$(Description);Title=$(Title) - $(NuspecProperties);Version=$(PackageVersion);RepositoryCommit=$(SourceRevisionId);RepositoryType=$(RepositoryType);RepositoryUrl=$(PrivateRepositoryUrl);ProjectFolder=$(MSBuildProjectDirectory)\;ProjectUrl=$(ProjectUrl) - true - snupkg - - - - diff --git a/src/Directory.vcxproj.props b/src/Directory.vcxproj.props deleted file mode 100644 index bcf26c57..00000000 --- a/src/Directory.vcxproj.props +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - Win32 - $(BaseIntermediateOutputPath)$(Configuration)\$(Platform)\ - $(OutputPath)$(Platform)\ - - - $(Company) - $(Copyright) - - win-x86;win-x64;win-arm64 - native,Version=v0.0 - - - - $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) - - - - - $(DisableSpecificCompilerWarnings) - Level4 - $(ProjectDir)inc;$(MSBuildProjectDirectory);$(IntDir);$(SqlCESdkIncludePath);$(ProjectAdditionalIncludeDirectories);%(AdditionalIncludeDirectories) - WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) - Use - precomp.h - StdCall - true - false - -YlprecompDefine - /Zc:threadSafeInit- %(AdditionalOptions) - true - - - $(ArmPreprocessorDefinitions);%(PreprocessorDefinitions) - $(ProjectAdditionalResourceIncludeDirectories);%(AdditionalIncludeDirectories) - - - $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ProjectAdditionalLibraryDirectories);%(AdditionalLibraryDirectories) - - - $(ProjectSubSystem) - $(ProjectModuleDefinitionFile) - $(ResourceOnlyDll) - true - $(ProjectAdditionalLinkLibraries);advapi32.lib;comdlg32.lib;user32.lib;oleaut32.lib;gdi32.lib;shell32.lib;ole32.lib;version.lib;%(AdditionalDependencies) - $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ArmLibraryDirectories);$(ProjectAdditionalLinkLibraryDirectories);%(AdditionalLibraryDirectories) - /IGNORE:4099 %(AdditionalOptions) - - - - - - NoExtensions - - - - - CDecl - - - - - OldStyle - true - true - - - - - Disabled - EnableFastChecks - _DEBUG;DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebug - - - - - - MultiThreadedDebugDll - - - - - MinSpace - NDEBUG;%(PreprocessorDefinitions) - true - true - MultiThreaded - - - true - true - - - - - - MultiThreadedDll - - - - - $(LinkKeyFile) - $(LinkDelaySign) - - - diff --git a/src/ca/CustomMsiErrors.h b/src/ca/CustomMsiErrors.h deleted file mode 100644 index b568d01c..00000000 --- a/src/ca/CustomMsiErrors.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -#define msierrSQLFailedCreateDatabase 26201 -#define msierrSQLFailedDropDatabase 26202 -#define msierrSQLFailedConnectDatabase 26203 -#define msierrSQLFailedExecString 26204 -#define msierrSQLDatabaseAlreadyExists 26205 - -//Last available is 26250 \ No newline at end of file diff --git a/src/ca/caDecor.h b/src/ca/caDecor.h deleted file mode 100644 index da274650..00000000 --- a/src/ca/caDecor.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - - -#if defined(_M_ARM64) -#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_A64" -#elif defined(_M_AMD64) -#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_X64" -#elif defined(_M_ARM) -#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_ARM" -#else -#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_X86" -#endif diff --git a/src/ca/dllmain.cpp b/src/ca/dllmain.cpp deleted file mode 100644 index 35ae6d1c..00000000 --- a/src/ca/dllmain.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -#include "precomp.h" - -/******************************************************************** -DllMain - standard entry point for all WiX custom actions - -********************************************************************/ -extern "C" BOOL WINAPI DllMain( - IN HINSTANCE hInst, - IN ULONG ulReason, - IN LPVOID) -{ - switch(ulReason) - { - case DLL_PROCESS_ATTACH: - WcaGlobalInitialize(hInst); - break; - - case DLL_PROCESS_DETACH: - WcaGlobalFinalize(); - break; - } - - return TRUE; -} diff --git a/src/ca/precomp.h b/src/ca/precomp.h deleted file mode 100644 index 266d543c..00000000 --- a/src/ca/precomp.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - - -#if _WIN32_MSI < 150 -#define _WIN32_MSI 150 -#endif - -#include -#include - -#include - -#define MAXUINT USHRT_MAX - -#include "wcautil.h" -#include "fileutil.h" -#include "memutil.h" -#include "strutil.h" -#include "wiutil.h" - -#include "CustomMsiErrors.h" - -#include "sca.h" -#include "scacost.h" -#include "scasqlstr.h" - -#include "caDecor.h" diff --git a/src/ca/sca.h b/src/ca/sca.h deleted file mode 100644 index bc36344e..00000000 --- a/src/ca/sca.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -// Generic action enum. -enum SCA_ACTION -{ - SCA_ACTION_NONE, - SCA_ACTION_INSTALL, - SCA_ACTION_UNINSTALL -}; - -// sql database attributes definitions -enum SCADB_ATTRIBUTES -{ - SCADB_CREATE_ON_INSTALL = 0x00000001, - SCADB_DROP_ON_UNINSTALL = 0x00000002, - SCADB_CONTINUE_ON_ERROR = 0x00000004, - SCADB_DROP_ON_INSTALL = 0x00000008, - SCADB_CREATE_ON_UNINSTALL = 0x00000010, - SCADB_CONFIRM_OVERWRITE = 0x00000020, - SCADB_CREATE_ON_REINSTALL = 0x00000040, - SCADB_DROP_ON_REINSTALL = 0x00000080, -}; - -// sql string/script attributes definitions -enum SCASQL_ATTRIBUTES -{ - SCASQL_EXECUTE_ON_INSTALL = 0x00000001, - SCASQL_EXECUTE_ON_UNINSTALL = 0x00000002, - SCASQL_CONTINUE_ON_ERROR = 0x00000004, - SCASQL_ROLLBACK = 0x00000008, - SCASQL_EXECUTE_ON_REINSTALL = 0x00000010, -}; diff --git a/src/ca/scacost.h b/src/ca/scacost.h deleted file mode 100644 index 6ea7e465..00000000 --- a/src/ca/scacost.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -const UINT COST_SQL_CREATEDB = 10000; -const UINT COST_SQL_DROPDB = 5000; -const UINT COST_SQL_CONNECTDB = 5000; -const UINT COST_SQL_STRING = 5000; diff --git a/src/ca/scadb.cpp b/src/ca/scadb.cpp deleted file mode 100644 index 288b9efe..00000000 --- a/src/ca/scadb.cpp +++ /dev/null @@ -1,588 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -#include "precomp.h" - -// sql queries -LPCWSTR vcsSqlDatabaseQuery = L"SELECT `SqlDb`, `Server`, `Instance`, `Database`, " - L"`Component_`, `User_`, `FileSpec_`, `FileSpec_Log`, `Attributes` " - L"FROM `Wix4SqlDatabase`"; -enum eSqlDatabaseQuery { sdqSqlDb = 1, sdqServer, sdqInstance, sdqDatabase, - sdqComponent, sdqUser, sdqDbFileSpec, sdqLogFileSpec, sdqAttributes }; - -LPCWSTR vcsSqlFileSpecQuery = L"SELECT `FileSpec`, `Name`, `Filename`, `Size`, " - L"`MaxSize`, `GrowthSize` FROM `Wix4SqlFileSpec` WHERE `FileSpec`=?"; -enum eSqlFileSpecQuery { sfsqFileSpec = 1, sfsqName, sfsqFilename, sfsqSize, - sfsqMaxSize, sfsqGrowth }; - - -// prototypes for private helper functions -static HRESULT NewDb( - __out SCA_DB** ppsd - ); - -static SCA_DB* AddDbToList( - __in SCA_DB* psdList, - __in SCA_DB* psd - ); - -static HRESULT SchedCreateDatabase( - __in SCA_DB* psd - ); - -static HRESULT SchedDropDatabase( - __in LPCWSTR wzKey, LPCWSTR wzServer, - __in LPCWSTR wzInstance, - __in LPCWSTR wzDatabase, - __in int iAttributes, - __in BOOL fIntegratedAuth, - __in LPCWSTR wzUser, - __in LPCWSTR wzPassword - ); - -static HRESULT GetFileSpec( - __in MSIHANDLE hViewFileSpec, - __in LPCWSTR wzKey, - __in SQL_FILESPEC* psf - ); - - -HRESULT ScaDbsRead( - __inout SCA_DB** ppsdList, - __in SCA_ACTION saAction - ) -{ - HRESULT hr = S_OK; - UINT er = ERROR_SUCCESS; - PMSIHANDLE hView; - PMSIHANDLE hRec; - PMSIHANDLE hViewFileSpec = NULL; - - LPWSTR pwzData = NULL; - LPWSTR pwzId = NULL; - LPWSTR pwzComponent = NULL; - - SCA_DB* psd = NULL; - - if (S_OK != WcaTableExists(L"Wix4SqlDatabase")) - { - WcaLog(LOGMSG_VERBOSE, "Skipping ScaCreateDatabase() - Wix4SqlDatabase table not present"); - ExitFunction1(hr = S_FALSE); - } - - if (S_OK == WcaTableExists(L"Wix4SqlFileSpec")) - { - hr = WcaOpenView(vcsSqlFileSpecQuery, &hViewFileSpec); - ExitOnFailure(hr, "failed to open view on Wix4SqlFileSpec table"); - } - - // loop through all the sql databases - hr = WcaOpenExecuteView(vcsSqlDatabaseQuery, &hView); - ExitOnFailure(hr, "Failed to open view on Wix4SqlDatabase table"); - while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) - { - BOOL fHasComponent = FALSE; - INSTALLSTATE isInstalled = INSTALLSTATE_UNKNOWN; - INSTALLSTATE isAction = INSTALLSTATE_UNKNOWN; - - hr = WcaGetRecordString(hRec, sdqSqlDb, &pwzId); - ExitOnFailure(hr, "Failed to get Wix4SqlDatabase.SqlDb"); - - hr = WcaGetRecordString(hRec, sdqComponent, &pwzComponent); - ExitOnFailure(hr, "Failed to get Component for database: '%ls'", psd->wzKey); - if (pwzComponent && *pwzComponent) - { - fHasComponent = TRUE; - - er = ::MsiGetComponentStateW(WcaGetInstallHandle(), pwzComponent, &isInstalled, &isAction); - hr = HRESULT_FROM_WIN32(er); - ExitOnFailure(hr, "Failed to get state for component: %ls", pwzComponent); - - // If we're doing install but the Component is not being installed or we're doing - // uninstall but the Component is not being uninstalled, skip it. - if ((WcaIsInstalling(isInstalled, isAction) && SCA_ACTION_INSTALL != saAction) || - (WcaIsUninstalling(isInstalled, isAction) && SCA_ACTION_UNINSTALL != saAction)) - { - continue; - } - } - - hr = NewDb(&psd); - ExitOnFailure(hr, "Failed to allocate memory for new database: %D", pwzId); - - hr = ::StringCchCopyW(psd->wzKey, countof(psd->wzKey), pwzId); - ExitOnFailure(hr, "Failed to copy Wix4SqlDatabase.SqlDbL: %ls", pwzId); - - hr = ::StringCchCopyW(psd->wzComponent, countof(psd->wzComponent), pwzComponent); - ExitOnFailure(hr, "Failed to copy Wix4SqlDatabase.Component_: %ls", pwzComponent); - - psd->fHasComponent = fHasComponent; - psd->isInstalled = isInstalled; - psd->isAction = isAction; - - hr = WcaGetRecordFormattedString(hRec, sdqServer, &pwzData); - ExitOnFailure(hr, "Failed to get Server for database: '%ls'", psd->wzKey); - hr = ::StringCchCopyW(psd->wzServer, countof(psd->wzServer), pwzData); - ExitOnFailure(hr, "Failed to copy server string to database object:%ls", pwzData); - - hr = WcaGetRecordFormattedString(hRec, sdqInstance, &pwzData); - ExitOnFailure(hr, "Failed to get Instance for database: '%ls'", psd->wzKey); - hr = ::StringCchCopyW(psd->wzInstance, countof(psd->wzInstance), pwzData); - ExitOnFailure(hr, "Failed to copy instance string to database object:%ls", pwzData); - - hr = WcaGetRecordFormattedString(hRec, sdqDatabase, &pwzData); - ExitOnFailure(hr, "Failed to get Database for database: '%ls'", psd->wzKey); - hr = ::StringCchCopyW(psd->wzDatabase, countof(psd->wzDatabase), pwzData); - ExitOnFailure(hr, "Failed to copy database string to database object:%ls", pwzData); - - hr = WcaGetRecordInteger(hRec, sdqAttributes, &psd->iAttributes); - ExitOnFailure(hr, "Failed to get Wix4SqlDatabase.Attributes"); - - hr = WcaGetRecordFormattedString(hRec, sdqUser, &pwzData); - ExitOnFailure(hr, "Failed to get User record for database: '%ls'", psd->wzKey); - - // if a user was specified - if (*pwzData) - { - psd->fUseIntegratedAuth = FALSE; - hr = ScaGetUser(pwzData, &psd->scau); - ExitOnFailure(hr, "Failed to get user information for database: '%ls'", psd->wzKey); - } - else - { - psd->fUseIntegratedAuth = TRUE; - // integrated authorization doesn't have a User record - } - - hr = WcaGetRecordString(hRec, sdqDbFileSpec, &pwzData); - ExitOnFailure(hr, "Failed to get Database FileSpec for database: '%ls'", psd->wzKey); - - // if a database filespec was specified - if (*pwzData) - { - hr = GetFileSpec(hViewFileSpec, pwzData, &psd->sfDb); - ExitOnFailure(hr, "failed to get FileSpec for: %ls", pwzData); - if (S_OK == hr) - { - psd->fHasDbSpec = TRUE; - } - } - - hr = WcaGetRecordString(hRec, sdqLogFileSpec, &pwzData); - ExitOnFailure(hr, "Failed to get Log FileSpec for database: '%ls'", psd->wzKey); - - // if a log filespec was specified - if (*pwzData) - { - hr = GetFileSpec(hViewFileSpec, pwzData, &psd->sfLog); - ExitOnFailure(hr, "failed to get FileSpec for: %ls", pwzData); - if (S_OK == hr) - { - psd->fHasLogSpec = TRUE; - } - } - - *ppsdList = AddDbToList(*ppsdList, psd); - psd = NULL; // set the db NULL so it doesn't accidentally get freed below - } - - if (E_NOMOREITEMS == hr) - { - hr = S_OK; - } - ExitOnFailure(hr, "Failure occured while processing Wix4SqlDatabase table"); - -LExit: - if (psd) - { - ScaDbsFreeList(psd); - } - - ReleaseStr(pwzComponent); - ReleaseStr(pwzId); - ReleaseStr(pwzData); - return hr; -} - - -SCA_DB* ScaDbsFindDatabase( - __in LPCWSTR wzSqlDb, - __in SCA_DB* psdList - ) -{ - SCA_DB* psd = NULL; - - for (psd = psdList; psd; psd = psd->psdNext) - { - if (0 == lstrcmpW(wzSqlDb, psd->wzKey)) - { - break; - } - } - - return psd; -} - - -HRESULT ScaDbsInstall( - __in SCA_DB* psdList - ) -{ - HRESULT hr = S_FALSE; // assume nothing will be done - SCA_DB* psd = NULL; - - for (psd = psdList; psd; psd = psd->psdNext) - { - if (psd->fHasComponent) - { - // if we need to drop, do that first - if (((psd->iAttributes & SCADB_DROP_ON_INSTALL) && WcaIsInstalling(psd->isInstalled, psd->isAction) && !WcaIsReInstalling(psd->isInstalled, psd->isAction)) || - ((psd->iAttributes & SCADB_DROP_ON_REINSTALL) && WcaIsReInstalling(psd->isInstalled, psd->isAction))) - { - hr = SchedDropDatabase(psd->wzKey, psd->wzServer, psd->wzInstance, psd->wzDatabase, psd->iAttributes, psd->fUseIntegratedAuth, psd->scau.wzName, psd->scau.wzPassword); - ExitOnFailure(hr, "Failed to drop database %ls", psd->wzKey); - } - - // if installing this component - if (((psd->iAttributes & SCADB_CREATE_ON_INSTALL) && WcaIsInstalling(psd->isInstalled, psd->isAction) && !WcaIsReInstalling(psd->isInstalled, psd->isAction)) || - ((psd->iAttributes & SCADB_CREATE_ON_REINSTALL) && WcaIsReInstalling(psd->isInstalled, psd->isAction))) - { - hr = SchedCreateDatabase(psd); - ExitOnFailure(hr, "Failed to ensure database %ls exists", psd->wzKey); - } - } - } - -LExit: - return hr; -} - - -HRESULT ScaDbsUninstall( - __in SCA_DB* psdList - ) -{ - HRESULT hr = S_FALSE; // assume nothing will be done - SCA_DB* psd = NULL; - - for (psd = psdList; psd; psd = psd->psdNext) - { - if (psd->fHasComponent) - { - // if we need to drop do that first - if ((psd->iAttributes & SCADB_DROP_ON_UNINSTALL) && WcaIsUninstalling(psd->isInstalled, psd->isAction)) - { - hr = SchedDropDatabase(psd->wzKey, psd->wzServer, psd->wzInstance, psd->wzDatabase, psd->iAttributes, psd->fUseIntegratedAuth, psd->scau.wzName, psd->scau.wzPassword); - ExitOnFailure(hr, "Failed to drop database %ls", psd->wzKey); - } - - // install the db - if ((psd->iAttributes & SCADB_CREATE_ON_UNINSTALL) && WcaIsUninstalling(psd->isInstalled, psd->isAction)) - { - hr = SchedCreateDatabase(psd); - ExitOnFailure(hr, "Failed to ensure database %ls exists", psd->wzKey); - } - } - } - -LExit: - return hr; -} - - -void ScaDbsFreeList( - __in SCA_DB* psdList - ) -{ - SCA_DB* psdDelete = psdList; - while (psdList) - { - psdDelete = psdList; - psdList = psdList->psdNext; - - MemFree(psdDelete); - } -} - - -// private helper functions - -static HRESULT NewDb( - __out SCA_DB** ppsd - ) -{ - HRESULT hr = S_OK; - SCA_DB* psd = static_cast(MemAlloc(sizeof(SCA_DB), TRUE)); - ExitOnNull(psd, hr, E_OUTOFMEMORY, "failed to allocate memory for new database element"); - - *ppsd = psd; - -LExit: - return hr; -} - - -static SCA_DB* AddDbToList( - __in SCA_DB* psdList, - __in SCA_DB* psd - ) -{ - if (psdList) - { - SCA_DB* psdT = psdList; - while (psdT->psdNext) - { - psdT = psdT->psdNext; - } - - psdT->psdNext = psd; - } - else - { - psdList = psd; - } - - return psdList; -} - - -static HRESULT SchedCreateDatabase( - __in SCA_DB* psd - ) -{ - HRESULT hr = S_OK; - WCHAR* pwzCustomActionData = NULL; - - hr = WcaWriteStringToCaData(psd->wzKey, &pwzCustomActionData); - ExitOnFailure(hr, "failed to add DBKey to CustomActionData"); - - hr = WcaWriteStringToCaData(psd->wzServer, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add server name to CustomActionData"); - - hr = WcaWriteStringToCaData(psd->wzInstance, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add server instance to CustomActionData"); - - hr = WcaWriteStringToCaData(psd->wzDatabase, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add database name to CustomActionData"); - - hr = WcaWriteIntegerToCaData(psd->iAttributes, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add Sql attributes to CustomActionData"); - - hr = WcaWriteStringToCaData(psd->fUseIntegratedAuth ? L"1" : L"0", &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add if integrated connection to CustomActionData"); - - hr = WcaWriteStringToCaData(psd->scau.wzName, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add server user to CustomActionData"); - - hr = WcaWriteStringToCaData(psd->scau.wzPassword, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add user password to CustomActionData"); - - // Check to see if the database exists, if it does not then schedule a rollback - // so we clean up after ourselves if the creation of the database fails or is - // aborted. It is interesting to note that we can do this check here because the - // deferred CustomActions are Impersonated. That means this scheduling action and - // the execution actions all run with the same user context, so it is safe to - // to do the check. - hr = SqlDatabaseExists(psd->wzServer, psd->wzInstance, psd->wzDatabase, psd->fUseIntegratedAuth, psd->scau.wzName, psd->scau.wzPassword, NULL); - if (S_FALSE == hr) - { - hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"RollbackCreateDatabase"), pwzCustomActionData, COST_SQL_CREATEDB); - ExitOnFailure(hr, "Failed to schedule RollbackCreateDatabase action"); - } - - // database filespec - if (psd->fHasDbSpec) - { - hr = WcaWriteStringToCaData(L"1", &pwzCustomActionData); - ExitOnFailure(hr, "failed to specify that do have db.filespec to CustomActionData"); - - hr = WcaWriteStringToCaData(psd->sfDb.wzName, &pwzCustomActionData); - ExitOnFailure(hr, "failed to add FileSpec.Name to CustomActionData"); - - hr = WcaWriteStringToCaData(psd->sfDb.wzFilename, &pwzCustomActionData); - ExitOnFailure(hr, "failed to add FileSpec.Filename to CustomActionData"); - - hr = WcaWriteStringToCaData(psd->sfDb.wzSize, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add FileSpec.Size to CustomActionData"); - - hr = WcaWriteStringToCaData(psd->sfDb.wzMaxSize, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add FileSpec.MaxSize to CustomActionData"); - - hr = WcaWriteStringToCaData(psd->sfDb.wzGrow, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add FileSpec.GrowthSize to CustomActionData"); - } - else - { - hr = WcaWriteStringToCaData(L"0", &pwzCustomActionData); - ExitOnFailure(hr, "failed to specify that do not have db.filespec to CustomActionData"); - } - - // log filespec - if (psd->fHasLogSpec) - { - hr = WcaWriteStringToCaData(L"1", &pwzCustomActionData); - ExitOnFailure(hr, "failed to specify that do have log.filespec to CustomActionData"); - - hr = WcaWriteStringToCaData(psd->sfLog.wzName, &pwzCustomActionData); - ExitOnFailure(hr, "failed to add FileSpec.Name to CustomActionData"); - - hr = WcaWriteStringToCaData(psd->sfLog.wzFilename, &pwzCustomActionData); - ExitOnFailure(hr, "failed to add FileSpec.Filename to CustomActionData"); - - hr = WcaWriteStringToCaData(psd->sfLog.wzSize, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add FileSpec.Size to CustomActionData"); - - hr = WcaWriteStringToCaData(psd->sfLog.wzMaxSize, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add FileSpec.MaxSize to CustomActionData"); - - hr = WcaWriteStringToCaData(psd->sfLog.wzGrow, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add FileSpec.GrowthSize to CustomActionData"); - } - else - { - hr = WcaWriteStringToCaData(L"0", &pwzCustomActionData); - ExitOnFailure(hr, "failed to specify that do not have log.filespec to CustomActionData"); - } - - // schedule the CreateDatabase action - hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"CreateDatabase"), pwzCustomActionData, COST_SQL_CREATEDB); - ExitOnFailure(hr, "Failed to schedule CreateDatabase action"); - -LExit: - ReleaseStr(pwzCustomActionData); - return hr; -} - - -HRESULT SchedDropDatabase( - __in LPCWSTR wzKey, - __in LPCWSTR wzServer, - __in LPCWSTR wzInstance, - __in LPCWSTR wzDatabase, - __in int iAttributes, - __in BOOL fIntegratedAuth, - __in LPCWSTR wzUser, - __in LPCWSTR wzPassword - ) -{ - HRESULT hr = S_OK; - WCHAR* pwzCustomActionData = NULL; - - hr = WcaWriteStringToCaData(wzKey, &pwzCustomActionData); - ExitOnFailure(hr, "failed to add DBKey to CustomActionData"); - - hr = WcaWriteStringToCaData(wzServer, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add server name to CustomActionData"); - - hr = WcaWriteStringToCaData(wzInstance, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add server instance to CustomActionData"); - - hr = WcaWriteStringToCaData(wzDatabase, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add database name to CustomActionData"); - - hr = WcaWriteIntegerToCaData(iAttributes, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add server name to CustomActionData"); - - hr = WcaWriteStringToCaData(fIntegratedAuth ? L"1" : L"0", &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add server name to CustomActionData"); - - hr = WcaWriteStringToCaData(wzUser, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add server user to CustomActionData"); - - hr = WcaWriteStringToCaData(wzPassword, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add user password to CustomActionData"); - - hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"DropDatabase"), pwzCustomActionData, COST_SQL_DROPDB); - ExitOnFailure(hr, "Failed to schedule DropDatabase action"); - -LExit: - ReleaseStr(pwzCustomActionData); - return hr; -} - - -HRESULT GetFileSpec( - __in MSIHANDLE hViewFileSpec, - __in LPCWSTR wzKey, - __in SQL_FILESPEC* psf - ) -{ - HRESULT hr = S_OK; - PMSIHANDLE hRecFileSpec, hRec; - LPWSTR pwzData = NULL; - - // create a record to do the fetch - hRecFileSpec = ::MsiCreateRecord(1); - if (!hRecFileSpec) - { - ExitOnFailure(hr = E_UNEXPECTED, "failed to create record for filespec: %ls", wzKey); - } - hr = WcaSetRecordString(hRecFileSpec, 1, wzKey); - ExitOnFailure(hr, "failed to set record string for filespec: %ls", wzKey); - - // get the FileSpec record - hr = WcaExecuteView(hViewFileSpec, hRecFileSpec); - ExitOnFailure(hr, "failed to execute view on Wix4SqlFileSpec table for filespec: %ls", wzKey); - hr = WcaFetchSingleRecord(hViewFileSpec, &hRec); - ExitOnFailure(hr, "failed to get record for filespec: %ls", wzKey); - - // read the data out of the filespec record - hr = WcaGetRecordFormattedString(hRec, sfsqName, &pwzData); - ExitOnFailure(hr, "Failed to get Wix4SqlFileSpec.Name for filespec: %ls", wzKey); - hr = ::StringCchCopyW(psf->wzName, countof(psf->wzName), pwzData); - ExitOnFailure(hr, "Failed to copy Wix4SqlFileSpec.Name string: %ls", pwzData); - - hr = WcaGetRecordFormattedString(hRec, sfsqFilename, &pwzData); - ExitOnFailure(hr, "Failed to get Wix4SqlFileSpec.Filename for filespec: %ls", wzKey); - if (*pwzData) - { - hr = ::StringCchCopyW(psf->wzFilename, countof(psf->wzFilename), pwzData); - ExitOnFailure(hr, "Failed to copy filename to filespec object: %ls", pwzData); - } - else // if there is no file, skip this FILESPEC - { - WcaLog(LOGMSG_VERBOSE, "No filename specified, skipping FileSpec: %ls", psf->wzName); - ExitFunction1(hr = S_FALSE); - } - - hr = WcaGetRecordFormattedString(hRec, sfsqSize, &pwzData); - ExitOnFailure(hr, "Failed to get Wix4SqlFileSpec.Size for filespec: %ls", wzKey); - if (*pwzData) - { - hr = ::StringCchCopyW(psf->wzSize, countof(psf->wzSize), pwzData); - ExitOnFailure(hr, "Failed to copy size to filespec object: %ls", pwzData); - } - else - { - psf->wzSize[0] = 0; - } - - hr = WcaGetRecordFormattedString(hRec, sfsqMaxSize, &pwzData); - ExitOnFailure(hr, "Failed to get Wix4SqlFileSpec.MaxSize for filespec: %ls", wzKey); - if (*pwzData) - { - hr = ::StringCchCopyW(psf->wzMaxSize, countof(psf->wzMaxSize), pwzData); - ExitOnFailure(hr, "Failed to copy max size to filespec object: %ls", pwzData); - } - else - { - psf->wzMaxSize[0] = 0; - } - - hr = WcaGetRecordFormattedString(hRec, sfsqGrowth, &pwzData); - ExitOnFailure(hr, "Failed to get Wix4SqlFileSpec.GrowthSize for filespec: %ls", wzKey); - if (*pwzData) - { - hr = ::StringCchCopyW(psf->wzGrow, countof(psf->wzGrow), pwzData); - ExitOnFailure(hr, "Failed to copy growth size to filespec object: %ls", pwzData); - } - else - { - psf->wzGrow[0] = 0; - } - - hr = S_OK; - -LExit: - ReleaseStr(pwzData); - return hr; -} diff --git a/src/ca/scadb.h b/src/ca/scadb.h deleted file mode 100644 index 885e84c2..00000000 --- a/src/ca/scadb.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - - -#include "scauser.h" -#include "sqlutil.h" - -struct SCA_DB -{ - // darwin information - WCHAR wzKey[MAX_DARWIN_KEY + 1]; - BOOL fHasComponent; - WCHAR wzComponent[MAX_DARWIN_KEY + 1]; - INSTALLSTATE isInstalled, isAction; - - WCHAR wzServer[MAX_DARWIN_COLUMN + 1]; - WCHAR wzInstance[MAX_DARWIN_COLUMN + 1]; - WCHAR wzDatabase[MAX_DARWIN_COLUMN + 1]; - - int iAttributes; - - BOOL fUseIntegratedAuth; - SCA_USER scau; - - BOOL fHasDbSpec; - SQL_FILESPEC sfDb; - BOOL fHasLogSpec; - SQL_FILESPEC sfLog; - - SCA_DB* psdNext; -}; - - -// prototypes -HRESULT ScaDbsRead( - __inout SCA_DB** ppsdList, - __in SCA_ACTION saAction - ); - -SCA_DB* ScaDbsFindDatabase( - __in LPCWSTR wzSqlDb, - __in SCA_DB* psdList - ); - -HRESULT ScaDbsInstall( - __in SCA_DB* psdList - ); - -HRESULT ScaDbsUninstall( - __in SCA_DB* psdList - ); - -void ScaDbsFreeList( - __in SCA_DB* psdList - ); diff --git a/src/ca/scaexec.cpp b/src/ca/scaexec.cpp deleted file mode 100644 index b2648361..00000000 --- a/src/ca/scaexec.cpp +++ /dev/null @@ -1,393 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -#include "precomp.h" - - -/******************************************************************** - * CreateDatabase - CUSTOM ACTION ENTRY POINT for creating databases - * - * Input: deferred CustomActionData - DbKey\tServer\tInstance\tDatabase\tAttributes\tIntegratedAuth\tUser\tPassword - * ****************************************************************/ -extern "C" UINT __stdcall CreateDatabase(MSIHANDLE hInstall) -{ -//AssertSz(FALSE, "debug CreateDatabase here"); - UINT er = ERROR_SUCCESS; - HRESULT hr = S_OK; - - LPWSTR pwzData = NULL; - IDBCreateSession* pidbSession = NULL; - BSTR bstrErrorDescription = NULL; - LPWSTR pwz = NULL; - LPWSTR pwzDatabaseKey = NULL; - LPWSTR pwzServer = NULL; - LPWSTR pwzInstance = NULL; - LPWSTR pwzDatabase = NULL; - LPWSTR pwzTemp = NULL; - int iAttributes; - BOOL fIntegratedAuth; - LPWSTR pwzUser = NULL; - LPWSTR pwzPassword = NULL; - BOOL fHaveDbFileSpec = FALSE; - SQL_FILESPEC sfDb; - BOOL fHaveLogFileSpec = FALSE; - SQL_FILESPEC sfLog; - BOOL fInitializedCom = FALSE; - - memset(&sfDb, 0, sizeof(sfDb)); - memset(&sfLog, 0, sizeof(sfLog)); - - hr = WcaInitialize(hInstall, "CreateDatabase"); - ExitOnFailure(hr, "failed to initialize"); - - hr = ::CoInitialize(NULL); - ExitOnFailure(hr, "failed to intialize COM"); - fInitializedCom = TRUE; - - hr = WcaGetProperty( L"CustomActionData", &pwzData); - ExitOnFailure(hr, "failed to get CustomActionData"); - - WcaLog(LOGMSG_TRACEONLY, "CustomActionData: %ls", pwzData); - - pwz = pwzData; - hr = WcaReadStringFromCaData(&pwz, &pwzDatabaseKey); // SQL Server - ExitOnFailure(hr, "failed to read database key from custom action data: %ls", pwz); - hr = WcaReadStringFromCaData(&pwz, &pwzServer); // SQL Server - ExitOnFailure(hr, "failed to read server from custom action data: %ls", pwz); - hr = WcaReadStringFromCaData(&pwz, &pwzInstance); // SQL Server Instance - ExitOnFailure(hr, "failed to read server instance from custom action data: %ls", pwz); - hr = WcaReadStringFromCaData(&pwz, &pwzDatabase); // SQL Database - ExitOnFailure(hr, "failed to read server instance from custom action data: %ls", pwz); - hr = WcaReadIntegerFromCaData(&pwz, &iAttributes); - ExitOnFailure(hr, "failed to read attributes from custom action data: %ls", pwz); - hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast(&fIntegratedAuth)); // Integrated Windows Authentication? - ExitOnFailure(hr, "failed to read integrated auth flag from custom action data: %ls", pwz); - hr = WcaReadStringFromCaData(&pwz, &pwzUser); // SQL User - ExitOnFailure(hr, "failed to read user from custom action data: %ls", pwz); - hr = WcaReadStringFromCaData(&pwz, &pwzPassword); // SQL User Password - ExitOnFailure(hr, "failed to read user from custom action data: %ls", pwz); - - // db file spec - hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast(&fHaveDbFileSpec)); - ExitOnFailure(hr, "failed to read db file spec from custom action data: %ls", pwz); - - if (fHaveDbFileSpec) - { - hr = WcaReadStringFromCaData(&pwz, &pwzTemp); - ExitOnFailure(hr, "failed to read db file spec name from custom action data: %ls", pwz); - hr = ::StringCchCopyW(sfDb.wzName, countof(sfDb.wzName), pwzTemp); - ExitOnFailure(hr, "failed to copy db file spec name: %ls", pwzTemp); - - hr = WcaReadStringFromCaData(&pwz, &pwzTemp); - ExitOnFailure(hr, "failed to read db file spec filename from custom action data: %ls", pwz); - hr = ::StringCchCopyW(sfDb.wzFilename, countof(sfDb.wzFilename), pwzTemp); - ExitOnFailure(hr, "failed to copy db file spec filename: %ls", pwzTemp); - - hr = WcaReadStringFromCaData(&pwz, &pwzTemp); - ExitOnFailure(hr, "failed to read db file spec size from custom action data: %ls", pwz); - hr = ::StringCchCopyW(sfDb.wzSize, countof(sfDb.wzSize), pwzTemp); - ExitOnFailure(hr, "failed to copy db file spec size value: %ls", pwzTemp); - - hr = WcaReadStringFromCaData(&pwz, &pwzTemp); - ExitOnFailure(hr, "failed to read db file spec max size from custom action data: %ls", pwz); - hr = ::StringCchCopyW(sfDb.wzMaxSize, countof(sfDb.wzMaxSize), pwzTemp); - ExitOnFailure(hr, "failed to copy db file spec max size: %ls", pwzTemp); - - hr = WcaReadStringFromCaData(&pwz, &pwzTemp); - ExitOnFailure(hr, "failed to read db file spec grow from custom action data: %ls", pwz); - hr = ::StringCchCopyW(sfDb.wzGrow, countof(sfDb.wzGrow), pwzTemp); - ExitOnFailure(hr, "failed to copy db file spec grow value: %ls", pwzTemp); - } - - // log file spec - hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast(&fHaveLogFileSpec)); - ExitOnFailure(hr, "failed to read log file spec from custom action data: %ls", pwz); - if (fHaveLogFileSpec) - { - hr = WcaReadStringFromCaData(&pwz, &pwzTemp); - ExitOnFailure(hr, "failed to read log file spec name from custom action data: %ls", pwz); - hr = ::StringCchCopyW(sfLog.wzName, countof(sfDb.wzName), pwzTemp); - ExitOnFailure(hr, "failed to copy log file spec name: %ls", pwzTemp); - - hr = WcaReadStringFromCaData(&pwz, &pwzTemp); - ExitOnFailure(hr, "failed to read log file spec filename from custom action data: %ls", pwz); - hr = ::StringCchCopyW(sfLog.wzFilename, countof(sfDb.wzFilename), pwzTemp); - ExitOnFailure(hr, "failed to copy log file spec filename: %ls", pwzTemp); - - hr = WcaReadStringFromCaData(&pwz, &pwzTemp); - ExitOnFailure(hr, "failed to read log file spec size from custom action data: %ls", pwz); - hr = ::StringCchCopyW(sfLog.wzSize, countof(sfDb.wzSize), pwzTemp); - ExitOnFailure(hr, "failed to copy log file spec size value: %ls", pwzTemp); - - hr = WcaReadStringFromCaData(&pwz, &pwzTemp); - ExitOnFailure(hr, "failed to read log file spec max size from custom action data: %ls", pwz); - hr = ::StringCchCopyW(sfLog.wzMaxSize, countof(sfDb.wzMaxSize), pwzTemp); - ExitOnFailure(hr, "failed to copy log file spec max size: %ls", pwzTemp); - - hr = WcaReadStringFromCaData(&pwz, &pwzTemp); - ExitOnFailure(hr, "failed to read log file spec grow from custom action data: %ls", pwz); - hr = ::StringCchCopyW(sfLog.wzGrow, countof(sfDb.wzGrow), pwzTemp); - ExitOnFailure(hr, "failed to copy log file spec grow value: %ls", pwzTemp); - } - - if (iAttributes & SCADB_CONFIRM_OVERWRITE) - { - // Check if the database already exists - hr = SqlDatabaseExists(pwzServer, pwzInstance, pwzDatabase, fIntegratedAuth, pwzUser, pwzPassword, &bstrErrorDescription); - MessageExitOnFailure(hr, msierrSQLFailedCreateDatabase, "failed to check if database exists: '%ls', error: %ls", pwzDatabase, NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription); - - if (S_OK == hr) // found an existing database, confirm that they don't want to stop before it gets trampled, in no UI case just continue anyways - { - hr = HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS); - if (IDNO == WcaErrorMessage(msierrSQLDatabaseAlreadyExists, hr, MB_YESNO, 1, pwzDatabase)) - ExitOnFailure(hr, "failed to initialize"); - } - } - - hr = SqlDatabaseEnsureExists(pwzServer, pwzInstance, pwzDatabase, fIntegratedAuth, pwzUser, pwzPassword, fHaveDbFileSpec ? &sfDb : NULL, fHaveLogFileSpec ? &sfLog : NULL, &bstrErrorDescription); - if ((iAttributes & SCADB_CONTINUE_ON_ERROR) && FAILED(hr)) - { - WcaLog(LOGMSG_STANDARD, "Error 0x%x: failed to create SQL database but continuing, error: %ls, Database: %ls", hr, NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription, pwzDatabase); - hr = S_OK; - } - MessageExitOnFailure(hr, msierrSQLFailedCreateDatabase, "failed to create to database: '%ls', error: %ls", pwzDatabase, NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription); - - hr = WcaProgressMessage(COST_SQL_CONNECTDB, FALSE); -LExit: - ReleaseStr(pwzDatabaseKey); - ReleaseStr(pwzServer); - ReleaseStr(pwzInstance); - ReleaseStr(pwzDatabase); - ReleaseStr(pwzUser); - ReleaseStr(pwzPassword); - ReleaseObject(pidbSession); - ReleaseBSTR(bstrErrorDescription); - - if (fInitializedCom) - { - ::CoUninitialize(); - } - - if (FAILED(hr)) - { - er = ERROR_INSTALL_FAILURE; - } - return WcaFinalize(er); -} - - -/******************************************************************** - DropDatabase - CUSTOM ACTION ENTRY POINT for removing databases - - Input: deferred CustomActionData - DbKey\tServer\tInstance\tDatabase\tAttributes\tIntegratedAuth\tUser\tPassword - * ****************************************************************/ -extern "C" UINT __stdcall DropDatabase(MSIHANDLE hInstall) -{ -//Assert(FALSE); - UINT er = ERROR_SUCCESS; - HRESULT hr = S_OK; - - LPWSTR pwzData = NULL; - IDBCreateSession* pidbSession = NULL; - BSTR bstrErrorDescription = NULL; - LPWSTR pwz = NULL; - LPWSTR pwzDatabaseKey = NULL; - LPWSTR pwzServer = NULL; - LPWSTR pwzInstance = NULL; - LPWSTR pwzDatabase = NULL; - long lAttributes; - BOOL fIntegratedAuth; - LPWSTR pwzUser = NULL; - LPWSTR pwzPassword = NULL; - BOOL fInitializedCom = TRUE; - - hr = WcaInitialize(hInstall, "DropDatabase"); - ExitOnFailure(hr, "failed to initialize"); - - hr = ::CoInitialize(NULL); - ExitOnFailure(hr, "failed to intialize COM"); - fInitializedCom = TRUE; - - hr = WcaGetProperty( L"CustomActionData", &pwzData); - ExitOnFailure(hr, "failed to get CustomActionData"); - - WcaLog(LOGMSG_TRACEONLY, "CustomActionData: %ls", pwzData); - - pwz = pwzData; - hr = WcaReadStringFromCaData(&pwz, &pwzDatabaseKey); - ExitOnFailure(hr, "failed to read database key"); - hr = WcaReadStringFromCaData(&pwz, &pwzServer); - ExitOnFailure(hr, "failed to read server"); - hr = WcaReadStringFromCaData(&pwz, &pwzInstance); - ExitOnFailure(hr, "failed to read instance"); - hr = WcaReadStringFromCaData(&pwz, &pwzDatabase); - ExitOnFailure(hr, "failed to read database"); - hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast(&lAttributes)); - ExitOnFailure(hr, "failed to read attributes"); - hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast(&fIntegratedAuth)); // Integrated Windows Authentication? - ExitOnFailure(hr, "failed to read integrated auth flag"); - hr = WcaReadStringFromCaData(&pwz, &pwzUser); - ExitOnFailure(hr, "failed to read user"); - hr = WcaReadStringFromCaData(&pwz, &pwzPassword); - ExitOnFailure(hr, "failed to read password"); - - hr = SqlDropDatabase(pwzServer, pwzInstance, pwzDatabase, fIntegratedAuth, pwzUser, pwzPassword, &bstrErrorDescription); - if ((lAttributes & SCADB_CONTINUE_ON_ERROR) && FAILED(hr)) - { - WcaLog(LOGMSG_STANDARD, "Error 0x%x: failed to drop SQL database but continuing, error: %ls, Database: %ls", hr, NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription, pwzDatabase); - hr = S_OK; - } - MessageExitOnFailure(hr, msierrSQLFailedDropDatabase, "failed to drop to database: '%ls', error: %ls", pwzDatabase, NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription); - - hr = WcaProgressMessage(COST_SQL_CONNECTDB, FALSE); - -LExit: - ReleaseStr(pwzDatabaseKey); - ReleaseStr(pwzServer); - ReleaseStr(pwzInstance); - ReleaseStr(pwzDatabase); - ReleaseStr(pwzUser); - ReleaseStr(pwzPassword); - ReleaseStr(pwzData); - ReleaseObject(pidbSession); - ReleaseBSTR(bstrErrorDescription); - - if (fInitializedCom) - { - ::CoUninitialize(); - } - - if (FAILED(hr)) - { - er = ERROR_INSTALL_FAILURE; - } - return WcaFinalize(er); -} - - -/******************************************************************** - ExecuteSqlStrings - CUSTOM ACTION ENTRY POINT for running SQL strings - - Input: deferred CustomActionData - DbKey\tServer\tInstance\tDatabase\tAttributes\tIntegratedAuth\tUser\tPassword\tSQLKey1\tSQLString1\tSQLKey2\tSQLString2\tSQLKey3\tSQLString3\t... - rollback CustomActionData - same as above - * ****************************************************************/ -extern "C" UINT __stdcall ExecuteSqlStrings(MSIHANDLE hInstall) -{ -//Assert(FALSE); - UINT er = ERROR_SUCCESS; - HRESULT hr = S_OK; - HRESULT hrDB = S_OK; - - LPWSTR pwzData = NULL; - IDBCreateSession* pidbSession = NULL; - BSTR bstrErrorDescription = NULL; - - LPWSTR pwz = NULL; - LPWSTR pwzDatabaseKey = NULL; - LPWSTR pwzServer = NULL; - LPWSTR pwzInstance = NULL; - LPWSTR pwzDatabase = NULL; - int iAttributesDB; - int iAttributesSQL; - BOOL fIntegratedAuth; - LPWSTR pwzUser = NULL; - LPWSTR pwzPassword = NULL; - LPWSTR pwzSqlKey = NULL; - LPWSTR pwzSql = NULL; - BOOL fInitializedCom = FALSE; - - hr = WcaInitialize(hInstall, "ExecuteSqlStrings"); - ExitOnFailure(hr, "failed to initialize"); - - hr = ::CoInitialize(NULL); - ExitOnFailure(hr, "failed to intialize COM"); - fInitializedCom = TRUE; - - hr = WcaGetProperty( L"CustomActionData", &pwzData); - ExitOnFailure(hr, "failed to get CustomActionData"); - - WcaLog(LOGMSG_TRACEONLY, "CustomActionData: %ls", pwzData); - - pwz = pwzData; - hr = WcaReadStringFromCaData(&pwz, &pwzDatabaseKey); - ExitOnFailure(hr, "failed to read database key"); - hr = WcaReadStringFromCaData(&pwz, &pwzServer); - ExitOnFailure(hr, "failed to read server"); - hr = WcaReadStringFromCaData(&pwz, &pwzInstance); - ExitOnFailure(hr, "failed to read instance"); - hr = WcaReadStringFromCaData(&pwz, &pwzDatabase); - ExitOnFailure(hr, "failed to read database"); - hr = WcaReadIntegerFromCaData(&pwz, &iAttributesDB); - ExitOnFailure(hr, "failed to read attributes"); - hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast(&fIntegratedAuth)); // Integrated Windows Authentication? - ExitOnFailure(hr, "failed to read integrated auth flag"); - hr = WcaReadStringFromCaData(&pwz, &pwzUser); - ExitOnFailure(hr, "failed to read user"); - hr = WcaReadStringFromCaData(&pwz, &pwzPassword); - ExitOnFailure(hr, "failed to read password"); - - // Store off the result of the connect, only exit if we don't care if the database connection succeeds - // Wait to fail until later to see if we actually have work to do that is not set to continue on error - hrDB = SqlConnectDatabase(pwzServer, pwzInstance, pwzDatabase, fIntegratedAuth, pwzUser, pwzPassword, &pidbSession); - if ((iAttributesDB & SCADB_CONTINUE_ON_ERROR) && FAILED(hrDB)) - { - WcaLog(LOGMSG_STANDARD, "Error 0x%x: continuing after failure to connect to database: %ls", hrDB, pwzDatabase); - ExitFunction1(hr = S_OK); - } - - while (S_OK == hr && S_OK == (hr = WcaReadStringFromCaData(&pwz, &pwzSqlKey))) - { - hr = WcaReadIntegerFromCaData(&pwz, &iAttributesSQL); - ExitOnFailure(hr, "failed to read attributes for SQL string: %ls", pwzSqlKey); - - hr = WcaReadStringFromCaData(&pwz, &pwzSql); - ExitOnFailure(hr, "failed to read SQL string for key: %ls", pwzSqlKey); - - // If the Wix4SqlString row is set to continue on error and the DB connection failed, skip attempting to execute - if ((iAttributesSQL & SCASQL_CONTINUE_ON_ERROR) && FAILED(hrDB)) - { - WcaLog(LOGMSG_STANDARD, "Error 0x%x: continuing after failure to connect to database: %ls", hrDB, pwzDatabase); - continue; - } - - // Now check if the DB connection succeeded - MessageExitOnFailure(hr = hrDB, msierrSQLFailedConnectDatabase, "failed to connect to database: '%ls'", pwzDatabase); - - WcaLog(LOGMSG_VERBOSE, "Executing SQL string: %ls", pwzSql); - hr = SqlSessionExecuteQuery(pidbSession, pwzSql, NULL, NULL, &bstrErrorDescription); - if ((iAttributesSQL & SCASQL_CONTINUE_ON_ERROR) && FAILED(hr)) - { - WcaLog(LOGMSG_STANDARD, "Error 0x%x: failed to execute SQL string but continuing, error: %ls, SQL key: %ls SQL string: %ls", hr, NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription, pwzSqlKey, pwzSql); - hr = S_OK; - } - MessageExitOnFailure(hr, msierrSQLFailedExecString, "failed to execute SQL string, error: %ls, SQL key: %ls SQL string: %ls", NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription, pwzSqlKey, pwzSql); - - WcaProgressMessage(COST_SQL_STRING, FALSE); - } - if (E_NOMOREITEMS == hr) - { - hr = S_OK; - } - -LExit: - ReleaseStr(pwzDatabaseKey); - ReleaseStr(pwzServer); - ReleaseStr(pwzInstance); - ReleaseStr(pwzDatabase); - ReleaseStr(pwzUser); - ReleaseStr(pwzPassword); - ReleaseStr(pwzData); - - ReleaseBSTR(bstrErrorDescription); - ReleaseObject(pidbSession); - - if (fInitializedCom) - { - ::CoUninitialize(); - } - - if (FAILED(hr)) - { - er = ERROR_INSTALL_FAILURE; - } - return WcaFinalize(er); -} diff --git a/src/ca/scasql.cpp b/src/ca/scasql.cpp deleted file mode 100644 index b0216950..00000000 --- a/src/ca/scasql.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -#include "precomp.h" - -// prototypes -static HRESULT ConfigureSqlData( - __in SCA_ACTION saAction - ); - - -/******************************************************************** -InstallSqlData - CUSTOM ACTION ENTRY POINT for installing - SQL data - -********************************************************************/ -extern "C" UINT __stdcall InstallSqlData( - __in MSIHANDLE hInstall - ) -{ - HRESULT hr = S_OK; - UINT er = ERROR_SUCCESS; - - // initialize - hr = WcaInitialize(hInstall, "InstallSqlData"); - ExitOnFailure(hr, "Failed to initialize"); - - hr = ConfigureSqlData(SCA_ACTION_INSTALL); - -LExit: - er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; - return WcaFinalize(er); -} - - -/******************************************************************** -UninstallSqlData - CUSTOM ACTION ENTRY POINT for uninstalling - SQL data - -********************************************************************/ -extern "C" UINT __stdcall UninstallSqlData( - __in MSIHANDLE hInstall - ) -{ - HRESULT hr = S_OK; - UINT er = ERROR_SUCCESS; - - // initialize - hr = WcaInitialize(hInstall, "UninstallCertificates"); - ExitOnFailure(hr, "Failed to initialize"); - - hr = ConfigureSqlData(SCA_ACTION_UNINSTALL); - -LExit: - er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; - return WcaFinalize(er); -} - - -static HRESULT ConfigureSqlData( - __in SCA_ACTION saAction - ) -{ - //AssertSz(FALSE, "debug ConfigureSqlData()"); - HRESULT hr = S_OK; - - SCA_DB* psdList = NULL; - SCA_SQLSTR* psssList = NULL; - - // check for the prerequsite tables - if (S_OK != WcaTableExists(L"Wix4SqlDatabase")) - { - WcaLog(LOGMSG_VERBOSE, "skipping SQL CustomAction, no Wix4SqlDatabase table"); - ExitFunction1(hr = S_FALSE); - } - - // read tables - hr = ScaDbsRead(&psdList, saAction); - ExitOnFailure(hr, "failed to read Wix4SqlDatabase table"); - - hr = ScaSqlStrsRead(&psssList, saAction); - ExitOnFailure(hr, "failed to read Wix4SqlString table"); - - hr = ScaSqlStrsReadScripts(&psssList, saAction); - ExitOnFailure(hr, "failed to read Wix4SqlScript table"); - - if (SCA_ACTION_UNINSTALL == saAction) - { - // do uninstall actions (order is important!) - hr = ScaSqlStrsUninstall(psdList, psssList); - ExitOnFailure(hr, "failed to execute uninstall SQL strings"); - - hr = ScaDbsUninstall(psdList); - ExitOnFailure(hr, "failed to uninstall databases"); - } - else - { - // do install actions (order is important!) - hr = ScaDbsInstall(psdList); - ExitOnFailure(hr, "failed to install databases"); - - hr = ScaSqlStrsInstall(psdList, psssList); - ExitOnFailure(hr, "failed to execute install SQL strings, length may be too long, try add GO to break up"); - } - -LExit: - if (psssList) - ScaSqlStrsFreeList(psssList); - - if (psdList) - ScaDbsFreeList(psdList); - - return hr; -} diff --git a/src/ca/scasqlstr.cpp b/src/ca/scasqlstr.cpp deleted file mode 100644 index c3ebd43d..00000000 --- a/src/ca/scasqlstr.cpp +++ /dev/null @@ -1,728 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -#include "precomp.h" - -// sql queries -LPCWSTR vcsSqlStringQuery = L"SELECT `String`, `SqlDb_`, `Component_`,`SQL`,`User_`,`Attributes`,`Sequence` " -L"FROM `Wix4SqlString` ORDER BY `SqlDb_`,`Sequence`"; -enum eSqlStringQuery { ssqSqlString = 1, ssqSqlDb, ssqComponent, ssqSQL, ssqUser, ssqAttributes, ssqSequence }; - -LPCWSTR vcsSqlScriptQuery = L"SELECT `ScriptBinary_`,`Script`, `SqlDb_`, `Component_`,`User_`,`Attributes`,`Sequence` " -L"FROM `Wix4SqlScript` ORDER BY `SqlDb_`,`Sequence`"; -enum eSqlScriptQuery { sscrqScriptBinary=1, sscrqSqlScript, sscrqSqlDb, sscrqComponent, sscrqUser, sscrqAttributes, sscrqSequence }; - -LPCWSTR vcsSqlBinaryScriptQuery = L"SELECT `Data` FROM `Binary` WHERE `Name`=?"; -enum eSqlBinaryScriptQuery { ssbsqData = 1 }; - - -// prototypes for private helper functions -static HRESULT NewSqlStr( - __out SCA_SQLSTR** ppsss - ); -static SCA_SQLSTR* AddSqlStrToList( - __in SCA_SQLSTR* psssList, - __in SCA_SQLSTR* psss - ); -static HRESULT ExecuteStrings( - __in SCA_DB* psdList, - __in SCA_SQLSTR* psssList, - __in BOOL fInstall - ); - -HRESULT ScaSqlStrsRead( - __inout SCA_SQLSTR** ppsssList, - __in SCA_ACTION saAction - ) -{ - HRESULT hr = S_OK; - UINT er = ERROR_SUCCESS; - PMSIHANDLE hView, hRec; - PMSIHANDLE hViewUser, hRecUser; - - LPWSTR pwzComponent = NULL; - LPWSTR pwzData = NULL; - - SCA_SQLSTR* psss = NULL; - - if (S_OK != WcaTableExists(L"Wix4SqlString") || S_OK != WcaTableExists(L"Wix4SqlDatabase")) - { - WcaLog(LOGMSG_VERBOSE, "Skipping ScaSqlStrsRead() - Wix4SqlString and/or Wix4SqlDatabase table not present"); - ExitFunction1(hr = S_FALSE); - } - - // loop through all the sql strings - hr = WcaOpenExecuteView(vcsSqlStringQuery, &hView); - ExitOnFailure(hr, "Failed to open view on Wix4SqlString table"); - while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) - { - INSTALLSTATE isInstalled = INSTALLSTATE_UNKNOWN; - INSTALLSTATE isAction = INSTALLSTATE_UNKNOWN; - - hr = WcaGetRecordString(hRec, ssqComponent, &pwzComponent); - ExitOnFailure(hr, "Failed to get Component for SQL String."); - - er = ::MsiGetComponentStateW(WcaGetInstallHandle(), pwzComponent, &isInstalled, &isAction); - hr = HRESULT_FROM_WIN32(er); - ExitOnFailure(hr, "Failed to get state for component: %ls", pwzComponent); - - // If we're doing install but the Component is not being installed or we're doing - // uninstall but the Component is not being uninstalled, skip it. - if ((WcaIsInstalling(isInstalled, isAction) && SCA_ACTION_INSTALL != saAction) || - (WcaIsUninstalling(isInstalled, isAction) && SCA_ACTION_UNINSTALL != saAction)) - { - continue; - } - - hr = NewSqlStr(&psss); - ExitOnFailure(hr, "failed to allocation new sql string element"); - - psss->isInstalled = isInstalled; - psss->isAction = isAction; - - hr = WcaGetRecordString(hRec, ssqSqlString, &pwzData); - ExitOnFailure(hr, "Failed to get Wix4SqlString.String"); - hr = ::StringCchCopyW(psss->wzKey, countof(psss->wzKey), pwzData); - ExitOnFailure(hr, "Failed to copy Wix4SqlString.String: %ls", pwzData); - - // find the database information for this string - hr = WcaGetRecordString(hRec, ssqSqlDb, &pwzData); - ExitOnFailure(hr, "Failed to get Wix4SqlString.SqlDb_ for SqlString '%ls'", psss->wzKey); - hr = ::StringCchCopyW(psss->wzSqlDb, countof(psss->wzSqlDb), pwzData); - ExitOnFailure(hr, "Failed to copy Wix4SqlString.SqlDb_: %ls", pwzData); - - hr = WcaGetRecordInteger(hRec, ssqAttributes, &psss->iAttributes); - ExitOnFailure(hr, "Failed to get Wix4SqlString.Attributes for SqlString '%ls'", psss->wzKey); - - //get the sequence number for the string (note that this will be sequenced with scripts too) - hr = WcaGetRecordInteger(hRec, ssqSequence, &psss->iSequence); - ExitOnFailure(hr, "Failed to get Wix4SqlString.Sequence for SqlString '%ls'", psss->wzKey); - - // execute SQL - hr = WcaGetRecordFormattedString(hRec, ssqSQL, &pwzData); - ExitOnFailure(hr, "Failed to get Wix4SqlString.SQL for SQL string '%ls'", psss->wzKey); - - Assert(!psss->pwzSql); - hr = StrAllocString(&psss->pwzSql, pwzData, 0); - ExitOnFailure(hr, "Failed to alloc string for SQL string '%ls'", psss->wzKey); - - *ppsssList = AddSqlStrToList(*ppsssList, psss); - psss = NULL; // set the sss to NULL so it doesn't get freed below - } - - if (E_NOMOREITEMS == hr) - { - hr = S_OK; - } - ExitOnFailure(hr, "Failure occured while reading Wix4SqlString table"); - -LExit: - // if anything was left over after an error clean it all up - if (psss) - { - ScaSqlStrsFreeList(psss); - } - - ReleaseStr(pwzData); - ReleaseStr(pwzComponent); - - return hr; -} - - -HRESULT ScaSqlStrsReadScripts( - __inout SCA_SQLSTR** ppsssList, - __in SCA_ACTION saAction - ) -{ - HRESULT hr = S_OK; - UINT er = ERROR_SUCCESS; - - PMSIHANDLE hView, hRec; - PMSIHANDLE hViewBinary, hRecBinary; - PMSIHANDLE hViewUser, hRecUser; - - LPWSTR pwzComponent = NULL; - LPWSTR pwzData = NULL; - - BYTE* pbScript = NULL; - DWORD cbRead = 0; - DWORD cbScript = 0; - DWORD cchScript = 0; - - LPWSTR pwzScriptBuffer = NULL; - WCHAR* pwzScript = NULL; - WCHAR* pwz; - DWORD cch = 0; - - SCA_SQLSTR sss; - SCA_SQLSTR* psss = NULL; - - if (S_OK != WcaTableExists(L"Wix4SqlScript") || S_OK != WcaTableExists(L"Wix4SqlDatabase") || S_OK != WcaTableExists(L"Binary")) - { - WcaLog(LOGMSG_VERBOSE, "Skipping ScaSqlStrsReadScripts() - Wix4SqlScript and/or Wix4SqlDatabase table not present"); - ExitFunction1(hr = S_FALSE); - } - - // open a view on the binary table - hr = WcaOpenView(vcsSqlBinaryScriptQuery, &hViewBinary); - ExitOnFailure(hr, "Failed to open view on Binary table for SQL scripts"); - - // loop through all the sql scripts - hr = WcaOpenExecuteView(vcsSqlScriptQuery, &hView); - ExitOnFailure(hr, "Failed to open view on Wix4SqlScript table"); - while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) - { - INSTALLSTATE isInstalled = INSTALLSTATE_UNKNOWN; - INSTALLSTATE isAction = INSTALLSTATE_UNKNOWN; - - hr = WcaGetRecordString(hRec, sscrqComponent, &pwzComponent); - ExitOnFailure(hr, "Failed to get Component for SQL Script."); - - er = ::MsiGetComponentStateW(WcaGetInstallHandle(), pwzComponent, &isInstalled, &isAction); - hr = HRESULT_FROM_WIN32(er); - ExitOnFailure(hr, "Failed to get state for component: %ls", pwzComponent); - - // If we're doing install but the Component is not being installed or we're doing - // uninstall but the Component is not being uninstalled, skip it. - if ((WcaIsInstalling(isInstalled, isAction) && SCA_ACTION_INSTALL != saAction) || - (WcaIsUninstalling(isInstalled, isAction) && SCA_ACTION_UNINSTALL != saAction)) - { - continue; - } - - ::ZeroMemory(&sss, sizeof(sss)); - - sss.isInstalled = isInstalled; - sss.isAction = isAction; - - hr = WcaGetRecordString(hRec, sscrqSqlScript, &pwzData); - ExitOnFailure(hr, "Failed to get Wix4SqlScript.Script"); - hr = ::StringCchCopyW(sss.wzKey, countof(sss.wzKey), pwzData); - ExitOnFailure(hr, "Failed to copy Wix4SqlScript.Script: %ls", pwzData); - - // find the database information for this string - hr = WcaGetRecordString(hRec, sscrqSqlDb, &pwzData); - ExitOnFailure(hr, "Failed to get Wix4SqlScript.SqlDb_ for SqlScript '%ls'", sss.wzKey); - hr = ::StringCchCopyW(sss.wzSqlDb, countof(sss.wzSqlDb), pwzData); - ExitOnFailure(hr, "Failed to copy Wix4SqlScript.SqlDbb: %ls", pwzData); - - hr = WcaGetRecordInteger(hRec, sscrqAttributes, &sss.iAttributes); - ExitOnFailure(hr, "Failed to get Wix4SqlScript.Attributes for SqlScript '%ls'", sss.wzKey); - - hr = WcaGetRecordInteger(hRec, sscrqSequence, &sss.iSequence); - ExitOnFailure(hr, "Failed to get Wix4SqlScript.Sequence for SqlScript '%ls'", sss.wzKey); - - // get the sql script out of the binary stream - hr = WcaExecuteView(hViewBinary, hRec); - ExitOnFailure(hr, "Failed to open Wix4SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey); - hr = WcaFetchSingleRecord(hViewBinary, &hRecBinary); - ExitOnFailure(hr, "Failed to fetch Wix4SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey); - - // Note: We need to allocate an extra character on the stream to NULL terminate the SQL script. - // The WcaGetRecordStream() function won't let us add extra space on the end of the stream - // so we'll read the stream "the old fashioned way". - //hr = WcaGetRecordStream(hRecBinary, ssbsqData, (BYTE**)&pbScript, &cbScript); - //ExitOnFailure(hr, "Failed to read Wix4SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey); - er = ::MsiRecordReadStream(hRecBinary, ssbsqData, NULL, &cbRead); - hr = HRESULT_FROM_WIN32(er); - ExitOnFailure(hr, "failed to get size of stream"); - - cbScript = cbRead + sizeof(WCHAR); // we may have an ANSI SQL script but leave enough to even NULL terminate a WCHAR string - hr = WcaAllocStream(&pbScript, cbScript); // this will allocate a fully zeroed out buffer so our string will be NULL terminated - ExitOnFailure(hr, "failed to allocate data for stream"); - - er = ::MsiRecordReadStream(hRecBinary, ssbsqData, reinterpret_cast(pbScript), &cbRead); //read the buffer but leave the space for the NULL terminator - hr = HRESULT_FROM_WIN32(er); - ExitOnFailure(hr, "failed to read from stream"); - - Assert(cbRead + sizeof(WCHAR) == cbScript); - - // Check for the UNICODE BOM file marker. - if ((0xFF == *pbScript) && (0xFE == *(pbScript + 1))) - { - // Copy the UNICODE string after the BOM marker (subtract one because we'll skip the BOM marker). - cchScript = (cbScript / sizeof(WCHAR)) - 1; - - hr = StrAllocString(&pwzScriptBuffer, reinterpret_cast(pbScript) + 1, 0); - ExitOnFailure(hr, "Failed to allocate WCHAR string of size '%d'", cchScript); - } - else - { - // We have an ANSI string so convert it to UNICODE. - cchScript = cbScript; - - hr = StrAllocStringAnsi(&pwzScriptBuffer, reinterpret_cast(pbScript), 0, CP_ACP); - ExitOnFailure(hr, "Failed to allocate WCHAR string of size '%d'", cchScript); - } - - // Free the byte buffer since it has been converted to a new UNICODE string, one way or another. - if (pbScript) - { - WcaFreeStream(pbScript); - pbScript = NULL; - } - - // Process the SQL script stripping out unnecessary stuff (like comments) and looking for "GO" statements. - pwzScript = pwzScriptBuffer; - while (cchScript && pwzScript && *pwzScript) - { - // strip off leading whitespace - while (cchScript && *pwzScript && iswspace(*pwzScript)) - { - ++pwzScript; - --cchScript; - } - - Assert(0 <= cchScript); - - // if there is a SQL comment remove it - while (cchScript && L'/' == *pwzScript && L'*' == *(pwzScript + 1)) - { - // go until end of comment - while (cchScript && *pwzScript && *(pwzScript + 1) && !(L'*' == *pwzScript && L'/' == *(pwzScript + 1))) - { - ++pwzScript; - --cchScript; - } - - Assert(2 <= cchScript); - - if (2 <= cchScript) - { - // to account for */ at end - pwzScript+=2; - cchScript-=2; - } - - Assert(0 <= cchScript); - - // strip off any new leading whitespace - while (cchScript && *pwzScript && iswspace(*pwzScript)) - { - ++pwzScript; - --cchScript; - } - } - - while (cchScript && L'-' == *pwzScript && L'-' == *(pwzScript + 1)) - { - // go past the new line character - while (cchScript && *pwzScript && L'\n' != *pwzScript) - { - ++pwzScript; - --cchScript; - } - - Assert(0 <= cchScript); - - if (cchScript && L'\n' == *pwzScript) - { - ++pwzScript; - --cchScript; - } - - Assert(0 <= cchScript); - - // strip off any new leading whitespace - while (cchScript && *pwzScript && iswspace(*pwzScript)) - { - ++pwzScript; - --cchScript; - } - } - - Assert(0 <= cchScript); - - // try to isolate a "GO" keyword and count the characters in the SQL string - pwz = pwzScript; - cch = 0; - while (cchScript && *pwz) - { - //skip past comment lines that might have "go" in them - //note that these comments are "in the middle" of our function, - //or possibly at the end of a line - if (cchScript && L'-' == *pwz && L'-' == *(pwz + 1)) - { - // skip past chars until the new line character - while (cchScript && *pwz && (L'\n' != *pwz)) - { - ++pwz; - ++cch; - --cchScript; - } - } - - //skip past comment lines of form /* to */ that might have "go" in them - //note that these comments are "in the middle" of our function, - //or possibly at the end of a line - if (cchScript && L'/' == *pwz && L'*' == *(pwz + 1)) - { - // skip past chars until the new line character - while (cchScript && *pwz && *(pwz + 1) && !((L'*' == *pwz) && (L'/' == *(pwz + 1)))) - { - ++pwz; - ++cch; - --cchScript; - } - - if (2 <= cchScript) - { - // to account for */ at end - pwz+=2; - cch+=2; - cchScript-=2; - } - } - - // Skip past strings that may be part of the SQL statement that might have a "go" in them - if ( cchScript && L'\'' == *pwz ) - { - ++pwz; - ++cch; - --cchScript; - - // Skip past chars until the end of the string - while ( cchScript && *pwz && !(L'\'' == *pwz) ) - { - ++pwz; - ++cch; - --cchScript; - } - } - - // Skip past strings that may be part of the SQL statement that might have a "go" in them - if ( cchScript && L'\"' == *pwz ) - { - ++pwz; - ++cch; - --cchScript; - - // Skip past chars until the end of the string - while ( cchScript && *pwz && !(L'\"' == *pwz) ) - { - ++pwz; - ++cch; - --cchScript; - } - } - - // if "GO" is isolated - if ((pwzScript == pwz || iswspace(*(pwz - 1))) && - (L'G' == *pwz || L'g' == *pwz) && - (L'O' == *(pwz + 1) || L'o' == *(pwz + 1)) && - (0 == *(pwz + 2) || iswspace(*(pwz + 2)))) - { - *pwz = 0; // null terminate the SQL string on the "G" - pwz += 2; - cchScript -= 2; - break; // found "GO" now add SQL string to list - } - - ++pwz; - ++cch; - --cchScript; - } - - Assert(0 <= cchScript); - - if (0 < cch) //don't process if there's nothing to process - { - // replace tabs with spaces - for (LPWSTR pwzTab = wcsstr(pwzScript, L"\t"); pwzTab; pwzTab = wcsstr(pwzTab, L"\t")) - *pwzTab = ' '; - - // strip off whitespace at the end of the script string - for (LPWSTR pwzErase = pwzScript + cch - 1; pwzScript < pwzErase && iswspace(*pwzErase); pwzErase--) - { - *(pwzErase) = 0; - cch--; - } - } - - if (0 < cch) - { - hr = NewSqlStr(&psss); - ExitOnFailure(hr, "failed to allocate new sql string element"); - - // copy everything over - hr = ::StringCchCopyW(psss->wzKey, countof(psss->wzKey), sss.wzKey); - ExitOnFailure(hr, "Failed to copy key string to sqlstr object"); - hr = ::StringCchCopyW(psss->wzSqlDb, countof(psss->wzSqlDb), sss.wzSqlDb); - ExitOnFailure(hr, "Failed to copy DB string to sqlstr object"); - hr = ::StringCchCopyW(psss->wzComponent, countof(psss->wzComponent), sss.wzComponent); - ExitOnFailure(hr, "Failed to copy component string to sqlstr object"); - psss->isInstalled = sss.isInstalled; - psss->isAction = sss.isAction; - psss->iAttributes = sss.iAttributes; - psss->iSequence = sss.iSequence; - - // cchRequired includes the NULL terminating char - hr = StrAllocString(&psss->pwzSql, pwzScript, 0); - ExitOnFailure(hr, "Failed to allocate string for SQL script: '%ls'", psss->wzKey); - - *ppsssList = AddSqlStrToList(*ppsssList, psss); - psss = NULL; // set the db NULL so it doesn't accidentally get freed below - } - - pwzScript = pwz; - } - } - - if (E_NOMOREITEMS == hr) - { - hr = S_OK; - } - ExitOnFailure(hr, "Failure occured while reading Wix4SqlScript table"); - -LExit: - // if anything was left over after an error clean it all up - if (psss) - { - ScaSqlStrsFreeList(psss); - } - - if (pbScript) - { - WcaFreeStream(pbScript); - } - - ReleaseStr(pwzScriptBuffer); - ReleaseStr(pwzData); - ReleaseStr(pwzComponent); - - return hr; -} - - -HRESULT ScaSqlStrsInstall( - __in SCA_DB* psdList, - __in SCA_SQLSTR* psssList - ) -{ - HRESULT hr = ExecuteStrings(psdList, psssList, TRUE); - - return hr; -} - - -HRESULT ScaSqlStrsUninstall( - __in SCA_DB* psdList, - __in SCA_SQLSTR* psssList - ) -{ - HRESULT hr = ExecuteStrings(psdList, psssList, FALSE); - - return hr; -} - - -void ScaSqlStrsFreeList( - __in SCA_SQLSTR* psssList - ) -{ - SCA_SQLSTR* psssDelete = psssList; - while (psssList) - { - psssDelete = psssList; - psssList = psssList->psssNext; - - if (psssDelete->pwzSql) - { - ReleaseStr(psssDelete->pwzSql); - } - - MemFree(psssDelete); - } -} - - -// private helper functions - -static HRESULT NewSqlStr( - __out SCA_SQLSTR** ppsss - ) -{ - HRESULT hr = S_OK; - SCA_SQLSTR* psss = static_cast(MemAlloc(sizeof(SCA_SQLSTR), TRUE)); - ExitOnNull(psss, hr, E_OUTOFMEMORY, "failed to allocate memory for new sql string element"); - - *ppsss = psss; - -LExit: - return hr; -} - - -static SCA_SQLSTR* AddSqlStrToList( - __in SCA_SQLSTR* psssList, - __in SCA_SQLSTR* psss - ) -{ - Assert(psss); //just checking - - //make certain we have a valid sequence number; note that negatives are technically valid - if (MSI_NULL_INTEGER == psss->iSequence) - { - psss->iSequence = 0; - } - - if (psssList) - { - //list already exists, so insert psss into the list in Sequence order - - //see if we need to change the head, otherwise figure out where in the order it fits - if (psss->iSequence < psssList->iSequence) - { - psss->psssNext = psssList; - psssList = psss; - } - else - { - SCA_SQLSTR* psssT = psssList; - //note that if Sequence numbers are duplicated, as in the case of a sqlscript, - //we need to insert them "at the end" of the group so the sqlfile stays in order - while (psssT->psssNext && (psssT->psssNext->iSequence <= psss->iSequence)) - { - psssT = psssT->psssNext; - } - - //insert our new psss AFTER psssT - psss->psssNext = psssT->psssNext; - psssT->psssNext = psss; - } - } - else - { - psssList = psss; - } - - return psssList; -} - - -static HRESULT ExecuteStrings( - __in SCA_DB* psdList, - __in SCA_SQLSTR* psssList, - __in BOOL fInstall - ) -{ - HRESULT hr = S_FALSE; // assume nothing will be done - - int iRollback = -1; - int iOldRollback = iRollback; - - LPCWSTR wzOldDb = NULL; - UINT uiCost = 0; - WCHAR* pwzCustomActionData = NULL; - WCHAR wzNumber[64]; - - // loop through all sql strings - for (SCA_SQLSTR* psss = psssList; psss; psss = psss->psssNext) - { - // if installing this component - if ((fInstall && (psss->iAttributes & SCASQL_EXECUTE_ON_INSTALL) && WcaIsInstalling(psss->isInstalled, psss->isAction) && !WcaIsReInstalling(psss->isInstalled, psss->isAction)) || - (fInstall && (psss->iAttributes & SCASQL_EXECUTE_ON_REINSTALL) && WcaIsReInstalling(psss->isInstalled, psss->isAction)) || - (!fInstall && (psss->iAttributes & SCASQL_EXECUTE_ON_UNINSTALL) && WcaIsUninstalling(psss->isInstalled, psss->isAction))) - { - // determine if this is a rollback scheduling or normal deferred scheduling - if (psss->iAttributes & SCASQL_ROLLBACK) - { - iRollback = 1; - } - else - { - iRollback = 0; - } - - // if we need to create a connection to a new server\database - if (!wzOldDb || 0 != lstrcmpW(wzOldDb, psss->wzSqlDb) || iOldRollback != iRollback) - { - const SCA_DB* psd = ScaDbsFindDatabase(psss->wzSqlDb, psdList); - if (!psd) - { - ExitOnFailure(hr = HRESULT_FROM_WIN32(ERROR_NOT_FOUND), "failed to find data for Database: %ls", psss->wzSqlDb); - } - - if (-1 == iOldRollback) - { - iOldRollback = iRollback; - } - Assert(0 == iOldRollback || 1 == iOldRollback); - - // if there was custom action data before, schedule the action to write it - if (pwzCustomActionData && *pwzCustomActionData) - { - Assert(pwzCustomActionData && *pwzCustomActionData && uiCost); - - hr = WcaDoDeferredAction(1 == iOldRollback ? CUSTOM_ACTION_DECORATION(L"RollbackExecuteSqlStrings") : CUSTOM_ACTION_DECORATION(L"ExecuteSqlStrings"), pwzCustomActionData, uiCost); - ExitOnFailure(hr, "failed to schedule ExecuteSqlStrings action, rollback: %d", iOldRollback); - iOldRollback = iRollback; - - *pwzCustomActionData = L'\0'; - uiCost = 0; - } - - Assert(!pwzCustomActionData || (pwzCustomActionData && 0 == *pwzCustomActionData) && 0 == uiCost); - - hr = WcaWriteStringToCaData(psd->wzKey, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add SQL Server Database String to CustomActionData for Database String: %ls", psd->wzKey); - - hr = WcaWriteStringToCaData(psd->wzServer, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add SQL Server to CustomActionData for Database String: %ls", psd->wzKey); - - hr = WcaWriteStringToCaData(psd->wzInstance, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add SQL Instance to CustomActionData for Database String: %ls", psd->wzKey); - - hr = WcaWriteStringToCaData(psd->wzDatabase, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add SQL Database to CustomActionData for Database String: %ls", psd->wzKey); - - hr = ::StringCchPrintfW(wzNumber, countof(wzNumber), L"%d", psd->iAttributes); - ExitOnFailure(hr, "Failed to format attributes integer value to string"); - hr = WcaWriteStringToCaData(wzNumber, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add SQL Attributes to CustomActionData for Database String: %ls", psd->wzKey); - - hr = ::StringCchPrintfW(wzNumber, countof(wzNumber), L"%d", psd->fUseIntegratedAuth); - ExitOnFailure(hr, "Failed to format UseIntegratedAuth integer value to string"); - hr = WcaWriteStringToCaData(wzNumber, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add SQL IntegratedAuth flag to CustomActionData for Database String: %ls", psd->wzKey); - - hr = WcaWriteStringToCaData(psd->scau.wzName, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add SQL UserName to CustomActionData for Database String: %ls", psd->wzKey); - - hr = WcaWriteStringToCaData(psd->scau.wzPassword, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add SQL Password to CustomActionData for Database String: %ls", psd->wzKey); - - uiCost += COST_SQL_CONNECTDB; - - wzOldDb = psss->wzSqlDb; - } - - WcaLog(LOGMSG_VERBOSE, "Scheduling SQL string: %ls", psss->pwzSql); - - hr = WcaWriteStringToCaData(psss->wzKey, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to add SQL Key to CustomActionData for SQL string: %ls", psss->wzKey); - - hr = WcaWriteIntegerToCaData(psss->iAttributes, &pwzCustomActionData); - ExitOnFailure(hr, "failed to add attributes to CustomActionData for SQL string: %ls", psss->wzKey); - - hr = WcaWriteStringToCaData(psss->pwzSql, &pwzCustomActionData); - ExitOnFailure(hr, "Failed to to add SQL Query to CustomActionData for SQL string: %ls", psss->wzKey); - uiCost += COST_SQL_STRING; - } - } - - if (pwzCustomActionData && *pwzCustomActionData) - { - Assert(pwzCustomActionData && *pwzCustomActionData && uiCost); - hr = WcaDoDeferredAction(1 == iRollback ? CUSTOM_ACTION_DECORATION(L"RollbackExecuteSqlStrings") : CUSTOM_ACTION_DECORATION(L"ExecuteSqlStrings"), pwzCustomActionData, uiCost); - ExitOnFailure(hr, "Failed to schedule ExecuteSqlStrings action"); - - *pwzCustomActionData = L'\0'; - uiCost = 0; - } - -LExit: - ReleaseStr(pwzCustomActionData); - - return hr; -} diff --git a/src/ca/scasqlstr.h b/src/ca/scasqlstr.h deleted file mode 100644 index 72c1d770..00000000 --- a/src/ca/scasqlstr.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - - -#include "scadb.h" - -struct SCA_SQLSTR -{ - // darwin information - WCHAR wzKey[MAX_DARWIN_KEY + 1]; - WCHAR wzComponent[MAX_DARWIN_KEY + 1]; - INSTALLSTATE isInstalled, isAction; - - WCHAR wzSqlDb[MAX_DARWIN_COLUMN + 1]; - - BOOL fHasUser; - SCA_USER scau; - - LPWSTR pwzSql; - int iAttributes; - int iSequence; //used to sequence Wix4SqlString and Wix4SqlScript tables together - - SCA_SQLSTR* psssNext; -}; - - -// prototypes -HRESULT ScaSqlStrsRead( - __inout SCA_SQLSTR** ppsssList, - __in SCA_ACTION saAction - ); - -HRESULT ScaSqlStrsReadScripts( - __inout SCA_SQLSTR** ppsssList, - __in SCA_ACTION saAction - ); - -HRESULT ScaSqlStrsInstall( - __in SCA_DB* psdList, - __in SCA_SQLSTR* psssList - ); - -HRESULT ScaSqlStrsUninstall( - __in SCA_DB* psdList, - __in SCA_SQLSTR* psssList - ); - -void ScaSqlStrsFreeList( - __in SCA_SQLSTR* psssList - ); - diff --git a/src/ca/scauser.cpp b/src/ca/scauser.cpp deleted file mode 100644 index 4d74e4d4..00000000 --- a/src/ca/scauser.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -#include "precomp.h" - -LPCWSTR vcsUserQuery = L"SELECT `User`, `Component_`, `Name`, `Domain`, `Password` FROM `User` WHERE `User`=?"; -enum eUserQuery { vuqUser = 1, vuqComponent, vuqName, vuqDomain, vuqPassword }; - - -HRESULT __stdcall ScaGetUser( - __in LPCWSTR wzUser, - __out SCA_USER* pscau - ) -{ - if (!wzUser || !pscau) - { - return E_INVALIDARG; - } - - HRESULT hr = S_OK; - PMSIHANDLE hView, hRec; - - LPWSTR pwzData = NULL; - - // clear struct and bail right away if no user key was passed to search for - ::ZeroMemory(pscau, sizeof(*pscau)); - if (!*wzUser) - { - ExitFunction1(hr = S_OK); - } - - hRec = ::MsiCreateRecord(1); - hr = WcaSetRecordString(hRec, 1, wzUser); - ExitOnFailure(hr, "Failed to look up User"); - - hr = WcaOpenView(vcsUserQuery, &hView); - ExitOnFailure(hr, "Failed to open view on User table"); - hr = WcaExecuteView(hView, hRec); - ExitOnFailure(hr, "Failed to execute view on User table"); - - hr = WcaFetchSingleRecord(hView, &hRec); - if (S_OK == hr) - { - hr = WcaGetRecordString(hRec, vuqUser, &pwzData); - ExitOnFailure(hr, "Failed to get User.User"); - hr = ::StringCchCopyW(pscau->wzKey, countof(pscau->wzKey), pwzData); - ExitOnFailure(hr, "Failed to copy key string to user object"); - - hr = WcaGetRecordString(hRec, vuqComponent, &pwzData); - ExitOnFailure(hr, "Failed to get User.Component_"); - hr = ::StringCchCopyW(pscau->wzComponent, countof(pscau->wzComponent), pwzData); - ExitOnFailure(hr, "Failed to copy component string to user object"); - - hr = WcaGetRecordFormattedString(hRec, vuqName, &pwzData); - ExitOnFailure(hr, "Failed to get User.Name"); - hr = ::StringCchCopyW(pscau->wzName, countof(pscau->wzName), pwzData); - ExitOnFailure(hr, "Failed to copy name string to user object"); - - hr = WcaGetRecordFormattedString(hRec, vuqDomain, &pwzData); - ExitOnFailure(hr, "Failed to get User.Domain"); - hr = ::StringCchCopyW(pscau->wzDomain, countof(pscau->wzDomain), pwzData); - ExitOnFailure(hr, "Failed to copy domain string to user object"); - - hr = WcaGetRecordFormattedString(hRec, vuqPassword, &pwzData); - ExitOnFailure(hr, "Failed to get User.Password"); - hr = ::StringCchCopyW(pscau->wzPassword, countof(pscau->wzPassword), pwzData); - ExitOnFailure(hr, "Failed to copy password string to user object"); - } - else if (E_NOMOREITEMS == hr) - { - WcaLog(LOGMSG_STANDARD, "Error: Cannot locate User.User='%ls'", wzUser); - hr = E_FAIL; - } - else - { - ExitOnFailure(hr, "Error or found multiple matching User rows"); - } - -LExit: - ReleaseStr(pwzData); - - return hr; -} diff --git a/src/ca/scauser.h b/src/ca/scauser.h deleted file mode 100644 index 20e561f2..00000000 --- a/src/ca/scauser.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - - - -// structs -struct SCA_GROUP -{ - WCHAR wzKey[MAX_DARWIN_KEY + 1]; - WCHAR wzComponent[MAX_DARWIN_KEY + 1]; - - WCHAR wzDomain[MAX_DARWIN_COLUMN + 1]; - WCHAR wzName[MAX_DARWIN_COLUMN + 1]; - - SCA_GROUP *psgNext; -}; - -struct SCA_USER -{ - WCHAR wzKey[MAX_DARWIN_KEY + 1]; - WCHAR wzComponent[MAX_DARWIN_KEY + 1]; - INSTALLSTATE isInstalled; - INSTALLSTATE isAction; - - WCHAR wzDomain[MAX_DARWIN_COLUMN + 1]; - WCHAR wzName[MAX_DARWIN_COLUMN + 1]; - WCHAR wzPassword[MAX_DARWIN_COLUMN + 1]; - INT iAttributes; - - SCA_GROUP *psgGroups; - - SCA_USER *psuNext; -}; - - -// prototypes -HRESULT __stdcall ScaGetUser( - __in LPCWSTR wzUser, - __out SCA_USER* pscau - ); diff --git a/src/ca/sqlca.cpp b/src/ca/sqlca.cpp deleted file mode 100644 index 37664a1c..00000000 --- a/src/ca/sqlca.cpp +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -#include "precomp.h" diff --git a/src/ca/sqlca.def b/src/ca/sqlca.def deleted file mode 100644 index e899d560..00000000 --- a/src/ca/sqlca.def +++ /dev/null @@ -1,13 +0,0 @@ -; Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - - -LIBRARY "sqlca" - -EXPORTS -;scaexec.cpp - CreateDatabase - DropDatabase - ExecuteSqlStrings -;scasql.cpp - InstallSqlData - UninstallSqlData diff --git a/src/ca/sqlca.vcxproj b/src/ca/sqlca.vcxproj deleted file mode 100644 index 18becc5f..00000000 --- a/src/ca/sqlca.vcxproj +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - Debug - ARM64 - - - Release - ARM64 - - - - - {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935} - DynamicLibrary - sqlca - v142 - Unicode - sqlca.def - WiX Toolset Sql CustomAction - - - - - - - msi.lib - - - - - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/ext/Sql/Directory.Build.props b/src/ext/Sql/Directory.Build.props new file mode 100644 index 00000000..b3c6287c --- /dev/null +++ b/src/ext/Sql/Directory.Build.props @@ -0,0 +1,27 @@ + + + + + + Debug + false + MSB3246 + + $(MSBuildProjectName) + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\build\)) + $(BaseOutputPath)obj\$(ProjectName)\ + $(BaseOutputPath)$(Configuration)\ + + WiX Toolset Team + WiX Toolset + Copyright (c) .NET Foundation and contributors. All rights reserved. + MS-RL + WiX Toolset + + + + + diff --git a/src/ext/Sql/Directory.Build.targets b/src/ext/Sql/Directory.Build.targets new file mode 100644 index 00000000..2fcc765a --- /dev/null +++ b/src/ext/Sql/Directory.Build.targets @@ -0,0 +1,51 @@ + + + + + + + true + $(SolutionPath) + $(NCrunchOriginalSolutionPath) + + + + + + + $([System.IO.File]::ReadAllText($(TheSolutionPath))) + $([System.IO.Path]::GetDirectoryName( $(TheSolutionPath) )) + (?<="[PackageName]", ")(.*)(?=", ") + + + + + + %(Identity) + $(SolutionFileContent.Contains('\%(Identity).csproj')) + + + + + $(RegexPattern.Replace('[PackageName]','%(PackageName)') ) + $([System.Text.RegularExpressions.Regex]::Match('$(SolutionFileContent)', '%(Pattern)')) + + + + + + + + + + + + + + diff --git a/src/ext/Sql/Directory.csproj.props b/src/ext/Sql/Directory.csproj.props new file mode 100644 index 00000000..81d24ad1 --- /dev/null +++ b/src/ext/Sql/Directory.csproj.props @@ -0,0 +1,13 @@ + + + + + true + true + $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)wix.snk)) + false + + diff --git a/src/ext/Sql/Directory.csproj.targets b/src/ext/Sql/Directory.csproj.targets new file mode 100644 index 00000000..c3270426 --- /dev/null +++ b/src/ext/Sql/Directory.csproj.targets @@ -0,0 +1,26 @@ + + + + + false + $(OutputPath)\$(AssemblyName).xml + + + + + $(PrivateRepositoryUrl.Replace('.git','')) + + $(MSBuildProjectName).nuspec + $(OutputPath)..\ + $(NuspecProperties);Id=$(PackageId);Authors=$(Authors);Copyright=$(Copyright);Description=$(Description);Title=$(Title) + $(NuspecProperties);Version=$(PackageVersion);RepositoryCommit=$(SourceRevisionId);RepositoryType=$(RepositoryType);RepositoryUrl=$(PrivateRepositoryUrl);ProjectFolder=$(MSBuildProjectDirectory)\;ProjectUrl=$(ProjectUrl) + true + snupkg + + + + diff --git a/src/ext/Sql/Directory.vcxproj.props b/src/ext/Sql/Directory.vcxproj.props new file mode 100644 index 00000000..bcf26c57 --- /dev/null +++ b/src/ext/Sql/Directory.vcxproj.props @@ -0,0 +1,111 @@ + + + + + + Win32 + $(BaseIntermediateOutputPath)$(Configuration)\$(Platform)\ + $(OutputPath)$(Platform)\ + + + $(Company) + $(Copyright) + + win-x86;win-x64;win-arm64 + native,Version=v0.0 + + + + $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) + + + + + $(DisableSpecificCompilerWarnings) + Level4 + $(ProjectDir)inc;$(MSBuildProjectDirectory);$(IntDir);$(SqlCESdkIncludePath);$(ProjectAdditionalIncludeDirectories);%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;_WIN32_MSI=500;_WIN32_WINNT=0x0501;$(ArmPreprocessorDefinitions);$(UnicodePreprocessorDefinitions);_CRT_STDIO_LEGACY_WIDE_SPECIFIERS;_WINSOCK_DEPRECATED_NO_WARNINGS;%(PreprocessorDefinitions) + Use + precomp.h + StdCall + true + false + -YlprecompDefine + /Zc:threadSafeInit- %(AdditionalOptions) + true + + + $(ArmPreprocessorDefinitions);%(PreprocessorDefinitions) + $(ProjectAdditionalResourceIncludeDirectories);%(AdditionalIncludeDirectories) + + + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ProjectAdditionalLibraryDirectories);%(AdditionalLibraryDirectories) + + + $(ProjectSubSystem) + $(ProjectModuleDefinitionFile) + $(ResourceOnlyDll) + true + $(ProjectAdditionalLinkLibraries);advapi32.lib;comdlg32.lib;user32.lib;oleaut32.lib;gdi32.lib;shell32.lib;ole32.lib;version.lib;%(AdditionalDependencies) + $(OutDir);$(AdditionalMultiTargetLibraryPath);$(ArmLibraryDirectories);$(ProjectAdditionalLinkLibraryDirectories);%(AdditionalLibraryDirectories) + /IGNORE:4099 %(AdditionalOptions) + + + + + + NoExtensions + + + + + CDecl + + + + + OldStyle + true + true + + + + + Disabled + EnableFastChecks + _DEBUG;DEBUG;%(PreprocessorDefinitions) + MultiThreadedDebug + + + + + + MultiThreadedDebugDll + + + + + MinSpace + NDEBUG;%(PreprocessorDefinitions) + true + true + MultiThreaded + + + true + true + + + + + + MultiThreadedDll + + + + + $(LinkKeyFile) + $(LinkDelaySign) + + + diff --git a/src/ext/Sql/README.md b/src/ext/Sql/README.md new file mode 100644 index 00000000..377c9032 --- /dev/null +++ b/src/ext/Sql/README.md @@ -0,0 +1,2 @@ +# Sql.wixext +WixToolset.Sql.wixext - Sql WiX Toolset Extension diff --git a/src/ext/Sql/Sql.wixext.sln b/src/ext/Sql/Sql.wixext.sln new file mode 100644 index 00000000..cfa9ad4f --- /dev/null +++ b/src/ext/Sql/Sql.wixext.sln @@ -0,0 +1,59 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30204.135 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqlca", "src\ca\sqlca.vcxproj", "{4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}" +EndProject +Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "sql", "src\wixlib\sql.wixproj", "{9ACF1A20-D801-45CC-A463-F9D13E506AA3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolset.Sql.wixext", "src\wixext\WixToolset.Sql.wixext.csproj", "{0E05519A-0045-4AEC-BD0C-D9205FF1468F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WixToolsetTest.Sql", "src\test\WixToolsetTest.Sql\WixToolsetTest.Sql.csproj", "{FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Debug|Any CPU.Build.0 = Debug|Win32 + {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Debug|x86.ActiveCfg = Debug|Win32 + {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Debug|x86.Build.0 = Debug|Win32 + {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Release|Any CPU.ActiveCfg = Release|Win32 + {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Release|x86.ActiveCfg = Release|Win32 + {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935}.Release|x86.Build.0 = Release|Win32 + {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Debug|Any CPU.ActiveCfg = Debug|x86 + {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Debug|Any CPU.Build.0 = Debug|x86 + {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Debug|x86.ActiveCfg = Debug|x86 + {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Debug|x86.Build.0 = Debug|x86 + {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Release|Any CPU.ActiveCfg = Release|x86 + {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Release|x86.ActiveCfg = Release|x86 + {9ACF1A20-D801-45CC-A463-F9D13E506AA3}.Release|x86.Build.0 = Release|x86 + {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Debug|x86.ActiveCfg = Debug|Any CPU + {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Debug|x86.Build.0 = Debug|Any CPU + {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Release|Any CPU.Build.0 = Release|Any CPU + {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Release|x86.ActiveCfg = Release|Any CPU + {0E05519A-0045-4AEC-BD0C-D9205FF1468F}.Release|x86.Build.0 = Release|Any CPU + {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Debug|x86.ActiveCfg = Debug|Any CPU + {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Debug|x86.Build.0 = Debug|Any CPU + {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Release|Any CPU.Build.0 = Release|Any CPU + {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Release|x86.ActiveCfg = Release|Any CPU + {FE72A369-03CA-4EBC-BC7B-A8BBF5BBD3E0}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DEFEE3BB-E557-4B77-A85C-ECA19D6F5DF5} + EndGlobalSection +EndGlobal diff --git a/src/ext/Sql/appveyor.cmd b/src/ext/Sql/appveyor.cmd new file mode 100644 index 00000000..f21449d2 --- /dev/null +++ b/src/ext/Sql/appveyor.cmd @@ -0,0 +1,19 @@ +@setlocal +@pushd %~dp0 +@set _C=Release +@if /i "%1"=="debug" set _C=Debug + +:: Restore +msbuild -p:Configuration=%_C% -t:Restore || exit /b + +:: Build +msbuild -p:Configuration=%_C% src\test\WixToolsetTest.Sql\WixToolsetTest.Sql.csproj || exit /b + +:: Test +dotnet test -c %_C% --no-build src\test\WixToolsetTest.Sql || exit /b + +:: Pack +msbuild -p:Configuration=%_C% -p:NoBuild=true -t:Pack src\wixext\WixToolset.Sql.wixext.csproj || exit /b + +@popd +@endlocal diff --git a/src/ext/Sql/appveyor.yml b/src/ext/Sql/appveyor.yml new file mode 100644 index 00000000..7c686b04 --- /dev/null +++ b/src/ext/Sql/appveyor.yml @@ -0,0 +1,40 @@ +# Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. +# +# Do NOT modify this file. Update the canonical version in Home\repo-template\src\appveyor.yml +# then update all of the repos. + +branches: + only: + - master + - develop + +image: Visual Studio 2019 + +version: 0.0.0.{build} +configuration: Release + +environment: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: 1 + NUGET_XMLDOC_MODE: skip + +build_script: + - appveyor.cmd + +pull_requests: + do_not_increment_build_number: true + +nuget: + disable_publish_on_pr: true + +skip_branch_with_pr: true +skip_tags: true + +artifacts: +- path: build\Release\**\*.nupkg + name: nuget + +notifications: +- provider: Slack + incoming_webhook: + secure: p5xuu+4x2JHfwGDMDe5KcG1k7gZxqYc4jWVwvyNZv5cvkubPD2waJs5yXMAXZNN7Z63/3PWHb7q4KoY/99AjauYa1nZ4c5qYqRPFRBKTHfA= diff --git a/src/ext/Sql/ca/CustomMsiErrors.h b/src/ext/Sql/ca/CustomMsiErrors.h new file mode 100644 index 00000000..b568d01c --- /dev/null +++ b/src/ext/Sql/ca/CustomMsiErrors.h @@ -0,0 +1,10 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#define msierrSQLFailedCreateDatabase 26201 +#define msierrSQLFailedDropDatabase 26202 +#define msierrSQLFailedConnectDatabase 26203 +#define msierrSQLFailedExecString 26204 +#define msierrSQLDatabaseAlreadyExists 26205 + +//Last available is 26250 \ No newline at end of file diff --git a/src/ext/Sql/ca/caDecor.h b/src/ext/Sql/ca/caDecor.h new file mode 100644 index 00000000..da274650 --- /dev/null +++ b/src/ext/Sql/ca/caDecor.h @@ -0,0 +1,13 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +#if defined(_M_ARM64) +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_A64" +#elif defined(_M_AMD64) +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_X64" +#elif defined(_M_ARM) +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_ARM" +#else +#define CUSTOM_ACTION_DECORATION(f) L"Wix4" f L"_X86" +#endif diff --git a/src/ext/Sql/ca/dllmain.cpp b/src/ext/Sql/ca/dllmain.cpp new file mode 100644 index 00000000..35ae6d1c --- /dev/null +++ b/src/ext/Sql/ca/dllmain.cpp @@ -0,0 +1,26 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +/******************************************************************** +DllMain - standard entry point for all WiX custom actions + +********************************************************************/ +extern "C" BOOL WINAPI DllMain( + IN HINSTANCE hInst, + IN ULONG ulReason, + IN LPVOID) +{ + switch(ulReason) + { + case DLL_PROCESS_ATTACH: + WcaGlobalInitialize(hInst); + break; + + case DLL_PROCESS_DETACH: + WcaGlobalFinalize(); + break; + } + + return TRUE; +} diff --git a/src/ext/Sql/ca/precomp.h b/src/ext/Sql/ca/precomp.h new file mode 100644 index 00000000..266d543c --- /dev/null +++ b/src/ext/Sql/ca/precomp.h @@ -0,0 +1,28 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +#if _WIN32_MSI < 150 +#define _WIN32_MSI 150 +#endif + +#include +#include + +#include + +#define MAXUINT USHRT_MAX + +#include "wcautil.h" +#include "fileutil.h" +#include "memutil.h" +#include "strutil.h" +#include "wiutil.h" + +#include "CustomMsiErrors.h" + +#include "sca.h" +#include "scacost.h" +#include "scasqlstr.h" + +#include "caDecor.h" diff --git a/src/ext/Sql/ca/sca.h b/src/ext/Sql/ca/sca.h new file mode 100644 index 00000000..bc36344e --- /dev/null +++ b/src/ext/Sql/ca/sca.h @@ -0,0 +1,33 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +// Generic action enum. +enum SCA_ACTION +{ + SCA_ACTION_NONE, + SCA_ACTION_INSTALL, + SCA_ACTION_UNINSTALL +}; + +// sql database attributes definitions +enum SCADB_ATTRIBUTES +{ + SCADB_CREATE_ON_INSTALL = 0x00000001, + SCADB_DROP_ON_UNINSTALL = 0x00000002, + SCADB_CONTINUE_ON_ERROR = 0x00000004, + SCADB_DROP_ON_INSTALL = 0x00000008, + SCADB_CREATE_ON_UNINSTALL = 0x00000010, + SCADB_CONFIRM_OVERWRITE = 0x00000020, + SCADB_CREATE_ON_REINSTALL = 0x00000040, + SCADB_DROP_ON_REINSTALL = 0x00000080, +}; + +// sql string/script attributes definitions +enum SCASQL_ATTRIBUTES +{ + SCASQL_EXECUTE_ON_INSTALL = 0x00000001, + SCASQL_EXECUTE_ON_UNINSTALL = 0x00000002, + SCASQL_CONTINUE_ON_ERROR = 0x00000004, + SCASQL_ROLLBACK = 0x00000008, + SCASQL_EXECUTE_ON_REINSTALL = 0x00000010, +}; diff --git a/src/ext/Sql/ca/scacost.h b/src/ext/Sql/ca/scacost.h new file mode 100644 index 00000000..6ea7e465 --- /dev/null +++ b/src/ext/Sql/ca/scacost.h @@ -0,0 +1,7 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +const UINT COST_SQL_CREATEDB = 10000; +const UINT COST_SQL_DROPDB = 5000; +const UINT COST_SQL_CONNECTDB = 5000; +const UINT COST_SQL_STRING = 5000; diff --git a/src/ext/Sql/ca/scadb.cpp b/src/ext/Sql/ca/scadb.cpp new file mode 100644 index 00000000..288b9efe --- /dev/null +++ b/src/ext/Sql/ca/scadb.cpp @@ -0,0 +1,588 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +// sql queries +LPCWSTR vcsSqlDatabaseQuery = L"SELECT `SqlDb`, `Server`, `Instance`, `Database`, " + L"`Component_`, `User_`, `FileSpec_`, `FileSpec_Log`, `Attributes` " + L"FROM `Wix4SqlDatabase`"; +enum eSqlDatabaseQuery { sdqSqlDb = 1, sdqServer, sdqInstance, sdqDatabase, + sdqComponent, sdqUser, sdqDbFileSpec, sdqLogFileSpec, sdqAttributes }; + +LPCWSTR vcsSqlFileSpecQuery = L"SELECT `FileSpec`, `Name`, `Filename`, `Size`, " + L"`MaxSize`, `GrowthSize` FROM `Wix4SqlFileSpec` WHERE `FileSpec`=?"; +enum eSqlFileSpecQuery { sfsqFileSpec = 1, sfsqName, sfsqFilename, sfsqSize, + sfsqMaxSize, sfsqGrowth }; + + +// prototypes for private helper functions +static HRESULT NewDb( + __out SCA_DB** ppsd + ); + +static SCA_DB* AddDbToList( + __in SCA_DB* psdList, + __in SCA_DB* psd + ); + +static HRESULT SchedCreateDatabase( + __in SCA_DB* psd + ); + +static HRESULT SchedDropDatabase( + __in LPCWSTR wzKey, LPCWSTR wzServer, + __in LPCWSTR wzInstance, + __in LPCWSTR wzDatabase, + __in int iAttributes, + __in BOOL fIntegratedAuth, + __in LPCWSTR wzUser, + __in LPCWSTR wzPassword + ); + +static HRESULT GetFileSpec( + __in MSIHANDLE hViewFileSpec, + __in LPCWSTR wzKey, + __in SQL_FILESPEC* psf + ); + + +HRESULT ScaDbsRead( + __inout SCA_DB** ppsdList, + __in SCA_ACTION saAction + ) +{ + HRESULT hr = S_OK; + UINT er = ERROR_SUCCESS; + PMSIHANDLE hView; + PMSIHANDLE hRec; + PMSIHANDLE hViewFileSpec = NULL; + + LPWSTR pwzData = NULL; + LPWSTR pwzId = NULL; + LPWSTR pwzComponent = NULL; + + SCA_DB* psd = NULL; + + if (S_OK != WcaTableExists(L"Wix4SqlDatabase")) + { + WcaLog(LOGMSG_VERBOSE, "Skipping ScaCreateDatabase() - Wix4SqlDatabase table not present"); + ExitFunction1(hr = S_FALSE); + } + + if (S_OK == WcaTableExists(L"Wix4SqlFileSpec")) + { + hr = WcaOpenView(vcsSqlFileSpecQuery, &hViewFileSpec); + ExitOnFailure(hr, "failed to open view on Wix4SqlFileSpec table"); + } + + // loop through all the sql databases + hr = WcaOpenExecuteView(vcsSqlDatabaseQuery, &hView); + ExitOnFailure(hr, "Failed to open view on Wix4SqlDatabase table"); + while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) + { + BOOL fHasComponent = FALSE; + INSTALLSTATE isInstalled = INSTALLSTATE_UNKNOWN; + INSTALLSTATE isAction = INSTALLSTATE_UNKNOWN; + + hr = WcaGetRecordString(hRec, sdqSqlDb, &pwzId); + ExitOnFailure(hr, "Failed to get Wix4SqlDatabase.SqlDb"); + + hr = WcaGetRecordString(hRec, sdqComponent, &pwzComponent); + ExitOnFailure(hr, "Failed to get Component for database: '%ls'", psd->wzKey); + if (pwzComponent && *pwzComponent) + { + fHasComponent = TRUE; + + er = ::MsiGetComponentStateW(WcaGetInstallHandle(), pwzComponent, &isInstalled, &isAction); + hr = HRESULT_FROM_WIN32(er); + ExitOnFailure(hr, "Failed to get state for component: %ls", pwzComponent); + + // If we're doing install but the Component is not being installed or we're doing + // uninstall but the Component is not being uninstalled, skip it. + if ((WcaIsInstalling(isInstalled, isAction) && SCA_ACTION_INSTALL != saAction) || + (WcaIsUninstalling(isInstalled, isAction) && SCA_ACTION_UNINSTALL != saAction)) + { + continue; + } + } + + hr = NewDb(&psd); + ExitOnFailure(hr, "Failed to allocate memory for new database: %D", pwzId); + + hr = ::StringCchCopyW(psd->wzKey, countof(psd->wzKey), pwzId); + ExitOnFailure(hr, "Failed to copy Wix4SqlDatabase.SqlDbL: %ls", pwzId); + + hr = ::StringCchCopyW(psd->wzComponent, countof(psd->wzComponent), pwzComponent); + ExitOnFailure(hr, "Failed to copy Wix4SqlDatabase.Component_: %ls", pwzComponent); + + psd->fHasComponent = fHasComponent; + psd->isInstalled = isInstalled; + psd->isAction = isAction; + + hr = WcaGetRecordFormattedString(hRec, sdqServer, &pwzData); + ExitOnFailure(hr, "Failed to get Server for database: '%ls'", psd->wzKey); + hr = ::StringCchCopyW(psd->wzServer, countof(psd->wzServer), pwzData); + ExitOnFailure(hr, "Failed to copy server string to database object:%ls", pwzData); + + hr = WcaGetRecordFormattedString(hRec, sdqInstance, &pwzData); + ExitOnFailure(hr, "Failed to get Instance for database: '%ls'", psd->wzKey); + hr = ::StringCchCopyW(psd->wzInstance, countof(psd->wzInstance), pwzData); + ExitOnFailure(hr, "Failed to copy instance string to database object:%ls", pwzData); + + hr = WcaGetRecordFormattedString(hRec, sdqDatabase, &pwzData); + ExitOnFailure(hr, "Failed to get Database for database: '%ls'", psd->wzKey); + hr = ::StringCchCopyW(psd->wzDatabase, countof(psd->wzDatabase), pwzData); + ExitOnFailure(hr, "Failed to copy database string to database object:%ls", pwzData); + + hr = WcaGetRecordInteger(hRec, sdqAttributes, &psd->iAttributes); + ExitOnFailure(hr, "Failed to get Wix4SqlDatabase.Attributes"); + + hr = WcaGetRecordFormattedString(hRec, sdqUser, &pwzData); + ExitOnFailure(hr, "Failed to get User record for database: '%ls'", psd->wzKey); + + // if a user was specified + if (*pwzData) + { + psd->fUseIntegratedAuth = FALSE; + hr = ScaGetUser(pwzData, &psd->scau); + ExitOnFailure(hr, "Failed to get user information for database: '%ls'", psd->wzKey); + } + else + { + psd->fUseIntegratedAuth = TRUE; + // integrated authorization doesn't have a User record + } + + hr = WcaGetRecordString(hRec, sdqDbFileSpec, &pwzData); + ExitOnFailure(hr, "Failed to get Database FileSpec for database: '%ls'", psd->wzKey); + + // if a database filespec was specified + if (*pwzData) + { + hr = GetFileSpec(hViewFileSpec, pwzData, &psd->sfDb); + ExitOnFailure(hr, "failed to get FileSpec for: %ls", pwzData); + if (S_OK == hr) + { + psd->fHasDbSpec = TRUE; + } + } + + hr = WcaGetRecordString(hRec, sdqLogFileSpec, &pwzData); + ExitOnFailure(hr, "Failed to get Log FileSpec for database: '%ls'", psd->wzKey); + + // if a log filespec was specified + if (*pwzData) + { + hr = GetFileSpec(hViewFileSpec, pwzData, &psd->sfLog); + ExitOnFailure(hr, "failed to get FileSpec for: %ls", pwzData); + if (S_OK == hr) + { + psd->fHasLogSpec = TRUE; + } + } + + *ppsdList = AddDbToList(*ppsdList, psd); + psd = NULL; // set the db NULL so it doesn't accidentally get freed below + } + + if (E_NOMOREITEMS == hr) + { + hr = S_OK; + } + ExitOnFailure(hr, "Failure occured while processing Wix4SqlDatabase table"); + +LExit: + if (psd) + { + ScaDbsFreeList(psd); + } + + ReleaseStr(pwzComponent); + ReleaseStr(pwzId); + ReleaseStr(pwzData); + return hr; +} + + +SCA_DB* ScaDbsFindDatabase( + __in LPCWSTR wzSqlDb, + __in SCA_DB* psdList + ) +{ + SCA_DB* psd = NULL; + + for (psd = psdList; psd; psd = psd->psdNext) + { + if (0 == lstrcmpW(wzSqlDb, psd->wzKey)) + { + break; + } + } + + return psd; +} + + +HRESULT ScaDbsInstall( + __in SCA_DB* psdList + ) +{ + HRESULT hr = S_FALSE; // assume nothing will be done + SCA_DB* psd = NULL; + + for (psd = psdList; psd; psd = psd->psdNext) + { + if (psd->fHasComponent) + { + // if we need to drop, do that first + if (((psd->iAttributes & SCADB_DROP_ON_INSTALL) && WcaIsInstalling(psd->isInstalled, psd->isAction) && !WcaIsReInstalling(psd->isInstalled, psd->isAction)) || + ((psd->iAttributes & SCADB_DROP_ON_REINSTALL) && WcaIsReInstalling(psd->isInstalled, psd->isAction))) + { + hr = SchedDropDatabase(psd->wzKey, psd->wzServer, psd->wzInstance, psd->wzDatabase, psd->iAttributes, psd->fUseIntegratedAuth, psd->scau.wzName, psd->scau.wzPassword); + ExitOnFailure(hr, "Failed to drop database %ls", psd->wzKey); + } + + // if installing this component + if (((psd->iAttributes & SCADB_CREATE_ON_INSTALL) && WcaIsInstalling(psd->isInstalled, psd->isAction) && !WcaIsReInstalling(psd->isInstalled, psd->isAction)) || + ((psd->iAttributes & SCADB_CREATE_ON_REINSTALL) && WcaIsReInstalling(psd->isInstalled, psd->isAction))) + { + hr = SchedCreateDatabase(psd); + ExitOnFailure(hr, "Failed to ensure database %ls exists", psd->wzKey); + } + } + } + +LExit: + return hr; +} + + +HRESULT ScaDbsUninstall( + __in SCA_DB* psdList + ) +{ + HRESULT hr = S_FALSE; // assume nothing will be done + SCA_DB* psd = NULL; + + for (psd = psdList; psd; psd = psd->psdNext) + { + if (psd->fHasComponent) + { + // if we need to drop do that first + if ((psd->iAttributes & SCADB_DROP_ON_UNINSTALL) && WcaIsUninstalling(psd->isInstalled, psd->isAction)) + { + hr = SchedDropDatabase(psd->wzKey, psd->wzServer, psd->wzInstance, psd->wzDatabase, psd->iAttributes, psd->fUseIntegratedAuth, psd->scau.wzName, psd->scau.wzPassword); + ExitOnFailure(hr, "Failed to drop database %ls", psd->wzKey); + } + + // install the db + if ((psd->iAttributes & SCADB_CREATE_ON_UNINSTALL) && WcaIsUninstalling(psd->isInstalled, psd->isAction)) + { + hr = SchedCreateDatabase(psd); + ExitOnFailure(hr, "Failed to ensure database %ls exists", psd->wzKey); + } + } + } + +LExit: + return hr; +} + + +void ScaDbsFreeList( + __in SCA_DB* psdList + ) +{ + SCA_DB* psdDelete = psdList; + while (psdList) + { + psdDelete = psdList; + psdList = psdList->psdNext; + + MemFree(psdDelete); + } +} + + +// private helper functions + +static HRESULT NewDb( + __out SCA_DB** ppsd + ) +{ + HRESULT hr = S_OK; + SCA_DB* psd = static_cast(MemAlloc(sizeof(SCA_DB), TRUE)); + ExitOnNull(psd, hr, E_OUTOFMEMORY, "failed to allocate memory for new database element"); + + *ppsd = psd; + +LExit: + return hr; +} + + +static SCA_DB* AddDbToList( + __in SCA_DB* psdList, + __in SCA_DB* psd + ) +{ + if (psdList) + { + SCA_DB* psdT = psdList; + while (psdT->psdNext) + { + psdT = psdT->psdNext; + } + + psdT->psdNext = psd; + } + else + { + psdList = psd; + } + + return psdList; +} + + +static HRESULT SchedCreateDatabase( + __in SCA_DB* psd + ) +{ + HRESULT hr = S_OK; + WCHAR* pwzCustomActionData = NULL; + + hr = WcaWriteStringToCaData(psd->wzKey, &pwzCustomActionData); + ExitOnFailure(hr, "failed to add DBKey to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->wzServer, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add server name to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->wzInstance, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add server instance to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->wzDatabase, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add database name to CustomActionData"); + + hr = WcaWriteIntegerToCaData(psd->iAttributes, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add Sql attributes to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->fUseIntegratedAuth ? L"1" : L"0", &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add if integrated connection to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->scau.wzName, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add server user to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->scau.wzPassword, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add user password to CustomActionData"); + + // Check to see if the database exists, if it does not then schedule a rollback + // so we clean up after ourselves if the creation of the database fails or is + // aborted. It is interesting to note that we can do this check here because the + // deferred CustomActions are Impersonated. That means this scheduling action and + // the execution actions all run with the same user context, so it is safe to + // to do the check. + hr = SqlDatabaseExists(psd->wzServer, psd->wzInstance, psd->wzDatabase, psd->fUseIntegratedAuth, psd->scau.wzName, psd->scau.wzPassword, NULL); + if (S_FALSE == hr) + { + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"RollbackCreateDatabase"), pwzCustomActionData, COST_SQL_CREATEDB); + ExitOnFailure(hr, "Failed to schedule RollbackCreateDatabase action"); + } + + // database filespec + if (psd->fHasDbSpec) + { + hr = WcaWriteStringToCaData(L"1", &pwzCustomActionData); + ExitOnFailure(hr, "failed to specify that do have db.filespec to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfDb.wzName, &pwzCustomActionData); + ExitOnFailure(hr, "failed to add FileSpec.Name to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfDb.wzFilename, &pwzCustomActionData); + ExitOnFailure(hr, "failed to add FileSpec.Filename to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfDb.wzSize, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add FileSpec.Size to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfDb.wzMaxSize, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add FileSpec.MaxSize to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfDb.wzGrow, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add FileSpec.GrowthSize to CustomActionData"); + } + else + { + hr = WcaWriteStringToCaData(L"0", &pwzCustomActionData); + ExitOnFailure(hr, "failed to specify that do not have db.filespec to CustomActionData"); + } + + // log filespec + if (psd->fHasLogSpec) + { + hr = WcaWriteStringToCaData(L"1", &pwzCustomActionData); + ExitOnFailure(hr, "failed to specify that do have log.filespec to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfLog.wzName, &pwzCustomActionData); + ExitOnFailure(hr, "failed to add FileSpec.Name to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfLog.wzFilename, &pwzCustomActionData); + ExitOnFailure(hr, "failed to add FileSpec.Filename to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfLog.wzSize, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add FileSpec.Size to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfLog.wzMaxSize, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add FileSpec.MaxSize to CustomActionData"); + + hr = WcaWriteStringToCaData(psd->sfLog.wzGrow, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add FileSpec.GrowthSize to CustomActionData"); + } + else + { + hr = WcaWriteStringToCaData(L"0", &pwzCustomActionData); + ExitOnFailure(hr, "failed to specify that do not have log.filespec to CustomActionData"); + } + + // schedule the CreateDatabase action + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"CreateDatabase"), pwzCustomActionData, COST_SQL_CREATEDB); + ExitOnFailure(hr, "Failed to schedule CreateDatabase action"); + +LExit: + ReleaseStr(pwzCustomActionData); + return hr; +} + + +HRESULT SchedDropDatabase( + __in LPCWSTR wzKey, + __in LPCWSTR wzServer, + __in LPCWSTR wzInstance, + __in LPCWSTR wzDatabase, + __in int iAttributes, + __in BOOL fIntegratedAuth, + __in LPCWSTR wzUser, + __in LPCWSTR wzPassword + ) +{ + HRESULT hr = S_OK; + WCHAR* pwzCustomActionData = NULL; + + hr = WcaWriteStringToCaData(wzKey, &pwzCustomActionData); + ExitOnFailure(hr, "failed to add DBKey to CustomActionData"); + + hr = WcaWriteStringToCaData(wzServer, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add server name to CustomActionData"); + + hr = WcaWriteStringToCaData(wzInstance, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add server instance to CustomActionData"); + + hr = WcaWriteStringToCaData(wzDatabase, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add database name to CustomActionData"); + + hr = WcaWriteIntegerToCaData(iAttributes, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add server name to CustomActionData"); + + hr = WcaWriteStringToCaData(fIntegratedAuth ? L"1" : L"0", &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add server name to CustomActionData"); + + hr = WcaWriteStringToCaData(wzUser, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add server user to CustomActionData"); + + hr = WcaWriteStringToCaData(wzPassword, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add user password to CustomActionData"); + + hr = WcaDoDeferredAction(CUSTOM_ACTION_DECORATION(L"DropDatabase"), pwzCustomActionData, COST_SQL_DROPDB); + ExitOnFailure(hr, "Failed to schedule DropDatabase action"); + +LExit: + ReleaseStr(pwzCustomActionData); + return hr; +} + + +HRESULT GetFileSpec( + __in MSIHANDLE hViewFileSpec, + __in LPCWSTR wzKey, + __in SQL_FILESPEC* psf + ) +{ + HRESULT hr = S_OK; + PMSIHANDLE hRecFileSpec, hRec; + LPWSTR pwzData = NULL; + + // create a record to do the fetch + hRecFileSpec = ::MsiCreateRecord(1); + if (!hRecFileSpec) + { + ExitOnFailure(hr = E_UNEXPECTED, "failed to create record for filespec: %ls", wzKey); + } + hr = WcaSetRecordString(hRecFileSpec, 1, wzKey); + ExitOnFailure(hr, "failed to set record string for filespec: %ls", wzKey); + + // get the FileSpec record + hr = WcaExecuteView(hViewFileSpec, hRecFileSpec); + ExitOnFailure(hr, "failed to execute view on Wix4SqlFileSpec table for filespec: %ls", wzKey); + hr = WcaFetchSingleRecord(hViewFileSpec, &hRec); + ExitOnFailure(hr, "failed to get record for filespec: %ls", wzKey); + + // read the data out of the filespec record + hr = WcaGetRecordFormattedString(hRec, sfsqName, &pwzData); + ExitOnFailure(hr, "Failed to get Wix4SqlFileSpec.Name for filespec: %ls", wzKey); + hr = ::StringCchCopyW(psf->wzName, countof(psf->wzName), pwzData); + ExitOnFailure(hr, "Failed to copy Wix4SqlFileSpec.Name string: %ls", pwzData); + + hr = WcaGetRecordFormattedString(hRec, sfsqFilename, &pwzData); + ExitOnFailure(hr, "Failed to get Wix4SqlFileSpec.Filename for filespec: %ls", wzKey); + if (*pwzData) + { + hr = ::StringCchCopyW(psf->wzFilename, countof(psf->wzFilename), pwzData); + ExitOnFailure(hr, "Failed to copy filename to filespec object: %ls", pwzData); + } + else // if there is no file, skip this FILESPEC + { + WcaLog(LOGMSG_VERBOSE, "No filename specified, skipping FileSpec: %ls", psf->wzName); + ExitFunction1(hr = S_FALSE); + } + + hr = WcaGetRecordFormattedString(hRec, sfsqSize, &pwzData); + ExitOnFailure(hr, "Failed to get Wix4SqlFileSpec.Size for filespec: %ls", wzKey); + if (*pwzData) + { + hr = ::StringCchCopyW(psf->wzSize, countof(psf->wzSize), pwzData); + ExitOnFailure(hr, "Failed to copy size to filespec object: %ls", pwzData); + } + else + { + psf->wzSize[0] = 0; + } + + hr = WcaGetRecordFormattedString(hRec, sfsqMaxSize, &pwzData); + ExitOnFailure(hr, "Failed to get Wix4SqlFileSpec.MaxSize for filespec: %ls", wzKey); + if (*pwzData) + { + hr = ::StringCchCopyW(psf->wzMaxSize, countof(psf->wzMaxSize), pwzData); + ExitOnFailure(hr, "Failed to copy max size to filespec object: %ls", pwzData); + } + else + { + psf->wzMaxSize[0] = 0; + } + + hr = WcaGetRecordFormattedString(hRec, sfsqGrowth, &pwzData); + ExitOnFailure(hr, "Failed to get Wix4SqlFileSpec.GrowthSize for filespec: %ls", wzKey); + if (*pwzData) + { + hr = ::StringCchCopyW(psf->wzGrow, countof(psf->wzGrow), pwzData); + ExitOnFailure(hr, "Failed to copy growth size to filespec object: %ls", pwzData); + } + else + { + psf->wzGrow[0] = 0; + } + + hr = S_OK; + +LExit: + ReleaseStr(pwzData); + return hr; +} diff --git a/src/ext/Sql/ca/scadb.h b/src/ext/Sql/ca/scadb.h new file mode 100644 index 00000000..885e84c2 --- /dev/null +++ b/src/ext/Sql/ca/scadb.h @@ -0,0 +1,55 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +#include "scauser.h" +#include "sqlutil.h" + +struct SCA_DB +{ + // darwin information + WCHAR wzKey[MAX_DARWIN_KEY + 1]; + BOOL fHasComponent; + WCHAR wzComponent[MAX_DARWIN_KEY + 1]; + INSTALLSTATE isInstalled, isAction; + + WCHAR wzServer[MAX_DARWIN_COLUMN + 1]; + WCHAR wzInstance[MAX_DARWIN_COLUMN + 1]; + WCHAR wzDatabase[MAX_DARWIN_COLUMN + 1]; + + int iAttributes; + + BOOL fUseIntegratedAuth; + SCA_USER scau; + + BOOL fHasDbSpec; + SQL_FILESPEC sfDb; + BOOL fHasLogSpec; + SQL_FILESPEC sfLog; + + SCA_DB* psdNext; +}; + + +// prototypes +HRESULT ScaDbsRead( + __inout SCA_DB** ppsdList, + __in SCA_ACTION saAction + ); + +SCA_DB* ScaDbsFindDatabase( + __in LPCWSTR wzSqlDb, + __in SCA_DB* psdList + ); + +HRESULT ScaDbsInstall( + __in SCA_DB* psdList + ); + +HRESULT ScaDbsUninstall( + __in SCA_DB* psdList + ); + +void ScaDbsFreeList( + __in SCA_DB* psdList + ); diff --git a/src/ext/Sql/ca/scaexec.cpp b/src/ext/Sql/ca/scaexec.cpp new file mode 100644 index 00000000..b2648361 --- /dev/null +++ b/src/ext/Sql/ca/scaexec.cpp @@ -0,0 +1,393 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + + +/******************************************************************** + * CreateDatabase - CUSTOM ACTION ENTRY POINT for creating databases + * + * Input: deferred CustomActionData - DbKey\tServer\tInstance\tDatabase\tAttributes\tIntegratedAuth\tUser\tPassword + * ****************************************************************/ +extern "C" UINT __stdcall CreateDatabase(MSIHANDLE hInstall) +{ +//AssertSz(FALSE, "debug CreateDatabase here"); + UINT er = ERROR_SUCCESS; + HRESULT hr = S_OK; + + LPWSTR pwzData = NULL; + IDBCreateSession* pidbSession = NULL; + BSTR bstrErrorDescription = NULL; + LPWSTR pwz = NULL; + LPWSTR pwzDatabaseKey = NULL; + LPWSTR pwzServer = NULL; + LPWSTR pwzInstance = NULL; + LPWSTR pwzDatabase = NULL; + LPWSTR pwzTemp = NULL; + int iAttributes; + BOOL fIntegratedAuth; + LPWSTR pwzUser = NULL; + LPWSTR pwzPassword = NULL; + BOOL fHaveDbFileSpec = FALSE; + SQL_FILESPEC sfDb; + BOOL fHaveLogFileSpec = FALSE; + SQL_FILESPEC sfLog; + BOOL fInitializedCom = FALSE; + + memset(&sfDb, 0, sizeof(sfDb)); + memset(&sfLog, 0, sizeof(sfLog)); + + hr = WcaInitialize(hInstall, "CreateDatabase"); + ExitOnFailure(hr, "failed to initialize"); + + hr = ::CoInitialize(NULL); + ExitOnFailure(hr, "failed to intialize COM"); + fInitializedCom = TRUE; + + hr = WcaGetProperty( L"CustomActionData", &pwzData); + ExitOnFailure(hr, "failed to get CustomActionData"); + + WcaLog(LOGMSG_TRACEONLY, "CustomActionData: %ls", pwzData); + + pwz = pwzData; + hr = WcaReadStringFromCaData(&pwz, &pwzDatabaseKey); // SQL Server + ExitOnFailure(hr, "failed to read database key from custom action data: %ls", pwz); + hr = WcaReadStringFromCaData(&pwz, &pwzServer); // SQL Server + ExitOnFailure(hr, "failed to read server from custom action data: %ls", pwz); + hr = WcaReadStringFromCaData(&pwz, &pwzInstance); // SQL Server Instance + ExitOnFailure(hr, "failed to read server instance from custom action data: %ls", pwz); + hr = WcaReadStringFromCaData(&pwz, &pwzDatabase); // SQL Database + ExitOnFailure(hr, "failed to read server instance from custom action data: %ls", pwz); + hr = WcaReadIntegerFromCaData(&pwz, &iAttributes); + ExitOnFailure(hr, "failed to read attributes from custom action data: %ls", pwz); + hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast(&fIntegratedAuth)); // Integrated Windows Authentication? + ExitOnFailure(hr, "failed to read integrated auth flag from custom action data: %ls", pwz); + hr = WcaReadStringFromCaData(&pwz, &pwzUser); // SQL User + ExitOnFailure(hr, "failed to read user from custom action data: %ls", pwz); + hr = WcaReadStringFromCaData(&pwz, &pwzPassword); // SQL User Password + ExitOnFailure(hr, "failed to read user from custom action data: %ls", pwz); + + // db file spec + hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast(&fHaveDbFileSpec)); + ExitOnFailure(hr, "failed to read db file spec from custom action data: %ls", pwz); + + if (fHaveDbFileSpec) + { + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read db file spec name from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfDb.wzName, countof(sfDb.wzName), pwzTemp); + ExitOnFailure(hr, "failed to copy db file spec name: %ls", pwzTemp); + + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read db file spec filename from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfDb.wzFilename, countof(sfDb.wzFilename), pwzTemp); + ExitOnFailure(hr, "failed to copy db file spec filename: %ls", pwzTemp); + + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read db file spec size from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfDb.wzSize, countof(sfDb.wzSize), pwzTemp); + ExitOnFailure(hr, "failed to copy db file spec size value: %ls", pwzTemp); + + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read db file spec max size from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfDb.wzMaxSize, countof(sfDb.wzMaxSize), pwzTemp); + ExitOnFailure(hr, "failed to copy db file spec max size: %ls", pwzTemp); + + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read db file spec grow from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfDb.wzGrow, countof(sfDb.wzGrow), pwzTemp); + ExitOnFailure(hr, "failed to copy db file spec grow value: %ls", pwzTemp); + } + + // log file spec + hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast(&fHaveLogFileSpec)); + ExitOnFailure(hr, "failed to read log file spec from custom action data: %ls", pwz); + if (fHaveLogFileSpec) + { + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read log file spec name from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfLog.wzName, countof(sfDb.wzName), pwzTemp); + ExitOnFailure(hr, "failed to copy log file spec name: %ls", pwzTemp); + + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read log file spec filename from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfLog.wzFilename, countof(sfDb.wzFilename), pwzTemp); + ExitOnFailure(hr, "failed to copy log file spec filename: %ls", pwzTemp); + + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read log file spec size from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfLog.wzSize, countof(sfDb.wzSize), pwzTemp); + ExitOnFailure(hr, "failed to copy log file spec size value: %ls", pwzTemp); + + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read log file spec max size from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfLog.wzMaxSize, countof(sfDb.wzMaxSize), pwzTemp); + ExitOnFailure(hr, "failed to copy log file spec max size: %ls", pwzTemp); + + hr = WcaReadStringFromCaData(&pwz, &pwzTemp); + ExitOnFailure(hr, "failed to read log file spec grow from custom action data: %ls", pwz); + hr = ::StringCchCopyW(sfLog.wzGrow, countof(sfDb.wzGrow), pwzTemp); + ExitOnFailure(hr, "failed to copy log file spec grow value: %ls", pwzTemp); + } + + if (iAttributes & SCADB_CONFIRM_OVERWRITE) + { + // Check if the database already exists + hr = SqlDatabaseExists(pwzServer, pwzInstance, pwzDatabase, fIntegratedAuth, pwzUser, pwzPassword, &bstrErrorDescription); + MessageExitOnFailure(hr, msierrSQLFailedCreateDatabase, "failed to check if database exists: '%ls', error: %ls", pwzDatabase, NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription); + + if (S_OK == hr) // found an existing database, confirm that they don't want to stop before it gets trampled, in no UI case just continue anyways + { + hr = HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS); + if (IDNO == WcaErrorMessage(msierrSQLDatabaseAlreadyExists, hr, MB_YESNO, 1, pwzDatabase)) + ExitOnFailure(hr, "failed to initialize"); + } + } + + hr = SqlDatabaseEnsureExists(pwzServer, pwzInstance, pwzDatabase, fIntegratedAuth, pwzUser, pwzPassword, fHaveDbFileSpec ? &sfDb : NULL, fHaveLogFileSpec ? &sfLog : NULL, &bstrErrorDescription); + if ((iAttributes & SCADB_CONTINUE_ON_ERROR) && FAILED(hr)) + { + WcaLog(LOGMSG_STANDARD, "Error 0x%x: failed to create SQL database but continuing, error: %ls, Database: %ls", hr, NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription, pwzDatabase); + hr = S_OK; + } + MessageExitOnFailure(hr, msierrSQLFailedCreateDatabase, "failed to create to database: '%ls', error: %ls", pwzDatabase, NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription); + + hr = WcaProgressMessage(COST_SQL_CONNECTDB, FALSE); +LExit: + ReleaseStr(pwzDatabaseKey); + ReleaseStr(pwzServer); + ReleaseStr(pwzInstance); + ReleaseStr(pwzDatabase); + ReleaseStr(pwzUser); + ReleaseStr(pwzPassword); + ReleaseObject(pidbSession); + ReleaseBSTR(bstrErrorDescription); + + if (fInitializedCom) + { + ::CoUninitialize(); + } + + if (FAILED(hr)) + { + er = ERROR_INSTALL_FAILURE; + } + return WcaFinalize(er); +} + + +/******************************************************************** + DropDatabase - CUSTOM ACTION ENTRY POINT for removing databases + + Input: deferred CustomActionData - DbKey\tServer\tInstance\tDatabase\tAttributes\tIntegratedAuth\tUser\tPassword + * ****************************************************************/ +extern "C" UINT __stdcall DropDatabase(MSIHANDLE hInstall) +{ +//Assert(FALSE); + UINT er = ERROR_SUCCESS; + HRESULT hr = S_OK; + + LPWSTR pwzData = NULL; + IDBCreateSession* pidbSession = NULL; + BSTR bstrErrorDescription = NULL; + LPWSTR pwz = NULL; + LPWSTR pwzDatabaseKey = NULL; + LPWSTR pwzServer = NULL; + LPWSTR pwzInstance = NULL; + LPWSTR pwzDatabase = NULL; + long lAttributes; + BOOL fIntegratedAuth; + LPWSTR pwzUser = NULL; + LPWSTR pwzPassword = NULL; + BOOL fInitializedCom = TRUE; + + hr = WcaInitialize(hInstall, "DropDatabase"); + ExitOnFailure(hr, "failed to initialize"); + + hr = ::CoInitialize(NULL); + ExitOnFailure(hr, "failed to intialize COM"); + fInitializedCom = TRUE; + + hr = WcaGetProperty( L"CustomActionData", &pwzData); + ExitOnFailure(hr, "failed to get CustomActionData"); + + WcaLog(LOGMSG_TRACEONLY, "CustomActionData: %ls", pwzData); + + pwz = pwzData; + hr = WcaReadStringFromCaData(&pwz, &pwzDatabaseKey); + ExitOnFailure(hr, "failed to read database key"); + hr = WcaReadStringFromCaData(&pwz, &pwzServer); + ExitOnFailure(hr, "failed to read server"); + hr = WcaReadStringFromCaData(&pwz, &pwzInstance); + ExitOnFailure(hr, "failed to read instance"); + hr = WcaReadStringFromCaData(&pwz, &pwzDatabase); + ExitOnFailure(hr, "failed to read database"); + hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast(&lAttributes)); + ExitOnFailure(hr, "failed to read attributes"); + hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast(&fIntegratedAuth)); // Integrated Windows Authentication? + ExitOnFailure(hr, "failed to read integrated auth flag"); + hr = WcaReadStringFromCaData(&pwz, &pwzUser); + ExitOnFailure(hr, "failed to read user"); + hr = WcaReadStringFromCaData(&pwz, &pwzPassword); + ExitOnFailure(hr, "failed to read password"); + + hr = SqlDropDatabase(pwzServer, pwzInstance, pwzDatabase, fIntegratedAuth, pwzUser, pwzPassword, &bstrErrorDescription); + if ((lAttributes & SCADB_CONTINUE_ON_ERROR) && FAILED(hr)) + { + WcaLog(LOGMSG_STANDARD, "Error 0x%x: failed to drop SQL database but continuing, error: %ls, Database: %ls", hr, NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription, pwzDatabase); + hr = S_OK; + } + MessageExitOnFailure(hr, msierrSQLFailedDropDatabase, "failed to drop to database: '%ls', error: %ls", pwzDatabase, NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription); + + hr = WcaProgressMessage(COST_SQL_CONNECTDB, FALSE); + +LExit: + ReleaseStr(pwzDatabaseKey); + ReleaseStr(pwzServer); + ReleaseStr(pwzInstance); + ReleaseStr(pwzDatabase); + ReleaseStr(pwzUser); + ReleaseStr(pwzPassword); + ReleaseStr(pwzData); + ReleaseObject(pidbSession); + ReleaseBSTR(bstrErrorDescription); + + if (fInitializedCom) + { + ::CoUninitialize(); + } + + if (FAILED(hr)) + { + er = ERROR_INSTALL_FAILURE; + } + return WcaFinalize(er); +} + + +/******************************************************************** + ExecuteSqlStrings - CUSTOM ACTION ENTRY POINT for running SQL strings + + Input: deferred CustomActionData - DbKey\tServer\tInstance\tDatabase\tAttributes\tIntegratedAuth\tUser\tPassword\tSQLKey1\tSQLString1\tSQLKey2\tSQLString2\tSQLKey3\tSQLString3\t... + rollback CustomActionData - same as above + * ****************************************************************/ +extern "C" UINT __stdcall ExecuteSqlStrings(MSIHANDLE hInstall) +{ +//Assert(FALSE); + UINT er = ERROR_SUCCESS; + HRESULT hr = S_OK; + HRESULT hrDB = S_OK; + + LPWSTR pwzData = NULL; + IDBCreateSession* pidbSession = NULL; + BSTR bstrErrorDescription = NULL; + + LPWSTR pwz = NULL; + LPWSTR pwzDatabaseKey = NULL; + LPWSTR pwzServer = NULL; + LPWSTR pwzInstance = NULL; + LPWSTR pwzDatabase = NULL; + int iAttributesDB; + int iAttributesSQL; + BOOL fIntegratedAuth; + LPWSTR pwzUser = NULL; + LPWSTR pwzPassword = NULL; + LPWSTR pwzSqlKey = NULL; + LPWSTR pwzSql = NULL; + BOOL fInitializedCom = FALSE; + + hr = WcaInitialize(hInstall, "ExecuteSqlStrings"); + ExitOnFailure(hr, "failed to initialize"); + + hr = ::CoInitialize(NULL); + ExitOnFailure(hr, "failed to intialize COM"); + fInitializedCom = TRUE; + + hr = WcaGetProperty( L"CustomActionData", &pwzData); + ExitOnFailure(hr, "failed to get CustomActionData"); + + WcaLog(LOGMSG_TRACEONLY, "CustomActionData: %ls", pwzData); + + pwz = pwzData; + hr = WcaReadStringFromCaData(&pwz, &pwzDatabaseKey); + ExitOnFailure(hr, "failed to read database key"); + hr = WcaReadStringFromCaData(&pwz, &pwzServer); + ExitOnFailure(hr, "failed to read server"); + hr = WcaReadStringFromCaData(&pwz, &pwzInstance); + ExitOnFailure(hr, "failed to read instance"); + hr = WcaReadStringFromCaData(&pwz, &pwzDatabase); + ExitOnFailure(hr, "failed to read database"); + hr = WcaReadIntegerFromCaData(&pwz, &iAttributesDB); + ExitOnFailure(hr, "failed to read attributes"); + hr = WcaReadIntegerFromCaData(&pwz, reinterpret_cast(&fIntegratedAuth)); // Integrated Windows Authentication? + ExitOnFailure(hr, "failed to read integrated auth flag"); + hr = WcaReadStringFromCaData(&pwz, &pwzUser); + ExitOnFailure(hr, "failed to read user"); + hr = WcaReadStringFromCaData(&pwz, &pwzPassword); + ExitOnFailure(hr, "failed to read password"); + + // Store off the result of the connect, only exit if we don't care if the database connection succeeds + // Wait to fail until later to see if we actually have work to do that is not set to continue on error + hrDB = SqlConnectDatabase(pwzServer, pwzInstance, pwzDatabase, fIntegratedAuth, pwzUser, pwzPassword, &pidbSession); + if ((iAttributesDB & SCADB_CONTINUE_ON_ERROR) && FAILED(hrDB)) + { + WcaLog(LOGMSG_STANDARD, "Error 0x%x: continuing after failure to connect to database: %ls", hrDB, pwzDatabase); + ExitFunction1(hr = S_OK); + } + + while (S_OK == hr && S_OK == (hr = WcaReadStringFromCaData(&pwz, &pwzSqlKey))) + { + hr = WcaReadIntegerFromCaData(&pwz, &iAttributesSQL); + ExitOnFailure(hr, "failed to read attributes for SQL string: %ls", pwzSqlKey); + + hr = WcaReadStringFromCaData(&pwz, &pwzSql); + ExitOnFailure(hr, "failed to read SQL string for key: %ls", pwzSqlKey); + + // If the Wix4SqlString row is set to continue on error and the DB connection failed, skip attempting to execute + if ((iAttributesSQL & SCASQL_CONTINUE_ON_ERROR) && FAILED(hrDB)) + { + WcaLog(LOGMSG_STANDARD, "Error 0x%x: continuing after failure to connect to database: %ls", hrDB, pwzDatabase); + continue; + } + + // Now check if the DB connection succeeded + MessageExitOnFailure(hr = hrDB, msierrSQLFailedConnectDatabase, "failed to connect to database: '%ls'", pwzDatabase); + + WcaLog(LOGMSG_VERBOSE, "Executing SQL string: %ls", pwzSql); + hr = SqlSessionExecuteQuery(pidbSession, pwzSql, NULL, NULL, &bstrErrorDescription); + if ((iAttributesSQL & SCASQL_CONTINUE_ON_ERROR) && FAILED(hr)) + { + WcaLog(LOGMSG_STANDARD, "Error 0x%x: failed to execute SQL string but continuing, error: %ls, SQL key: %ls SQL string: %ls", hr, NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription, pwzSqlKey, pwzSql); + hr = S_OK; + } + MessageExitOnFailure(hr, msierrSQLFailedExecString, "failed to execute SQL string, error: %ls, SQL key: %ls SQL string: %ls", NULL == bstrErrorDescription ? L"unknown error" : bstrErrorDescription, pwzSqlKey, pwzSql); + + WcaProgressMessage(COST_SQL_STRING, FALSE); + } + if (E_NOMOREITEMS == hr) + { + hr = S_OK; + } + +LExit: + ReleaseStr(pwzDatabaseKey); + ReleaseStr(pwzServer); + ReleaseStr(pwzInstance); + ReleaseStr(pwzDatabase); + ReleaseStr(pwzUser); + ReleaseStr(pwzPassword); + ReleaseStr(pwzData); + + ReleaseBSTR(bstrErrorDescription); + ReleaseObject(pidbSession); + + if (fInitializedCom) + { + ::CoUninitialize(); + } + + if (FAILED(hr)) + { + er = ERROR_INSTALL_FAILURE; + } + return WcaFinalize(er); +} diff --git a/src/ext/Sql/ca/scasql.cpp b/src/ext/Sql/ca/scasql.cpp new file mode 100644 index 00000000..b0216950 --- /dev/null +++ b/src/ext/Sql/ca/scasql.cpp @@ -0,0 +1,113 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +// prototypes +static HRESULT ConfigureSqlData( + __in SCA_ACTION saAction + ); + + +/******************************************************************** +InstallSqlData - CUSTOM ACTION ENTRY POINT for installing + SQL data + +********************************************************************/ +extern "C" UINT __stdcall InstallSqlData( + __in MSIHANDLE hInstall + ) +{ + HRESULT hr = S_OK; + UINT er = ERROR_SUCCESS; + + // initialize + hr = WcaInitialize(hInstall, "InstallSqlData"); + ExitOnFailure(hr, "Failed to initialize"); + + hr = ConfigureSqlData(SCA_ACTION_INSTALL); + +LExit: + er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; + return WcaFinalize(er); +} + + +/******************************************************************** +UninstallSqlData - CUSTOM ACTION ENTRY POINT for uninstalling + SQL data + +********************************************************************/ +extern "C" UINT __stdcall UninstallSqlData( + __in MSIHANDLE hInstall + ) +{ + HRESULT hr = S_OK; + UINT er = ERROR_SUCCESS; + + // initialize + hr = WcaInitialize(hInstall, "UninstallCertificates"); + ExitOnFailure(hr, "Failed to initialize"); + + hr = ConfigureSqlData(SCA_ACTION_UNINSTALL); + +LExit: + er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; + return WcaFinalize(er); +} + + +static HRESULT ConfigureSqlData( + __in SCA_ACTION saAction + ) +{ + //AssertSz(FALSE, "debug ConfigureSqlData()"); + HRESULT hr = S_OK; + + SCA_DB* psdList = NULL; + SCA_SQLSTR* psssList = NULL; + + // check for the prerequsite tables + if (S_OK != WcaTableExists(L"Wix4SqlDatabase")) + { + WcaLog(LOGMSG_VERBOSE, "skipping SQL CustomAction, no Wix4SqlDatabase table"); + ExitFunction1(hr = S_FALSE); + } + + // read tables + hr = ScaDbsRead(&psdList, saAction); + ExitOnFailure(hr, "failed to read Wix4SqlDatabase table"); + + hr = ScaSqlStrsRead(&psssList, saAction); + ExitOnFailure(hr, "failed to read Wix4SqlString table"); + + hr = ScaSqlStrsReadScripts(&psssList, saAction); + ExitOnFailure(hr, "failed to read Wix4SqlScript table"); + + if (SCA_ACTION_UNINSTALL == saAction) + { + // do uninstall actions (order is important!) + hr = ScaSqlStrsUninstall(psdList, psssList); + ExitOnFailure(hr, "failed to execute uninstall SQL strings"); + + hr = ScaDbsUninstall(psdList); + ExitOnFailure(hr, "failed to uninstall databases"); + } + else + { + // do install actions (order is important!) + hr = ScaDbsInstall(psdList); + ExitOnFailure(hr, "failed to install databases"); + + hr = ScaSqlStrsInstall(psdList, psssList); + ExitOnFailure(hr, "failed to execute install SQL strings, length may be too long, try add GO to break up"); + } + +LExit: + if (psssList) + ScaSqlStrsFreeList(psssList); + + if (psdList) + ScaDbsFreeList(psdList); + + return hr; +} diff --git a/src/ext/Sql/ca/scasqlstr.cpp b/src/ext/Sql/ca/scasqlstr.cpp new file mode 100644 index 00000000..c3ebd43d --- /dev/null +++ b/src/ext/Sql/ca/scasqlstr.cpp @@ -0,0 +1,728 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +// sql queries +LPCWSTR vcsSqlStringQuery = L"SELECT `String`, `SqlDb_`, `Component_`,`SQL`,`User_`,`Attributes`,`Sequence` " +L"FROM `Wix4SqlString` ORDER BY `SqlDb_`,`Sequence`"; +enum eSqlStringQuery { ssqSqlString = 1, ssqSqlDb, ssqComponent, ssqSQL, ssqUser, ssqAttributes, ssqSequence }; + +LPCWSTR vcsSqlScriptQuery = L"SELECT `ScriptBinary_`,`Script`, `SqlDb_`, `Component_`,`User_`,`Attributes`,`Sequence` " +L"FROM `Wix4SqlScript` ORDER BY `SqlDb_`,`Sequence`"; +enum eSqlScriptQuery { sscrqScriptBinary=1, sscrqSqlScript, sscrqSqlDb, sscrqComponent, sscrqUser, sscrqAttributes, sscrqSequence }; + +LPCWSTR vcsSqlBinaryScriptQuery = L"SELECT `Data` FROM `Binary` WHERE `Name`=?"; +enum eSqlBinaryScriptQuery { ssbsqData = 1 }; + + +// prototypes for private helper functions +static HRESULT NewSqlStr( + __out SCA_SQLSTR** ppsss + ); +static SCA_SQLSTR* AddSqlStrToList( + __in SCA_SQLSTR* psssList, + __in SCA_SQLSTR* psss + ); +static HRESULT ExecuteStrings( + __in SCA_DB* psdList, + __in SCA_SQLSTR* psssList, + __in BOOL fInstall + ); + +HRESULT ScaSqlStrsRead( + __inout SCA_SQLSTR** ppsssList, + __in SCA_ACTION saAction + ) +{ + HRESULT hr = S_OK; + UINT er = ERROR_SUCCESS; + PMSIHANDLE hView, hRec; + PMSIHANDLE hViewUser, hRecUser; + + LPWSTR pwzComponent = NULL; + LPWSTR pwzData = NULL; + + SCA_SQLSTR* psss = NULL; + + if (S_OK != WcaTableExists(L"Wix4SqlString") || S_OK != WcaTableExists(L"Wix4SqlDatabase")) + { + WcaLog(LOGMSG_VERBOSE, "Skipping ScaSqlStrsRead() - Wix4SqlString and/or Wix4SqlDatabase table not present"); + ExitFunction1(hr = S_FALSE); + } + + // loop through all the sql strings + hr = WcaOpenExecuteView(vcsSqlStringQuery, &hView); + ExitOnFailure(hr, "Failed to open view on Wix4SqlString table"); + while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) + { + INSTALLSTATE isInstalled = INSTALLSTATE_UNKNOWN; + INSTALLSTATE isAction = INSTALLSTATE_UNKNOWN; + + hr = WcaGetRecordString(hRec, ssqComponent, &pwzComponent); + ExitOnFailure(hr, "Failed to get Component for SQL String."); + + er = ::MsiGetComponentStateW(WcaGetInstallHandle(), pwzComponent, &isInstalled, &isAction); + hr = HRESULT_FROM_WIN32(er); + ExitOnFailure(hr, "Failed to get state for component: %ls", pwzComponent); + + // If we're doing install but the Component is not being installed or we're doing + // uninstall but the Component is not being uninstalled, skip it. + if ((WcaIsInstalling(isInstalled, isAction) && SCA_ACTION_INSTALL != saAction) || + (WcaIsUninstalling(isInstalled, isAction) && SCA_ACTION_UNINSTALL != saAction)) + { + continue; + } + + hr = NewSqlStr(&psss); + ExitOnFailure(hr, "failed to allocation new sql string element"); + + psss->isInstalled = isInstalled; + psss->isAction = isAction; + + hr = WcaGetRecordString(hRec, ssqSqlString, &pwzData); + ExitOnFailure(hr, "Failed to get Wix4SqlString.String"); + hr = ::StringCchCopyW(psss->wzKey, countof(psss->wzKey), pwzData); + ExitOnFailure(hr, "Failed to copy Wix4SqlString.String: %ls", pwzData); + + // find the database information for this string + hr = WcaGetRecordString(hRec, ssqSqlDb, &pwzData); + ExitOnFailure(hr, "Failed to get Wix4SqlString.SqlDb_ for SqlString '%ls'", psss->wzKey); + hr = ::StringCchCopyW(psss->wzSqlDb, countof(psss->wzSqlDb), pwzData); + ExitOnFailure(hr, "Failed to copy Wix4SqlString.SqlDb_: %ls", pwzData); + + hr = WcaGetRecordInteger(hRec, ssqAttributes, &psss->iAttributes); + ExitOnFailure(hr, "Failed to get Wix4SqlString.Attributes for SqlString '%ls'", psss->wzKey); + + //get the sequence number for the string (note that this will be sequenced with scripts too) + hr = WcaGetRecordInteger(hRec, ssqSequence, &psss->iSequence); + ExitOnFailure(hr, "Failed to get Wix4SqlString.Sequence for SqlString '%ls'", psss->wzKey); + + // execute SQL + hr = WcaGetRecordFormattedString(hRec, ssqSQL, &pwzData); + ExitOnFailure(hr, "Failed to get Wix4SqlString.SQL for SQL string '%ls'", psss->wzKey); + + Assert(!psss->pwzSql); + hr = StrAllocString(&psss->pwzSql, pwzData, 0); + ExitOnFailure(hr, "Failed to alloc string for SQL string '%ls'", psss->wzKey); + + *ppsssList = AddSqlStrToList(*ppsssList, psss); + psss = NULL; // set the sss to NULL so it doesn't get freed below + } + + if (E_NOMOREITEMS == hr) + { + hr = S_OK; + } + ExitOnFailure(hr, "Failure occured while reading Wix4SqlString table"); + +LExit: + // if anything was left over after an error clean it all up + if (psss) + { + ScaSqlStrsFreeList(psss); + } + + ReleaseStr(pwzData); + ReleaseStr(pwzComponent); + + return hr; +} + + +HRESULT ScaSqlStrsReadScripts( + __inout SCA_SQLSTR** ppsssList, + __in SCA_ACTION saAction + ) +{ + HRESULT hr = S_OK; + UINT er = ERROR_SUCCESS; + + PMSIHANDLE hView, hRec; + PMSIHANDLE hViewBinary, hRecBinary; + PMSIHANDLE hViewUser, hRecUser; + + LPWSTR pwzComponent = NULL; + LPWSTR pwzData = NULL; + + BYTE* pbScript = NULL; + DWORD cbRead = 0; + DWORD cbScript = 0; + DWORD cchScript = 0; + + LPWSTR pwzScriptBuffer = NULL; + WCHAR* pwzScript = NULL; + WCHAR* pwz; + DWORD cch = 0; + + SCA_SQLSTR sss; + SCA_SQLSTR* psss = NULL; + + if (S_OK != WcaTableExists(L"Wix4SqlScript") || S_OK != WcaTableExists(L"Wix4SqlDatabase") || S_OK != WcaTableExists(L"Binary")) + { + WcaLog(LOGMSG_VERBOSE, "Skipping ScaSqlStrsReadScripts() - Wix4SqlScript and/or Wix4SqlDatabase table not present"); + ExitFunction1(hr = S_FALSE); + } + + // open a view on the binary table + hr = WcaOpenView(vcsSqlBinaryScriptQuery, &hViewBinary); + ExitOnFailure(hr, "Failed to open view on Binary table for SQL scripts"); + + // loop through all the sql scripts + hr = WcaOpenExecuteView(vcsSqlScriptQuery, &hView); + ExitOnFailure(hr, "Failed to open view on Wix4SqlScript table"); + while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) + { + INSTALLSTATE isInstalled = INSTALLSTATE_UNKNOWN; + INSTALLSTATE isAction = INSTALLSTATE_UNKNOWN; + + hr = WcaGetRecordString(hRec, sscrqComponent, &pwzComponent); + ExitOnFailure(hr, "Failed to get Component for SQL Script."); + + er = ::MsiGetComponentStateW(WcaGetInstallHandle(), pwzComponent, &isInstalled, &isAction); + hr = HRESULT_FROM_WIN32(er); + ExitOnFailure(hr, "Failed to get state for component: %ls", pwzComponent); + + // If we're doing install but the Component is not being installed or we're doing + // uninstall but the Component is not being uninstalled, skip it. + if ((WcaIsInstalling(isInstalled, isAction) && SCA_ACTION_INSTALL != saAction) || + (WcaIsUninstalling(isInstalled, isAction) && SCA_ACTION_UNINSTALL != saAction)) + { + continue; + } + + ::ZeroMemory(&sss, sizeof(sss)); + + sss.isInstalled = isInstalled; + sss.isAction = isAction; + + hr = WcaGetRecordString(hRec, sscrqSqlScript, &pwzData); + ExitOnFailure(hr, "Failed to get Wix4SqlScript.Script"); + hr = ::StringCchCopyW(sss.wzKey, countof(sss.wzKey), pwzData); + ExitOnFailure(hr, "Failed to copy Wix4SqlScript.Script: %ls", pwzData); + + // find the database information for this string + hr = WcaGetRecordString(hRec, sscrqSqlDb, &pwzData); + ExitOnFailure(hr, "Failed to get Wix4SqlScript.SqlDb_ for SqlScript '%ls'", sss.wzKey); + hr = ::StringCchCopyW(sss.wzSqlDb, countof(sss.wzSqlDb), pwzData); + ExitOnFailure(hr, "Failed to copy Wix4SqlScript.SqlDbb: %ls", pwzData); + + hr = WcaGetRecordInteger(hRec, sscrqAttributes, &sss.iAttributes); + ExitOnFailure(hr, "Failed to get Wix4SqlScript.Attributes for SqlScript '%ls'", sss.wzKey); + + hr = WcaGetRecordInteger(hRec, sscrqSequence, &sss.iSequence); + ExitOnFailure(hr, "Failed to get Wix4SqlScript.Sequence for SqlScript '%ls'", sss.wzKey); + + // get the sql script out of the binary stream + hr = WcaExecuteView(hViewBinary, hRec); + ExitOnFailure(hr, "Failed to open Wix4SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey); + hr = WcaFetchSingleRecord(hViewBinary, &hRecBinary); + ExitOnFailure(hr, "Failed to fetch Wix4SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey); + + // Note: We need to allocate an extra character on the stream to NULL terminate the SQL script. + // The WcaGetRecordStream() function won't let us add extra space on the end of the stream + // so we'll read the stream "the old fashioned way". + //hr = WcaGetRecordStream(hRecBinary, ssbsqData, (BYTE**)&pbScript, &cbScript); + //ExitOnFailure(hr, "Failed to read Wix4SqlScript.BinaryScript_ for SqlScript '%ls'", sss.wzKey); + er = ::MsiRecordReadStream(hRecBinary, ssbsqData, NULL, &cbRead); + hr = HRESULT_FROM_WIN32(er); + ExitOnFailure(hr, "failed to get size of stream"); + + cbScript = cbRead + sizeof(WCHAR); // we may have an ANSI SQL script but leave enough to even NULL terminate a WCHAR string + hr = WcaAllocStream(&pbScript, cbScript); // this will allocate a fully zeroed out buffer so our string will be NULL terminated + ExitOnFailure(hr, "failed to allocate data for stream"); + + er = ::MsiRecordReadStream(hRecBinary, ssbsqData, reinterpret_cast(pbScript), &cbRead); //read the buffer but leave the space for the NULL terminator + hr = HRESULT_FROM_WIN32(er); + ExitOnFailure(hr, "failed to read from stream"); + + Assert(cbRead + sizeof(WCHAR) == cbScript); + + // Check for the UNICODE BOM file marker. + if ((0xFF == *pbScript) && (0xFE == *(pbScript + 1))) + { + // Copy the UNICODE string after the BOM marker (subtract one because we'll skip the BOM marker). + cchScript = (cbScript / sizeof(WCHAR)) - 1; + + hr = StrAllocString(&pwzScriptBuffer, reinterpret_cast(pbScript) + 1, 0); + ExitOnFailure(hr, "Failed to allocate WCHAR string of size '%d'", cchScript); + } + else + { + // We have an ANSI string so convert it to UNICODE. + cchScript = cbScript; + + hr = StrAllocStringAnsi(&pwzScriptBuffer, reinterpret_cast(pbScript), 0, CP_ACP); + ExitOnFailure(hr, "Failed to allocate WCHAR string of size '%d'", cchScript); + } + + // Free the byte buffer since it has been converted to a new UNICODE string, one way or another. + if (pbScript) + { + WcaFreeStream(pbScript); + pbScript = NULL; + } + + // Process the SQL script stripping out unnecessary stuff (like comments) and looking for "GO" statements. + pwzScript = pwzScriptBuffer; + while (cchScript && pwzScript && *pwzScript) + { + // strip off leading whitespace + while (cchScript && *pwzScript && iswspace(*pwzScript)) + { + ++pwzScript; + --cchScript; + } + + Assert(0 <= cchScript); + + // if there is a SQL comment remove it + while (cchScript && L'/' == *pwzScript && L'*' == *(pwzScript + 1)) + { + // go until end of comment + while (cchScript && *pwzScript && *(pwzScript + 1) && !(L'*' == *pwzScript && L'/' == *(pwzScript + 1))) + { + ++pwzScript; + --cchScript; + } + + Assert(2 <= cchScript); + + if (2 <= cchScript) + { + // to account for */ at end + pwzScript+=2; + cchScript-=2; + } + + Assert(0 <= cchScript); + + // strip off any new leading whitespace + while (cchScript && *pwzScript && iswspace(*pwzScript)) + { + ++pwzScript; + --cchScript; + } + } + + while (cchScript && L'-' == *pwzScript && L'-' == *(pwzScript + 1)) + { + // go past the new line character + while (cchScript && *pwzScript && L'\n' != *pwzScript) + { + ++pwzScript; + --cchScript; + } + + Assert(0 <= cchScript); + + if (cchScript && L'\n' == *pwzScript) + { + ++pwzScript; + --cchScript; + } + + Assert(0 <= cchScript); + + // strip off any new leading whitespace + while (cchScript && *pwzScript && iswspace(*pwzScript)) + { + ++pwzScript; + --cchScript; + } + } + + Assert(0 <= cchScript); + + // try to isolate a "GO" keyword and count the characters in the SQL string + pwz = pwzScript; + cch = 0; + while (cchScript && *pwz) + { + //skip past comment lines that might have "go" in them + //note that these comments are "in the middle" of our function, + //or possibly at the end of a line + if (cchScript && L'-' == *pwz && L'-' == *(pwz + 1)) + { + // skip past chars until the new line character + while (cchScript && *pwz && (L'\n' != *pwz)) + { + ++pwz; + ++cch; + --cchScript; + } + } + + //skip past comment lines of form /* to */ that might have "go" in them + //note that these comments are "in the middle" of our function, + //or possibly at the end of a line + if (cchScript && L'/' == *pwz && L'*' == *(pwz + 1)) + { + // skip past chars until the new line character + while (cchScript && *pwz && *(pwz + 1) && !((L'*' == *pwz) && (L'/' == *(pwz + 1)))) + { + ++pwz; + ++cch; + --cchScript; + } + + if (2 <= cchScript) + { + // to account for */ at end + pwz+=2; + cch+=2; + cchScript-=2; + } + } + + // Skip past strings that may be part of the SQL statement that might have a "go" in them + if ( cchScript && L'\'' == *pwz ) + { + ++pwz; + ++cch; + --cchScript; + + // Skip past chars until the end of the string + while ( cchScript && *pwz && !(L'\'' == *pwz) ) + { + ++pwz; + ++cch; + --cchScript; + } + } + + // Skip past strings that may be part of the SQL statement that might have a "go" in them + if ( cchScript && L'\"' == *pwz ) + { + ++pwz; + ++cch; + --cchScript; + + // Skip past chars until the end of the string + while ( cchScript && *pwz && !(L'\"' == *pwz) ) + { + ++pwz; + ++cch; + --cchScript; + } + } + + // if "GO" is isolated + if ((pwzScript == pwz || iswspace(*(pwz - 1))) && + (L'G' == *pwz || L'g' == *pwz) && + (L'O' == *(pwz + 1) || L'o' == *(pwz + 1)) && + (0 == *(pwz + 2) || iswspace(*(pwz + 2)))) + { + *pwz = 0; // null terminate the SQL string on the "G" + pwz += 2; + cchScript -= 2; + break; // found "GO" now add SQL string to list + } + + ++pwz; + ++cch; + --cchScript; + } + + Assert(0 <= cchScript); + + if (0 < cch) //don't process if there's nothing to process + { + // replace tabs with spaces + for (LPWSTR pwzTab = wcsstr(pwzScript, L"\t"); pwzTab; pwzTab = wcsstr(pwzTab, L"\t")) + *pwzTab = ' '; + + // strip off whitespace at the end of the script string + for (LPWSTR pwzErase = pwzScript + cch - 1; pwzScript < pwzErase && iswspace(*pwzErase); pwzErase--) + { + *(pwzErase) = 0; + cch--; + } + } + + if (0 < cch) + { + hr = NewSqlStr(&psss); + ExitOnFailure(hr, "failed to allocate new sql string element"); + + // copy everything over + hr = ::StringCchCopyW(psss->wzKey, countof(psss->wzKey), sss.wzKey); + ExitOnFailure(hr, "Failed to copy key string to sqlstr object"); + hr = ::StringCchCopyW(psss->wzSqlDb, countof(psss->wzSqlDb), sss.wzSqlDb); + ExitOnFailure(hr, "Failed to copy DB string to sqlstr object"); + hr = ::StringCchCopyW(psss->wzComponent, countof(psss->wzComponent), sss.wzComponent); + ExitOnFailure(hr, "Failed to copy component string to sqlstr object"); + psss->isInstalled = sss.isInstalled; + psss->isAction = sss.isAction; + psss->iAttributes = sss.iAttributes; + psss->iSequence = sss.iSequence; + + // cchRequired includes the NULL terminating char + hr = StrAllocString(&psss->pwzSql, pwzScript, 0); + ExitOnFailure(hr, "Failed to allocate string for SQL script: '%ls'", psss->wzKey); + + *ppsssList = AddSqlStrToList(*ppsssList, psss); + psss = NULL; // set the db NULL so it doesn't accidentally get freed below + } + + pwzScript = pwz; + } + } + + if (E_NOMOREITEMS == hr) + { + hr = S_OK; + } + ExitOnFailure(hr, "Failure occured while reading Wix4SqlScript table"); + +LExit: + // if anything was left over after an error clean it all up + if (psss) + { + ScaSqlStrsFreeList(psss); + } + + if (pbScript) + { + WcaFreeStream(pbScript); + } + + ReleaseStr(pwzScriptBuffer); + ReleaseStr(pwzData); + ReleaseStr(pwzComponent); + + return hr; +} + + +HRESULT ScaSqlStrsInstall( + __in SCA_DB* psdList, + __in SCA_SQLSTR* psssList + ) +{ + HRESULT hr = ExecuteStrings(psdList, psssList, TRUE); + + return hr; +} + + +HRESULT ScaSqlStrsUninstall( + __in SCA_DB* psdList, + __in SCA_SQLSTR* psssList + ) +{ + HRESULT hr = ExecuteStrings(psdList, psssList, FALSE); + + return hr; +} + + +void ScaSqlStrsFreeList( + __in SCA_SQLSTR* psssList + ) +{ + SCA_SQLSTR* psssDelete = psssList; + while (psssList) + { + psssDelete = psssList; + psssList = psssList->psssNext; + + if (psssDelete->pwzSql) + { + ReleaseStr(psssDelete->pwzSql); + } + + MemFree(psssDelete); + } +} + + +// private helper functions + +static HRESULT NewSqlStr( + __out SCA_SQLSTR** ppsss + ) +{ + HRESULT hr = S_OK; + SCA_SQLSTR* psss = static_cast(MemAlloc(sizeof(SCA_SQLSTR), TRUE)); + ExitOnNull(psss, hr, E_OUTOFMEMORY, "failed to allocate memory for new sql string element"); + + *ppsss = psss; + +LExit: + return hr; +} + + +static SCA_SQLSTR* AddSqlStrToList( + __in SCA_SQLSTR* psssList, + __in SCA_SQLSTR* psss + ) +{ + Assert(psss); //just checking + + //make certain we have a valid sequence number; note that negatives are technically valid + if (MSI_NULL_INTEGER == psss->iSequence) + { + psss->iSequence = 0; + } + + if (psssList) + { + //list already exists, so insert psss into the list in Sequence order + + //see if we need to change the head, otherwise figure out where in the order it fits + if (psss->iSequence < psssList->iSequence) + { + psss->psssNext = psssList; + psssList = psss; + } + else + { + SCA_SQLSTR* psssT = psssList; + //note that if Sequence numbers are duplicated, as in the case of a sqlscript, + //we need to insert them "at the end" of the group so the sqlfile stays in order + while (psssT->psssNext && (psssT->psssNext->iSequence <= psss->iSequence)) + { + psssT = psssT->psssNext; + } + + //insert our new psss AFTER psssT + psss->psssNext = psssT->psssNext; + psssT->psssNext = psss; + } + } + else + { + psssList = psss; + } + + return psssList; +} + + +static HRESULT ExecuteStrings( + __in SCA_DB* psdList, + __in SCA_SQLSTR* psssList, + __in BOOL fInstall + ) +{ + HRESULT hr = S_FALSE; // assume nothing will be done + + int iRollback = -1; + int iOldRollback = iRollback; + + LPCWSTR wzOldDb = NULL; + UINT uiCost = 0; + WCHAR* pwzCustomActionData = NULL; + WCHAR wzNumber[64]; + + // loop through all sql strings + for (SCA_SQLSTR* psss = psssList; psss; psss = psss->psssNext) + { + // if installing this component + if ((fInstall && (psss->iAttributes & SCASQL_EXECUTE_ON_INSTALL) && WcaIsInstalling(psss->isInstalled, psss->isAction) && !WcaIsReInstalling(psss->isInstalled, psss->isAction)) || + (fInstall && (psss->iAttributes & SCASQL_EXECUTE_ON_REINSTALL) && WcaIsReInstalling(psss->isInstalled, psss->isAction)) || + (!fInstall && (psss->iAttributes & SCASQL_EXECUTE_ON_UNINSTALL) && WcaIsUninstalling(psss->isInstalled, psss->isAction))) + { + // determine if this is a rollback scheduling or normal deferred scheduling + if (psss->iAttributes & SCASQL_ROLLBACK) + { + iRollback = 1; + } + else + { + iRollback = 0; + } + + // if we need to create a connection to a new server\database + if (!wzOldDb || 0 != lstrcmpW(wzOldDb, psss->wzSqlDb) || iOldRollback != iRollback) + { + const SCA_DB* psd = ScaDbsFindDatabase(psss->wzSqlDb, psdList); + if (!psd) + { + ExitOnFailure(hr = HRESULT_FROM_WIN32(ERROR_NOT_FOUND), "failed to find data for Database: %ls", psss->wzSqlDb); + } + + if (-1 == iOldRollback) + { + iOldRollback = iRollback; + } + Assert(0 == iOldRollback || 1 == iOldRollback); + + // if there was custom action data before, schedule the action to write it + if (pwzCustomActionData && *pwzCustomActionData) + { + Assert(pwzCustomActionData && *pwzCustomActionData && uiCost); + + hr = WcaDoDeferredAction(1 == iOldRollback ? CUSTOM_ACTION_DECORATION(L"RollbackExecuteSqlStrings") : CUSTOM_ACTION_DECORATION(L"ExecuteSqlStrings"), pwzCustomActionData, uiCost); + ExitOnFailure(hr, "failed to schedule ExecuteSqlStrings action, rollback: %d", iOldRollback); + iOldRollback = iRollback; + + *pwzCustomActionData = L'\0'; + uiCost = 0; + } + + Assert(!pwzCustomActionData || (pwzCustomActionData && 0 == *pwzCustomActionData) && 0 == uiCost); + + hr = WcaWriteStringToCaData(psd->wzKey, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add SQL Server Database String to CustomActionData for Database String: %ls", psd->wzKey); + + hr = WcaWriteStringToCaData(psd->wzServer, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add SQL Server to CustomActionData for Database String: %ls", psd->wzKey); + + hr = WcaWriteStringToCaData(psd->wzInstance, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add SQL Instance to CustomActionData for Database String: %ls", psd->wzKey); + + hr = WcaWriteStringToCaData(psd->wzDatabase, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add SQL Database to CustomActionData for Database String: %ls", psd->wzKey); + + hr = ::StringCchPrintfW(wzNumber, countof(wzNumber), L"%d", psd->iAttributes); + ExitOnFailure(hr, "Failed to format attributes integer value to string"); + hr = WcaWriteStringToCaData(wzNumber, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add SQL Attributes to CustomActionData for Database String: %ls", psd->wzKey); + + hr = ::StringCchPrintfW(wzNumber, countof(wzNumber), L"%d", psd->fUseIntegratedAuth); + ExitOnFailure(hr, "Failed to format UseIntegratedAuth integer value to string"); + hr = WcaWriteStringToCaData(wzNumber, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add SQL IntegratedAuth flag to CustomActionData for Database String: %ls", psd->wzKey); + + hr = WcaWriteStringToCaData(psd->scau.wzName, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add SQL UserName to CustomActionData for Database String: %ls", psd->wzKey); + + hr = WcaWriteStringToCaData(psd->scau.wzPassword, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add SQL Password to CustomActionData for Database String: %ls", psd->wzKey); + + uiCost += COST_SQL_CONNECTDB; + + wzOldDb = psss->wzSqlDb; + } + + WcaLog(LOGMSG_VERBOSE, "Scheduling SQL string: %ls", psss->pwzSql); + + hr = WcaWriteStringToCaData(psss->wzKey, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to add SQL Key to CustomActionData for SQL string: %ls", psss->wzKey); + + hr = WcaWriteIntegerToCaData(psss->iAttributes, &pwzCustomActionData); + ExitOnFailure(hr, "failed to add attributes to CustomActionData for SQL string: %ls", psss->wzKey); + + hr = WcaWriteStringToCaData(psss->pwzSql, &pwzCustomActionData); + ExitOnFailure(hr, "Failed to to add SQL Query to CustomActionData for SQL string: %ls", psss->wzKey); + uiCost += COST_SQL_STRING; + } + } + + if (pwzCustomActionData && *pwzCustomActionData) + { + Assert(pwzCustomActionData && *pwzCustomActionData && uiCost); + hr = WcaDoDeferredAction(1 == iRollback ? CUSTOM_ACTION_DECORATION(L"RollbackExecuteSqlStrings") : CUSTOM_ACTION_DECORATION(L"ExecuteSqlStrings"), pwzCustomActionData, uiCost); + ExitOnFailure(hr, "Failed to schedule ExecuteSqlStrings action"); + + *pwzCustomActionData = L'\0'; + uiCost = 0; + } + +LExit: + ReleaseStr(pwzCustomActionData); + + return hr; +} diff --git a/src/ext/Sql/ca/scasqlstr.h b/src/ext/Sql/ca/scasqlstr.h new file mode 100644 index 00000000..72c1d770 --- /dev/null +++ b/src/ext/Sql/ca/scasqlstr.h @@ -0,0 +1,51 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +#include "scadb.h" + +struct SCA_SQLSTR +{ + // darwin information + WCHAR wzKey[MAX_DARWIN_KEY + 1]; + WCHAR wzComponent[MAX_DARWIN_KEY + 1]; + INSTALLSTATE isInstalled, isAction; + + WCHAR wzSqlDb[MAX_DARWIN_COLUMN + 1]; + + BOOL fHasUser; + SCA_USER scau; + + LPWSTR pwzSql; + int iAttributes; + int iSequence; //used to sequence Wix4SqlString and Wix4SqlScript tables together + + SCA_SQLSTR* psssNext; +}; + + +// prototypes +HRESULT ScaSqlStrsRead( + __inout SCA_SQLSTR** ppsssList, + __in SCA_ACTION saAction + ); + +HRESULT ScaSqlStrsReadScripts( + __inout SCA_SQLSTR** ppsssList, + __in SCA_ACTION saAction + ); + +HRESULT ScaSqlStrsInstall( + __in SCA_DB* psdList, + __in SCA_SQLSTR* psssList + ); + +HRESULT ScaSqlStrsUninstall( + __in SCA_DB* psdList, + __in SCA_SQLSTR* psssList + ); + +void ScaSqlStrsFreeList( + __in SCA_SQLSTR* psssList + ); + diff --git a/src/ext/Sql/ca/scauser.cpp b/src/ext/Sql/ca/scauser.cpp new file mode 100644 index 00000000..4d74e4d4 --- /dev/null +++ b/src/ext/Sql/ca/scauser.cpp @@ -0,0 +1,82 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" + +LPCWSTR vcsUserQuery = L"SELECT `User`, `Component_`, `Name`, `Domain`, `Password` FROM `User` WHERE `User`=?"; +enum eUserQuery { vuqUser = 1, vuqComponent, vuqName, vuqDomain, vuqPassword }; + + +HRESULT __stdcall ScaGetUser( + __in LPCWSTR wzUser, + __out SCA_USER* pscau + ) +{ + if (!wzUser || !pscau) + { + return E_INVALIDARG; + } + + HRESULT hr = S_OK; + PMSIHANDLE hView, hRec; + + LPWSTR pwzData = NULL; + + // clear struct and bail right away if no user key was passed to search for + ::ZeroMemory(pscau, sizeof(*pscau)); + if (!*wzUser) + { + ExitFunction1(hr = S_OK); + } + + hRec = ::MsiCreateRecord(1); + hr = WcaSetRecordString(hRec, 1, wzUser); + ExitOnFailure(hr, "Failed to look up User"); + + hr = WcaOpenView(vcsUserQuery, &hView); + ExitOnFailure(hr, "Failed to open view on User table"); + hr = WcaExecuteView(hView, hRec); + ExitOnFailure(hr, "Failed to execute view on User table"); + + hr = WcaFetchSingleRecord(hView, &hRec); + if (S_OK == hr) + { + hr = WcaGetRecordString(hRec, vuqUser, &pwzData); + ExitOnFailure(hr, "Failed to get User.User"); + hr = ::StringCchCopyW(pscau->wzKey, countof(pscau->wzKey), pwzData); + ExitOnFailure(hr, "Failed to copy key string to user object"); + + hr = WcaGetRecordString(hRec, vuqComponent, &pwzData); + ExitOnFailure(hr, "Failed to get User.Component_"); + hr = ::StringCchCopyW(pscau->wzComponent, countof(pscau->wzComponent), pwzData); + ExitOnFailure(hr, "Failed to copy component string to user object"); + + hr = WcaGetRecordFormattedString(hRec, vuqName, &pwzData); + ExitOnFailure(hr, "Failed to get User.Name"); + hr = ::StringCchCopyW(pscau->wzName, countof(pscau->wzName), pwzData); + ExitOnFailure(hr, "Failed to copy name string to user object"); + + hr = WcaGetRecordFormattedString(hRec, vuqDomain, &pwzData); + ExitOnFailure(hr, "Failed to get User.Domain"); + hr = ::StringCchCopyW(pscau->wzDomain, countof(pscau->wzDomain), pwzData); + ExitOnFailure(hr, "Failed to copy domain string to user object"); + + hr = WcaGetRecordFormattedString(hRec, vuqPassword, &pwzData); + ExitOnFailure(hr, "Failed to get User.Password"); + hr = ::StringCchCopyW(pscau->wzPassword, countof(pscau->wzPassword), pwzData); + ExitOnFailure(hr, "Failed to copy password string to user object"); + } + else if (E_NOMOREITEMS == hr) + { + WcaLog(LOGMSG_STANDARD, "Error: Cannot locate User.User='%ls'", wzUser); + hr = E_FAIL; + } + else + { + ExitOnFailure(hr, "Error or found multiple matching User rows"); + } + +LExit: + ReleaseStr(pwzData); + + return hr; +} diff --git a/src/ext/Sql/ca/scauser.h b/src/ext/Sql/ca/scauser.h new file mode 100644 index 00000000..20e561f2 --- /dev/null +++ b/src/ext/Sql/ca/scauser.h @@ -0,0 +1,40 @@ +#pragma once +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + + +// structs +struct SCA_GROUP +{ + WCHAR wzKey[MAX_DARWIN_KEY + 1]; + WCHAR wzComponent[MAX_DARWIN_KEY + 1]; + + WCHAR wzDomain[MAX_DARWIN_COLUMN + 1]; + WCHAR wzName[MAX_DARWIN_COLUMN + 1]; + + SCA_GROUP *psgNext; +}; + +struct SCA_USER +{ + WCHAR wzKey[MAX_DARWIN_KEY + 1]; + WCHAR wzComponent[MAX_DARWIN_KEY + 1]; + INSTALLSTATE isInstalled; + INSTALLSTATE isAction; + + WCHAR wzDomain[MAX_DARWIN_COLUMN + 1]; + WCHAR wzName[MAX_DARWIN_COLUMN + 1]; + WCHAR wzPassword[MAX_DARWIN_COLUMN + 1]; + INT iAttributes; + + SCA_GROUP *psgGroups; + + SCA_USER *psuNext; +}; + + +// prototypes +HRESULT __stdcall ScaGetUser( + __in LPCWSTR wzUser, + __out SCA_USER* pscau + ); diff --git a/src/ext/Sql/ca/sqlca.cpp b/src/ext/Sql/ca/sqlca.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/ext/Sql/ca/sqlca.cpp @@ -0,0 +1,3 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +#include "precomp.h" diff --git a/src/ext/Sql/ca/sqlca.def b/src/ext/Sql/ca/sqlca.def new file mode 100644 index 00000000..e899d560 --- /dev/null +++ b/src/ext/Sql/ca/sqlca.def @@ -0,0 +1,13 @@ +; Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + + +LIBRARY "sqlca" + +EXPORTS +;scaexec.cpp + CreateDatabase + DropDatabase + ExecuteSqlStrings +;scasql.cpp + InstallSqlData + UninstallSqlData diff --git a/src/ext/Sql/ca/sqlca.vcxproj b/src/ext/Sql/ca/sqlca.vcxproj new file mode 100644 index 00000000..18becc5f --- /dev/null +++ b/src/ext/Sql/ca/sqlca.vcxproj @@ -0,0 +1,83 @@ + + + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM64 + + + Release + ARM64 + + + + + {4DCA6E4B-A1F1-4450-BC2D-94AC20F31935} + DynamicLibrary + sqlca + v142 + Unicode + sqlca.def + WiX Toolset Sql CustomAction + + + + + + + msi.lib + + + + + Create + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/Sql/nuget.config b/src/ext/Sql/nuget.config new file mode 100644 index 00000000..db7aba29 --- /dev/null +++ b/src/ext/Sql/nuget.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ext/Sql/test/WixToolsetTest.Sql/SqlExtensionFixture.cs b/src/ext/Sql/test/WixToolsetTest.Sql/SqlExtensionFixture.cs new file mode 100644 index 00000000..aa9d7a1f --- /dev/null +++ b/src/ext/Sql/test/WixToolsetTest.Sql/SqlExtensionFixture.cs @@ -0,0 +1,36 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolsetTest.Sql +{ + using System.Linq; + using WixBuildTools.TestSupport; + using WixToolset.Core.TestPackage; + using WixToolset.Sql; + using Xunit; + + public class SqlExtensionFixture + { + [Fact] + public void CanBuildUsingSqlStuff() + { + var folder = TestData.Get(@"TestData\UsingSql"); + var build = new Builder(folder, typeof(SqlExtensionFactory), new[] { folder }); + + var results = build.BuildAndQuery(Build, "Wix4SqlDatabase", "Wix4SqlFileSpec", "Wix4SqlScript", "Wix4SqlString"); + WixAssert.CompareLineByLine(new[] + { + "Wix4SqlDatabase:TestDB\tMySQLHostName\tMyInstanceName\tMyDB\tDatabaseComponent\t\tTestFileSpecId\tTestLogFileSpecId\t35", + "Wix4SqlFileSpec:TestFileSpecId\tTestFileSpecLogicalName\tTestFileSpec\t10MB\t100MB\t10%", + "Wix4SqlFileSpec:TestLogFileSpecId\tTestLogFileSpecLogicalName\tTestLogFileSpec\t1MB\t10MB\t1%", + "Wix4SqlScript:TestScript\tTestDB\tDatabaseComponent\tScriptBinary\t\t1\t", + "Wix4SqlString:TestString\tTestDB\tDatabaseComponent\tCREATE TABLE TestTable1(name varchar(20), value varchar(20))\t\t1\t", + }, results.ToArray()); + } + + private static void Build(string[] args) + { + var result = WixRunner.Execute(args) + .AssertSuccess(); + } + } +} diff --git a/src/ext/Sql/test/WixToolsetTest.Sql/TestData/UsingSql/Package.en-us.wxl b/src/ext/Sql/test/WixToolsetTest.Sql/TestData/UsingSql/Package.en-us.wxl new file mode 100644 index 00000000..38c12ac1 --- /dev/null +++ b/src/ext/Sql/test/WixToolsetTest.Sql/TestData/UsingSql/Package.en-us.wxl @@ -0,0 +1,11 @@ + + + + + + A newer version of [ProductName] is already installed. + MsiPackage + + diff --git a/src/ext/Sql/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs b/src/ext/Sql/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs new file mode 100644 index 00000000..ee3bc921 --- /dev/null +++ b/src/ext/Sql/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/Sql/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs b/src/ext/Sql/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs new file mode 100644 index 00000000..f7626926 --- /dev/null +++ b/src/ext/Sql/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/Sql/test/WixToolsetTest.Sql/TestData/UsingSql/example.txt b/src/ext/Sql/test/WixToolsetTest.Sql/TestData/UsingSql/example.txt new file mode 100644 index 00000000..1b4ffe8a --- /dev/null +++ b/src/ext/Sql/test/WixToolsetTest.Sql/TestData/UsingSql/example.txt @@ -0,0 +1 @@ +This is example.txt. \ No newline at end of file diff --git a/src/ext/Sql/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj b/src/ext/Sql/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj new file mode 100644 index 00000000..bbf3041d --- /dev/null +++ b/src/ext/Sql/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj @@ -0,0 +1,38 @@ + + + + + + netcoreapp3.1 + false + + + + NU1701 + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/Sql/test/WixToolsetTest.Sql/WixToolsetTest.Sql.v3.ncrunchproject b/src/ext/Sql/test/WixToolsetTest.Sql/WixToolsetTest.Sql.v3.ncrunchproject new file mode 100644 index 00000000..7b5b2139 --- /dev/null +++ b/src/ext/Sql/test/WixToolsetTest.Sql/WixToolsetTest.Sql.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/src/ext/Sql/wix.snk b/src/ext/Sql/wix.snk new file mode 100644 index 00000000..3908a66a Binary files /dev/null and b/src/ext/Sql/wix.snk differ diff --git a/src/ext/Sql/wixext/SqlCompiler.cs b/src/ext/Sql/wixext/SqlCompiler.cs new file mode 100644 index 00000000..46196e95 --- /dev/null +++ b/src/ext/Sql/wixext/SqlCompiler.cs @@ -0,0 +1,804 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using System; + using System.Collections.Generic; + using System.Xml.Linq; + using WixToolset.Data; + using WixToolset.Extensibility; + using WixToolset.Extensibility.Data; + using WixToolset.Sql.Symbols; + + /// + /// The compiler for the WiX Toolset SQL Server Extension. + /// + public sealed class SqlCompiler : BaseCompilerExtension + { + // sql database attributes definitions (from sca.h) + internal const int DbCreateOnInstall = 0x00000001; + internal const int DbDropOnUninstall = 0x00000002; + internal const int DbContinueOnError = 0x00000004; + internal const int DbDropOnInstall = 0x00000008; + internal const int DbCreateOnUninstall = 0x00000010; + internal const int DbConfirmOverwrite = 0x00000020; + internal const int DbCreateOnReinstall = 0x00000040; + internal const int DbDropOnReinstall = 0x00000080; + + // sql string/script attributes definitions (from sca.h) + internal const int SqlExecuteOnInstall = 0x00000001; + internal const int SqlExecuteOnUninstall = 0x00000002; + internal const int SqlContinueOnError = 0x00000004; + internal const int SqlRollback = 0x00000008; + internal const int SqlExecuteOnReinstall = 0x00000010; + + public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/sql"; + + /// + /// Processes an element for the Compiler. + /// + /// + /// + /// Parent element of element to process. + /// Element to process. + /// Extra information about the context in which this element is being parsed. + public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) + { + switch (parentElement.Name.LocalName) + { + case "Component": + var componentId = context["ComponentId"]; + + switch (element.Name.LocalName) + { + case "SqlDatabase": + this.ParseSqlDatabaseElement(intermediate, section, element, componentId); + break; + case "SqlScript": + this.ParseSqlScriptElement(intermediate, section, element, componentId, null); + break; + case "SqlString": + this.ParseSqlStringElement(intermediate, section, element, componentId, null); + break; + default: + this.ParseHelper.UnexpectedElement(parentElement, element); + break; + } + break; + case "Fragment": + case "Module": + case "Package": + switch (element.Name.LocalName) + { + case "SqlDatabase": + this.ParseSqlDatabaseElement(intermediate, section, element, null); + break; + default: + this.ParseHelper.UnexpectedElement(parentElement, element); + break; + } + break; + default: + this.ParseHelper.UnexpectedElement(parentElement, element); + break; + } + } + + /// + /// Parses a sql database element + /// + /// + /// + /// Element to parse. + /// Identifier for parent component. + private void ParseSqlDatabaseElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId) + { + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + Identifier id = null; + int attributes = 0; + string database = null; + Identifier fileSpec = null; + string instance = null; + Identifier logFileSpec = null; + string server = null; + string user = null; + + foreach (var attrib in element.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Id": + id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "ConfirmOverwrite": + if (null == componentId) + { + this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); + } + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= DbConfirmOverwrite; + } + break; + case "ContinueOnError": + if (null == componentId) + { + this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); + } + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= DbContinueOnError; + } + break; + case "CreateOnInstall": + if (null == componentId) + { + this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); + } + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= DbCreateOnInstall; + } + break; + case "CreateOnReinstall": + if (null == componentId) + { + this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); + } + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= DbCreateOnReinstall; + } + break; + case "CreateOnUninstall": + if (null == componentId) + { + this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); + } + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= DbCreateOnUninstall; + } + break; + case "Database": + database = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "DropOnInstall": + if (null == componentId) + { + this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); + } + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= DbDropOnInstall; + } + break; + case "DropOnReinstall": + if (null == componentId) + { + this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); + } + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= DbDropOnReinstall; + } + break; + + case "DropOnUninstall": + if (null == componentId) + { + this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); + } + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= DbDropOnUninstall; + } + break; + case "Instance": + instance = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Server": + server = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "User": + user = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + if (!this.ParseHelper.ContainsProperty(user)) + { + user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "User", user); + } + break; + default: + this.ParseHelper.UnexpectedAttribute(element, attrib); + break; + } + } + else + { + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); + } + } + + if (null == id) + { + id = this.ParseHelper.CreateIdentifier("sdb", componentId, server, database); + } + + if (null == database) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Database")); + } + else if (128 < database.Length) + { + this.Messaging.Write(ErrorMessages.IdentifierTooLongError(sourceLineNumbers, element.Name.LocalName, "Database", database, 128)); + } + + if (null == server) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Server")); + } + + if (0 == attributes && null != componentId) + { + this.Messaging.Write(SqlErrors.OneOfAttributesRequiredUnderComponent(sourceLineNumbers, element.Name.LocalName, "CreateOnInstall", "CreateOnUninstall", "DropOnInstall", "DropOnUninstall")); + } + + foreach (var child in element.Elements()) + { + if (this.Namespace == child.Name.Namespace) + { + var childSourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(child); + switch (child.Name.LocalName) + { + case "SqlScript": + if (null == componentId) + { + this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); + } + + this.ParseSqlScriptElement(intermediate, section, child, componentId, id?.Id); + break; + case "SqlString": + if (null == componentId) + { + this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); + } + + this.ParseSqlStringElement(intermediate, section, child, componentId, id?.Id); + break; + case "SqlFileSpec": + if (null == componentId) + { + this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); + } + else if (null != fileSpec) + { + this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, element.Name.LocalName, child.Name.LocalName, 1)); + } + + fileSpec = this.ParseSqlFileSpecElement(intermediate, section, child, id?.Id); + break; + case "SqlLogFileSpec": + if (null == componentId) + { + this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); + } + else if (null != logFileSpec) + { + this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, element.Name.LocalName, child.Name.LocalName, 1)); + } + + logFileSpec = this.ParseSqlFileSpecElement(intermediate, section, child, id?.Id); + break; + default: + this.ParseHelper.UnexpectedElement(element, child); + break; + } + } + else + { + this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, element, child); + } + } + + if (null != componentId) + { + // Reference InstallSqlData and UninstallSqlData since nothing will happen without it + this.AddReferenceToInstallSqlData(section, sourceLineNumbers); + } + + if (!this.Messaging.EncounteredError) + { + var symbol = section.AddSymbol(new SqlDatabaseSymbol(sourceLineNumbers, id) + { + Server = server, + Instance = instance, + Database = database, + ComponentRef = componentId, + UserRef = user, + FileSpecRef = fileSpec?.Id, + LogFileSpecRef = logFileSpec?.Id, + }); + + if (0 != attributes) + { + symbol.Attributes = attributes; + } + } + } + + /// + /// Parses a sql file specification element. + /// + /// + /// + /// Element to parse. + /// Identifier of sql file specification. + private Identifier ParseSqlFileSpecElement(Intermediate intermediate, IntermediateSection section, XElement element, string parentId) + { + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + Identifier id = null; + string fileName = null; + string growthSize = null; + string maxSize = null; + string name = null; + string size = null; + + foreach (var attrib in element.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Id": + id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Name": + name = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Filename": + fileName = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Size": + size = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "MaxSize": + maxSize = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "GrowthSize": + growthSize = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.ParseHelper.UnexpectedAttribute(element, attrib); + break; + } + } + else + { + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); + } + } + + if (null == id) + { + id = this.ParseHelper.CreateIdentifier("sfs", parentId, name, fileName); + } + + if (null == name) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Name")); + } + + if (null == fileName) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Filename")); + } + + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); + + if (!this.Messaging.EncounteredError) + { + var symbol = section.AddSymbol(new SqlFileSpecSymbol(sourceLineNumbers, id) + { + Name = name, + Filename = fileName, + }); + + if (null != size) + { + symbol.Size = size; + } + + if (null != maxSize) + { + symbol.MaxSize = maxSize; + } + + if (null != growthSize) + { + symbol.GrowthSize = growthSize; + } + } + + return id; + } + + /// + /// Parses a sql script element. + /// + /// Element to parse. + /// Identifier for parent component. + /// Optional database to execute script against. + private void ParseSqlScriptElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string sqlDb) + { + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + Identifier id = null; + int attributes = 0; + var rollbackAttribute = false; + var nonRollbackAttribute = false; + string binaryRef = null; + var sequence = CompilerConstants.IntegerNotSet; + string user = null; + + foreach (var attrib in element.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Id": + id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "BinaryRef": + binaryRef = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.Binary, binaryRef); + break; + case "Sequence": + sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); + break; + case "SqlDb": + if (null != sqlDb) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, element.Parent.Name.LocalName)); + } + sqlDb = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SqlSymbolDefinitions.SqlDatabase, sqlDb); + break; + case "User": + user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "User", user); + break; + + // Flag-setting attributes + case "ContinueOnError": + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlContinueOnError; + } + break; + case "ExecuteOnInstall": + if (rollbackAttribute) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + } + nonRollbackAttribute = true; + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnInstall; + } + break; + case "ExecuteOnReinstall": + if (rollbackAttribute) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + } + nonRollbackAttribute = true; + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnReinstall; + } + break; + case "ExecuteOnUninstall": + if (rollbackAttribute) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + } + nonRollbackAttribute = true; + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnUninstall; + } + break; + case "RollbackOnInstall": + if (nonRollbackAttribute) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); + } + rollbackAttribute = true; + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnInstall; + attributes |= SqlRollback; + } + break; + case "RollbackOnReinstall": + if (nonRollbackAttribute) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); + } + rollbackAttribute = true; + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnReinstall; + attributes |= SqlRollback; + } + break; + case "RollbackOnUninstall": + if (nonRollbackAttribute) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); + } + rollbackAttribute = true; + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnUninstall; + attributes |= SqlRollback; + } + break; + default: + this.ParseHelper.UnexpectedAttribute(element, attrib); + break; + } + } + else + { + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); + } + } + + if (null == id) + { + id = this.ParseHelper.CreateIdentifier("ssc", componentId, binaryRef, sqlDb); + } + + if (null == binaryRef) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "BinaryRef")); + } + + if (null == sqlDb) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "SqlDb")); + } + + if (0 == attributes) + { + this.Messaging.Write(ErrorMessages.ExpectedAttributes(sourceLineNumbers, element.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall", "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + } + + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); + + // Reference InstallSqlData and UninstallSqlData since nothing will happen without it + this.AddReferenceToInstallSqlData(section, sourceLineNumbers); + + if (!this.Messaging.EncounteredError) + { + var symbol = section.AddSymbol(new SqlScriptSymbol(sourceLineNumbers, id) + { + SqlDbRef = sqlDb, + ComponentRef = componentId, + ScriptBinaryRef = binaryRef, + UserRef = user, + Attributes = attributes, + }); + + if (CompilerConstants.IntegerNotSet != sequence) + { + symbol.Sequence = sequence; + } + } + } + + /// + /// Parses a sql string element. + /// + /// Element to parse. + /// Identifier for parent component. + /// Optional database to execute string against. + private void ParseSqlStringElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string sqlDb) + { + var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + Identifier id = null; + int attributes = 0; + var rollbackAttribute = false; + var nonRollbackAttribute = false; + var sequence = CompilerConstants.IntegerNotSet; + string sql = null; + string user = null; + + foreach (var attrib in element.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Id": + id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "ContinueOnError": + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlContinueOnError; + } + break; + case "ExecuteOnInstall": + if (rollbackAttribute) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + } + nonRollbackAttribute = true; + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnInstall; + } + break; + case "ExecuteOnReinstall": + if (rollbackAttribute) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + } + nonRollbackAttribute = true; + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnReinstall; + } + break; + case "ExecuteOnUninstall": + if (rollbackAttribute) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + } + nonRollbackAttribute = true; + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnUninstall; + } + break; + case "RollbackOnInstall": + if (nonRollbackAttribute) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); + } + rollbackAttribute = true; + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnInstall; + attributes |= SqlRollback; + } + break; + case "RollbackOnReinstall": + if (nonRollbackAttribute) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); + } + rollbackAttribute = true; + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnReinstall; + attributes |= SqlRollback; + } + break; + case "RollbackOnUninstall": + if (nonRollbackAttribute) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); + } + rollbackAttribute = true; + + if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= SqlExecuteOnUninstall; + attributes |= SqlRollback; + } + break; + case "Sequence": + sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); + break; + case "SQL": + sql = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "SqlDb": + if (null != sqlDb) + { + this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, "SqlDb", "SqlDatabase")); + } + + sqlDb = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SqlSymbolDefinitions.SqlDatabase, sqlDb); + break; + case "User": + user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "User", user); + break; + default: + this.ParseHelper.UnexpectedAttribute(element, attrib); + break; + } + } + else + { + this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); + } + } + + if (null == id) + { + id = this.ParseHelper.CreateIdentifier("sst", componentId, sql, sqlDb); + } + + if (null == sql) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "SQL")); + } + + if (null == sqlDb) + { + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "SqlDb")); + } + + if (0 == attributes) + { + this.Messaging.Write(ErrorMessages.ExpectedAttributes(sourceLineNumbers, element.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall", "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); + } + + this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); + + // Reference InstallSqlData and UninstallSqlData since nothing will happen without it + this.AddReferenceToInstallSqlData(section, sourceLineNumbers); + + if (!this.Messaging.EncounteredError) + { + var symbol = section.AddSymbol(new SqlStringSymbol(sourceLineNumbers, id) + { + SqlDbRef = sqlDb, + ComponentRef = componentId, + SQL = sql, + UserRef = user, + Attributes = attributes, + }); + + if (CompilerConstants.IntegerNotSet != sequence) + { + symbol.Sequence = sequence; + } + } + } + + private void AddReferenceToInstallSqlData(IntermediateSection section, SourceLineNumber sourceLineNumbers) + { + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4InstallSqlData", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); + this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4UninstallSqlData", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); + } + } +} diff --git a/src/ext/Sql/wixext/SqlDecompiler.cs b/src/ext/Sql/wixext/SqlDecompiler.cs new file mode 100644 index 00000000..52436b87 --- /dev/null +++ b/src/ext/Sql/wixext/SqlDecompiler.cs @@ -0,0 +1,514 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ +#if TODO_CONSIDER_DECOMPILER + using System.Collections; + using WixToolset.Data; + using WixToolset.Extensibility; + using Sql = WixToolset.Extensions.Serialize.Sql; + using Wix = WixToolset.Data.Serialize; + + /// + /// The decompiler for the WiX Toolset SQL Server Extension. + /// + public sealed class SqlDecompiler : DecompilerExtension + { + /// + /// Creates a decompiler for SQL Extension. + /// + public SqlDecompiler() + { + this.TableDefinitions = SqlExtensionData.GetExtensionTableDefinitions(); + } + + /// + /// Get the extensions library to be removed. + /// + /// Table definitions for library. + /// Library to remove from decompiled output. + public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions) + { + return SqlExtensionData.GetExtensionLibrary(tableDefinitions); + } + + /// + /// Decompiles an extension table. + /// + /// The table to decompile. + public override void DecompileTable(Table table) + { + switch (table.Name) + { + case "SqlDatabase": + this.DecompileSqlDatabaseTable(table); + break; + case "SqlFileSpec": + // handled in FinalizeSqlFileSpecTable + break; + case "SqlScript": + this.DecompileSqlScriptTable(table); + break; + case "SqlString": + this.DecompileSqlStringTable(table); + break; + default: + base.DecompileTable(table); + break; + } + } + + /// + /// Finalize decompilation. + /// + /// The collection of all tables. + public override void Finish(TableIndexedCollection tables) + { + this.FinalizeSqlFileSpecTable(tables); + this.FinalizeSqlScriptAndSqlStringTables(tables); + } + + /// + /// Decompile the SqlDatabase table. + /// + /// The table to decompile. + private void DecompileSqlDatabaseTable(Table table) + { + foreach (Row row in table.Rows) + { + Sql.SqlDatabase sqlDatabase = new Sql.SqlDatabase(); + + sqlDatabase.Id = (string)row[0]; + + if (null != row[1]) + { + sqlDatabase.Server = (string)row[1]; + } + + if (null != row[2]) + { + sqlDatabase.Instance = (string)row[2]; + } + + sqlDatabase.Database = (string)row[3]; + + if (null != row[5]) + { + sqlDatabase.User = (string)row[5]; + } + + // the FileSpec_ and FileSpec_Log columns will be handled in FinalizeSqlFileSpecTable + + if (null != row[8]) + { + int attributes = (int)row[8]; + + if (SqlCompiler.DbCreateOnInstall == (attributes & SqlCompiler.DbCreateOnInstall)) + { + sqlDatabase.CreateOnInstall = Sql.YesNoType.yes; + } + + if (SqlCompiler.DbDropOnUninstall == (attributes & SqlCompiler.DbDropOnUninstall)) + { + sqlDatabase.DropOnUninstall = Sql.YesNoType.yes; + } + + if (SqlCompiler.DbContinueOnError == (attributes & SqlCompiler.DbContinueOnError)) + { + sqlDatabase.ContinueOnError = Sql.YesNoType.yes; + } + + if (SqlCompiler.DbDropOnInstall == (attributes & SqlCompiler.DbDropOnInstall)) + { + sqlDatabase.DropOnInstall = Sql.YesNoType.yes; + } + + if (SqlCompiler.DbCreateOnUninstall == (attributes & SqlCompiler.DbCreateOnUninstall)) + { + sqlDatabase.CreateOnUninstall = Sql.YesNoType.yes; + } + + if (SqlCompiler.DbConfirmOverwrite == (attributes & SqlCompiler.DbConfirmOverwrite)) + { + sqlDatabase.ConfirmOverwrite = Sql.YesNoType.yes; + } + + if (SqlCompiler.DbCreateOnReinstall == (attributes & SqlCompiler.DbCreateOnReinstall)) + { + sqlDatabase.CreateOnReinstall = Sql.YesNoType.yes; + } + + if (SqlCompiler.DbDropOnReinstall == (attributes & SqlCompiler.DbDropOnReinstall)) + { + sqlDatabase.DropOnReinstall = Sql.YesNoType.yes; + } + } + + if (null != row[4]) + { + Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[4]); + + if (null != component) + { + component.AddChild(sqlDatabase); + } + else + { + this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[4], "Component")); + } + } + else + { + this.Core.RootElement.AddChild(sqlDatabase); + } + this.Core.IndexElement(row, sqlDatabase); + } + } + + /// + /// Decompile the SqlScript table. + /// + /// The table to decompile. + private void DecompileSqlScriptTable(Table table) + { + foreach (Row row in table.Rows) + { + Sql.SqlScript sqlScript = new Sql.SqlScript(); + + sqlScript.Id = (string)row[0]; + + // the Db_ and Component_ columns are handled in FinalizeSqlScriptAndSqlStringTables + + sqlScript.BinaryKey = (string)row[3]; + + if (null != row[4]) + { + sqlScript.User = (string)row[4]; + } + + int attributes = (int)row[5]; + + if (SqlCompiler.SqlContinueOnError == (attributes & SqlCompiler.SqlContinueOnError)) + { + sqlScript.ContinueOnError = Sql.YesNoType.yes; + } + + if (SqlCompiler.SqlExecuteOnInstall == (attributes & SqlCompiler.SqlExecuteOnInstall)) + { + sqlScript.ExecuteOnInstall = Sql.YesNoType.yes; + } + + if (SqlCompiler.SqlExecuteOnReinstall == (attributes & SqlCompiler.SqlExecuteOnReinstall)) + { + sqlScript.ExecuteOnReinstall = Sql.YesNoType.yes; + } + + if (SqlCompiler.SqlExecuteOnUninstall == (attributes & SqlCompiler.SqlExecuteOnUninstall)) + { + sqlScript.ExecuteOnUninstall = Sql.YesNoType.yes; + } + + if ((SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnInstall) == (attributes & (SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnInstall))) + { + sqlScript.RollbackOnInstall = Sql.YesNoType.yes; + } + + if ((SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnReinstall) == (attributes & (SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnReinstall))) + { + sqlScript.RollbackOnReinstall = Sql.YesNoType.yes; + } + + if ((SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnUninstall) == (attributes & (SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnUninstall))) + { + sqlScript.RollbackOnUninstall = Sql.YesNoType.yes; + } + + if (null != row[6]) + { + sqlScript.Sequence = (int)row[6]; + } + + this.Core.IndexElement(row, sqlScript); + } + } + + /// + /// Decompile the SqlString table. + /// + /// The table to decompile. + private void DecompileSqlStringTable(Table table) + { + foreach (Row row in table.Rows) + { + Sql.SqlString sqlString = new Sql.SqlString(); + + sqlString.Id = (string)row[0]; + + // the Db_ and Component_ columns are handled in FinalizeSqlScriptAndSqlStringTables + + sqlString.SQL = (string)row[3]; + + if (null != row[4]) + { + sqlString.User = (string)row[4]; + } + + int attributes = (int)row[5]; + + if (SqlCompiler.SqlContinueOnError == (attributes & SqlCompiler.SqlContinueOnError)) + { + sqlString.ContinueOnError = Sql.YesNoType.yes; + } + + if (SqlCompiler.SqlExecuteOnInstall == (attributes & SqlCompiler.SqlExecuteOnInstall)) + { + sqlString.ExecuteOnInstall = Sql.YesNoType.yes; + } + + if (SqlCompiler.SqlExecuteOnReinstall == (attributes & SqlCompiler.SqlExecuteOnReinstall)) + { + sqlString.ExecuteOnReinstall = Sql.YesNoType.yes; + } + + if (SqlCompiler.SqlExecuteOnUninstall == (attributes & SqlCompiler.SqlExecuteOnUninstall)) + { + sqlString.ExecuteOnUninstall = Sql.YesNoType.yes; + } + + if ((SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnInstall) == (attributes & (SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnInstall))) + { + sqlString.RollbackOnInstall = Sql.YesNoType.yes; + } + + if ((SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnReinstall) == (attributes & (SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnReinstall))) + { + sqlString.RollbackOnReinstall = Sql.YesNoType.yes; + } + + if ((SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnUninstall) == (attributes & (SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnUninstall))) + { + sqlString.RollbackOnUninstall = Sql.YesNoType.yes; + } + + if (null != row[6]) + { + sqlString.Sequence = (int)row[6]; + } + + this.Core.IndexElement(row, sqlString); + } + } + + /// + /// Finalize the SqlFileSpec table. + /// + /// The collection of all tables. + /// + /// Since rows of the SqlFileSpec table are represented by either + /// the SqlFileSpec or SqlLogFileSpec depending upon the context in + /// which they are used in the SqlDatabase table, decompilation of this + /// table must occur after the SqlDatbase parents are decompiled. + /// + private void FinalizeSqlFileSpecTable(TableIndexedCollection tables) + { + Table sqlDatabaseTable = tables["SqlDatabase"]; + Table sqlFileSpecTable = tables["SqlFileSpec"]; + + if (null != sqlDatabaseTable && null != sqlFileSpecTable) + { + Hashtable sqlFileSpecRows = new Hashtable(); + + // index each SqlFileSpec row by its primary key + foreach (Row row in sqlFileSpecTable.Rows) + { + sqlFileSpecRows.Add(row[0], row); + } + + // create the necessary SqlFileSpec and SqlLogFileSpec elements for each row + foreach (Row row in sqlDatabaseTable.Rows) + { + Sql.SqlDatabase sqlDatabase = (Sql.SqlDatabase)this.Core.GetIndexedElement(row); + + if (null != row[6]) + { + Row sqlFileSpecRow = (Row)sqlFileSpecRows[row[6]]; + + if (null != sqlFileSpecRow) + { + Sql.SqlFileSpec sqlFileSpec = new Sql.SqlFileSpec(); + + sqlFileSpec.Id = (string)sqlFileSpecRow[0]; + + if (null != sqlFileSpecRow[1]) + { + sqlFileSpec.Name = (string)sqlFileSpecRow[1]; + } + + sqlFileSpec.Filename = (string)sqlFileSpecRow[2]; + + if (null != sqlFileSpecRow[3]) + { + sqlFileSpec.Size = (string)sqlFileSpecRow[3]; + } + + if (null != sqlFileSpecRow[4]) + { + sqlFileSpec.MaxSize = (string)sqlFileSpecRow[4]; + } + + if (null != sqlFileSpecRow[5]) + { + sqlFileSpec.GrowthSize = (string)sqlFileSpecRow[5]; + } + + sqlDatabase.AddChild(sqlFileSpec); + } + else + { + this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, sqlDatabaseTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "FileSpec_", (string)row[6], "SqlFileSpec")); + } + } + + if (null != row[7]) + { + Row sqlFileSpecRow = (Row)sqlFileSpecRows[row[7]]; + + if (null != sqlFileSpecRow) + { + Sql.SqlLogFileSpec sqlLogFileSpec = new Sql.SqlLogFileSpec(); + + sqlLogFileSpec.Id = (string)sqlFileSpecRow[0]; + + if (null != sqlFileSpecRow[1]) + { + sqlLogFileSpec.Name = (string)sqlFileSpecRow[1]; + } + + sqlLogFileSpec.Filename = (string)sqlFileSpecRow[2]; + + if (null != sqlFileSpecRow[3]) + { + sqlLogFileSpec.Size = (string)sqlFileSpecRow[3]; + } + + if (null != sqlFileSpecRow[4]) + { + sqlLogFileSpec.MaxSize = (string)sqlFileSpecRow[4]; + } + + if (null != sqlFileSpecRow[5]) + { + sqlLogFileSpec.GrowthSize = (string)sqlFileSpecRow[5]; + } + + sqlDatabase.AddChild(sqlLogFileSpec); + } + else + { + this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, sqlDatabaseTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "FileSpec_Log", (string)row[7], "SqlFileSpec")); + } + } + } + } + } + + /// + /// Finalize the SqlScript table. + /// + /// The collection of all tables. + /// + /// The SqlScript and SqlString tables contain a foreign key into the SqlDatabase + /// and Component tables. Depending upon the parent of the SqlDatabase + /// element, the SqlScript and SqlString elements are nested under either the + /// SqlDatabase or the Component element. + /// + private void FinalizeSqlScriptAndSqlStringTables(TableIndexedCollection tables) + { + Table sqlDatabaseTable = tables["SqlDatabase"]; + Table sqlScriptTable = tables["SqlScript"]; + Table sqlStringTable = tables["SqlString"]; + + Hashtable sqlDatabaseRows = new Hashtable(); + + // index each SqlDatabase row by its primary key + if (null != sqlDatabaseTable) + { + foreach (Row row in sqlDatabaseTable.Rows) + { + sqlDatabaseRows.Add(row[0], row); + } + } + + if (null != sqlScriptTable) + { + foreach (Row row in sqlScriptTable.Rows) + { + Sql.SqlScript sqlScript = (Sql.SqlScript)this.Core.GetIndexedElement(row); + + Row sqlDatabaseRow = (Row)sqlDatabaseRows[row[1]]; + string databaseComponent = (string)sqlDatabaseRow[4]; + + // determine if the SqlScript element should be nested under the database or another component + if (null != databaseComponent && databaseComponent == (string)row[2]) + { + Sql.SqlDatabase sqlDatabase = (Sql.SqlDatabase)this.Core.GetIndexedElement(sqlDatabaseRow); + + sqlDatabase.AddChild(sqlScript); + } + else // nest under the component of the SqlDatabase row + { + Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[2]); + + // set the Database value + sqlScript.SqlDb = (string)row[1]; + + if (null != component) + { + component.AddChild(sqlScript); + } + else + { + this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, sqlScriptTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[2], "Component")); + } + } + } + } + + if (null != sqlStringTable) + { + foreach (Row row in sqlStringTable.Rows) + { + Sql.SqlString sqlString = (Sql.SqlString)this.Core.GetIndexedElement(row); + + Row sqlDatabaseRow = (Row)sqlDatabaseRows[row[1]]; + string databaseComponent = (string)sqlDatabaseRow[4]; + + // determine if the SqlScript element should be nested under the database or another component + if (null != databaseComponent && databaseComponent == (string)row[2]) + { + Sql.SqlDatabase sqlDatabase = (Sql.SqlDatabase)this.Core.GetIndexedElement(sqlDatabaseRow); + + sqlDatabase.AddChild(sqlString); + } + else // nest under the component of the SqlDatabase row + { + Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[2]); + + // set the Database value + sqlString.SqlDb = (string)row[1]; + + if (null != component) + { + component.AddChild(sqlString); + } + else + { + this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, sqlStringTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[2], "Component")); + } + } + } + } + } + } +#endif +} diff --git a/src/ext/Sql/wixext/SqlErrors.cs b/src/ext/Sql/wixext/SqlErrors.cs new file mode 100644 index 00000000..f25728bd --- /dev/null +++ b/src/ext/Sql/wixext/SqlErrors.cs @@ -0,0 +1,48 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using System.Resources; + using WixToolset.Data; + + public static class SqlErrors + { + public static Message IllegalAttributeWithoutComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName) + { + return Message(sourceLineNumbers, Ids.IllegalAttributeWithoutComponent, "The {0}/@{1} attribute cannot be specified unless the element has a Component as an ancestor. A {0} that does not have a Component ancestor is not installed.", elementName, attributeName); + } + + public static Message IllegalElementWithoutComponent(SourceLineNumber sourceLineNumbers, string elementName) + { + return Message(sourceLineNumbers, Ids.IllegalElementWithoutComponent, "The {0} element cannot be specified unless the element has a Component as an ancestor. A {0} that does not have a Component ancestor is not installed.", elementName); + } + + public static Message OneOfAttributesRequiredUnderComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName1, string attributeName2, string attributeName3, string attributeName4) + { + return Message(sourceLineNumbers, Ids.OneOfAttributesRequiredUnderComponent, "When nested under a Component, the {0} element must have one of the following attributes specified: {1}, {2}, {3} or {4}.", elementName, attributeName1, attributeName2, attributeName3, attributeName4); + } + + public static Message DeprecatedBinaryChildElement(SourceLineNumber sourceLineNumbers, string elementName) + { + return Message(sourceLineNumbers, Ids.DeprecatedBinaryChildElement, "The {0} element contains a deprecated child Binary element. Please move the Binary element under a Fragment, Module, or Product element and set the {0}/@BinaryKey attribute to the value of the Binary/@Id attribute.", elementName); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); + } + + private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args) + { + return new Message(sourceLineNumber, MessageLevel.Error, (int)id, resourceManager, resourceName, args); + } + + public enum Ids + { + IllegalAttributeWithoutComponent = 5100, + IllegalElementWithoutComponent = 5101, + OneOfAttributesRequiredUnderComponent = 5102, + DeprecatedBinaryChildElement = 5103, + } + } +} \ No newline at end of file diff --git a/src/ext/Sql/wixext/SqlExtensionData.cs b/src/ext/Sql/wixext/SqlExtensionData.cs new file mode 100644 index 00000000..60de94fe --- /dev/null +++ b/src/ext/Sql/wixext/SqlExtensionData.cs @@ -0,0 +1,30 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using WixToolset.Data; + using WixToolset.Extensibility; + + /// + /// The WiX Toolset SQL Server Extension. + /// + public sealed class SqlExtensionData : BaseExtensionData + { + /// + /// Gets the default culture. + /// + /// The default culture. + public override string DefaultCulture => "en-US"; + + public override bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) + { + symbolDefinition = SqlSymbolDefinitions.ByName(name); + return symbolDefinition != null; + } + + public override Intermediate GetLibrary(ISymbolDefinitionCreator symbolDefinitions) + { + return Intermediate.Load(typeof(SqlExtensionData).Assembly, "WixToolset.Sql.sql.wixlib", symbolDefinitions); + } + } +} diff --git a/src/ext/Sql/wixext/SqlExtensionFactory.cs b/src/ext/Sql/wixext/SqlExtensionFactory.cs new file mode 100644 index 00000000..279106d3 --- /dev/null +++ b/src/ext/Sql/wixext/SqlExtensionFactory.cs @@ -0,0 +1,18 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using System; + using System.Collections.Generic; + using WixToolset.Extensibility; + + public class SqlExtensionFactory : BaseExtensionFactory + { + protected override IReadOnlyCollection ExtensionTypes => new[] + { + typeof(SqlCompiler), + typeof(SqlExtensionData), + typeof(SqlWindowsInstallerBackendBinderExtension), + }; + } +} diff --git a/src/ext/Sql/wixext/SqlTableDefinitions.cs b/src/ext/Sql/wixext/SqlTableDefinitions.cs new file mode 100644 index 00000000..029a092e --- /dev/null +++ b/src/ext/Sql/wixext/SqlTableDefinitions.cs @@ -0,0 +1,82 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using WixToolset.Data.WindowsInstaller; + + public static class SqlTableDefinitions + { + public static readonly TableDefinition SqlDatabase = new TableDefinition( + "Wix4SqlDatabase", + SqlSymbolDefinitions.SqlDatabase, + new[] + { + new ColumnDefinition("SqlDb", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Server", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Primary key, name of server running SQL Server"), + new ColumnDefinition("Instance", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Primary key, name of SQL Server instance"), + new ColumnDefinition("Database", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Primary key, name of database in a SQL Server"), + new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key, Component used to determine install state ", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "User", keyColumn: 1, description: "Foreign key, User used to log into database", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("FileSpec_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "Wix4SqlFileSpec", keyColumn: 1, description: "Foreign key referencing SqlFileSpec.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("FileSpec_Log", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "Wix4SqlFileSpec", keyColumn: 1, description: "Foreign key referencing SqlFileSpec.", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, minValue: 0, maxValue: 255, description: "1 == create on install, 2 == drop on uninstall, 4 == continue on error, 8 == drop on install, 16 == create on uninstall, 32 == confirm update existing table, 64 == create on reinstall, 128 == drop on reinstall"), + }, + symbolIdIsPrimaryKey: true + ); + + public static readonly TableDefinition SqlFileSpec = new TableDefinition( + "Wix4SqlFileSpec", + SqlSymbolDefinitions.SqlFileSpec, + new[] + { + new ColumnDefinition("FileSpec", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Name", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Logical name of filespec", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Filename", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Filename to use (path must exist)", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("Size", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Initial size for file", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("MaxSize", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Maximum size for file", modularizeType: ColumnModularizeType.Property), + new ColumnDefinition("GrowthSize", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Size file should grow when necessary", modularizeType: ColumnModularizeType.Property), + }, + symbolIdIsPrimaryKey: true + ); + + public static readonly TableDefinition SqlScript = new TableDefinition( + "Wix4SqlScript", + SqlSymbolDefinitions.SqlScript, + new[] + { + new ColumnDefinition("Script", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token"), + new ColumnDefinition("SqlDb_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Wix4SqlDatabase", keyColumn: 1, description: "Foreign key, SQL Server key", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key, Component used to determine install state", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("ScriptBinary_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Binary", keyColumn: 1, description: "Foreign key, Binary stream that contains SQL Script to execute", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "User", keyColumn: 1, description: "Foreign key, User used to log into database", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, possibilities: "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31", description: "1 == execute on install, 2 == execute on uninstall, 4 == continue on error, 8 == rollback on install, 16 == rollback on uninstall"), + new ColumnDefinition("Sequence", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Order to execute SQL Queries in"), + }, + symbolIdIsPrimaryKey: true + ); + + public static readonly TableDefinition SqlString = new TableDefinition( + "Wix4SqlString", + SqlSymbolDefinitions.SqlString, + new[] + { + new ColumnDefinition("String", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Id for the Wix4SqlString", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("SqlDb_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Wix4SqlDatabase", keyColumn: 1, description: "Foreign key, SQL Server key", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key, Component used to determine install state", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("SQL", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "SQL query to execute"), + new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "User", keyColumn: 1, description: "Foreign key, User used to log into database", modularizeType: ColumnModularizeType.Column), + new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, possibilities: "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31", description: "1 == execute on install, 2 == execute on uninstall, 4 == continue on error, 8 == rollback on install, 16 == rollback on uninstall"), + new ColumnDefinition("Sequence", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Order to execute SQL Queries in"), + }, + symbolIdIsPrimaryKey: true + ); + + public static readonly TableDefinition[] All = new[] + { + SqlDatabase, + SqlFileSpec, + SqlScript, + SqlString, + }; + } +} diff --git a/src/ext/Sql/wixext/SqlWindowsInstallerBackendExtension.cs b/src/ext/Sql/wixext/SqlWindowsInstallerBackendExtension.cs new file mode 100644 index 00000000..2ccdcc56 --- /dev/null +++ b/src/ext/Sql/wixext/SqlWindowsInstallerBackendExtension.cs @@ -0,0 +1,13 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using System.Collections.Generic; + using WixToolset.Data.WindowsInstaller; + using WixToolset.Extensibility; + + public class SqlWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension + { + public override IReadOnlyCollection TableDefinitions => SqlTableDefinitions.All; + } +} diff --git a/src/ext/Sql/wixext/Symbols/SqlDatabaseSymbol.cs b/src/ext/Sql/wixext/Symbols/SqlDatabaseSymbol.cs new file mode 100644 index 00000000..6f0820ac --- /dev/null +++ b/src/ext/Sql/wixext/Symbols/SqlDatabaseSymbol.cs @@ -0,0 +1,103 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using WixToolset.Data; + using WixToolset.Sql.Symbols; + + public static partial class SqlSymbolDefinitions + { + public static readonly IntermediateSymbolDefinition SqlDatabase = new IntermediateSymbolDefinition( + SqlSymbolDefinitionType.SqlDatabase.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Server), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Instance), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Database), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.ComponentRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.UserRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.FileSpecRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.LogFileSpecRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Attributes), IntermediateFieldType.Number), + }, + typeof(SqlDatabaseSymbol)); + } +} + +namespace WixToolset.Sql.Symbols +{ + using WixToolset.Data; + + public enum SqlDatabaseSymbolFields + { + Server, + Instance, + Database, + ComponentRef, + UserRef, + FileSpecRef, + LogFileSpecRef, + Attributes, + } + + public class SqlDatabaseSymbol : IntermediateSymbol + { + public SqlDatabaseSymbol() : base(SqlSymbolDefinitions.SqlDatabase, null, null) + { + } + + public SqlDatabaseSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlDatabase, sourceLineNumber, id) + { + } + + public IntermediateField this[SqlDatabaseSymbolFields index] => this.Fields[(int)index]; + + public string Server + { + get => this.Fields[(int)SqlDatabaseSymbolFields.Server].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.Server, value); + } + + public string Instance + { + get => this.Fields[(int)SqlDatabaseSymbolFields.Instance].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.Instance, value); + } + + public string Database + { + get => this.Fields[(int)SqlDatabaseSymbolFields.Database].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.Database, value); + } + + public string ComponentRef + { + get => this.Fields[(int)SqlDatabaseSymbolFields.ComponentRef].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.ComponentRef, value); + } + + public string UserRef + { + get => this.Fields[(int)SqlDatabaseSymbolFields.UserRef].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.UserRef, value); + } + + public string FileSpecRef + { + get => this.Fields[(int)SqlDatabaseSymbolFields.FileSpecRef].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.FileSpecRef, value); + } + + public string LogFileSpecRef + { + get => this.Fields[(int)SqlDatabaseSymbolFields.LogFileSpecRef].AsString(); + set => this.Set((int)SqlDatabaseSymbolFields.LogFileSpecRef, value); + } + + public int Attributes + { + get => this.Fields[(int)SqlDatabaseSymbolFields.Attributes].AsNumber(); + set => this.Set((int)SqlDatabaseSymbolFields.Attributes, value); + } + } +} \ No newline at end of file diff --git a/src/ext/Sql/wixext/Symbols/SqlFileSpecSymbol.cs b/src/ext/Sql/wixext/Symbols/SqlFileSpecSymbol.cs new file mode 100644 index 00000000..d9eecc62 --- /dev/null +++ b/src/ext/Sql/wixext/Symbols/SqlFileSpecSymbol.cs @@ -0,0 +1,79 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using WixToolset.Data; + using WixToolset.Sql.Symbols; + + public static partial class SqlSymbolDefinitions + { + public static readonly IntermediateSymbolDefinition SqlFileSpec = new IntermediateSymbolDefinition( + SqlSymbolDefinitionType.SqlFileSpec.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.Name), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.Filename), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.Size), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.MaxSize), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.GrowthSize), IntermediateFieldType.String), + }, + typeof(SqlFileSpecSymbol)); + } +} + +namespace WixToolset.Sql.Symbols +{ + using WixToolset.Data; + + public enum SqlFileSpecSymbolFields + { + Name, + Filename, + Size, + MaxSize, + GrowthSize, + } + + public class SqlFileSpecSymbol : IntermediateSymbol + { + public SqlFileSpecSymbol() : base(SqlSymbolDefinitions.SqlFileSpec, null, null) + { + } + + public SqlFileSpecSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlFileSpec, sourceLineNumber, id) + { + } + + public IntermediateField this[SqlFileSpecSymbolFields index] => this.Fields[(int)index]; + + public string Name + { + get => this.Fields[(int)SqlFileSpecSymbolFields.Name].AsString(); + set => this.Set((int)SqlFileSpecSymbolFields.Name, value); + } + + public string Filename + { + get => this.Fields[(int)SqlFileSpecSymbolFields.Filename].AsString(); + set => this.Set((int)SqlFileSpecSymbolFields.Filename, value); + } + + public string Size + { + get => this.Fields[(int)SqlFileSpecSymbolFields.Size].AsString(); + set => this.Set((int)SqlFileSpecSymbolFields.Size, value); + } + + public string MaxSize + { + get => this.Fields[(int)SqlFileSpecSymbolFields.MaxSize].AsString(); + set => this.Set((int)SqlFileSpecSymbolFields.MaxSize, value); + } + + public string GrowthSize + { + get => this.Fields[(int)SqlFileSpecSymbolFields.GrowthSize].AsString(); + set => this.Set((int)SqlFileSpecSymbolFields.GrowthSize, value); + } + } +} \ No newline at end of file diff --git a/src/ext/Sql/wixext/Symbols/SqlScriptSymbol.cs b/src/ext/Sql/wixext/Symbols/SqlScriptSymbol.cs new file mode 100644 index 00000000..94c70390 --- /dev/null +++ b/src/ext/Sql/wixext/Symbols/SqlScriptSymbol.cs @@ -0,0 +1,87 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using WixToolset.Data; + using WixToolset.Sql.Symbols; + + public static partial class SqlSymbolDefinitions + { + public static readonly IntermediateSymbolDefinition SqlScript = new IntermediateSymbolDefinition( + SqlSymbolDefinitionType.SqlScript.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.SqlDbRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.ComponentRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.ScriptBinaryRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.UserRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.Attributes), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.Sequence), IntermediateFieldType.Number), + }, + typeof(SqlScriptSymbol)); + } +} + +namespace WixToolset.Sql.Symbols +{ + using WixToolset.Data; + + public enum SqlScriptSymbolFields + { + SqlDbRef, + ComponentRef, + ScriptBinaryRef, + UserRef, + Attributes, + Sequence, + } + + public class SqlScriptSymbol : IntermediateSymbol + { + public SqlScriptSymbol() : base(SqlSymbolDefinitions.SqlScript, null, null) + { + } + + public SqlScriptSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlScript, sourceLineNumber, id) + { + } + + public IntermediateField this[SqlScriptSymbolFields index] => this.Fields[(int)index]; + + public string SqlDbRef + { + get => this.Fields[(int)SqlScriptSymbolFields.SqlDbRef].AsString(); + set => this.Set((int)SqlScriptSymbolFields.SqlDbRef, value); + } + + public string ComponentRef + { + get => this.Fields[(int)SqlScriptSymbolFields.ComponentRef].AsString(); + set => this.Set((int)SqlScriptSymbolFields.ComponentRef, value); + } + + public string ScriptBinaryRef + { + get => this.Fields[(int)SqlScriptSymbolFields.ScriptBinaryRef].AsString(); + set => this.Set((int)SqlScriptSymbolFields.ScriptBinaryRef, value); + } + + public string UserRef + { + get => this.Fields[(int)SqlScriptSymbolFields.UserRef].AsString(); + set => this.Set((int)SqlScriptSymbolFields.UserRef, value); + } + + public int Attributes + { + get => this.Fields[(int)SqlScriptSymbolFields.Attributes].AsNumber(); + set => this.Set((int)SqlScriptSymbolFields.Attributes, value); + } + + public int? Sequence + { + get => this.Fields[(int)SqlScriptSymbolFields.Sequence].AsNullableNumber(); + set => this.Set((int)SqlScriptSymbolFields.Sequence, value); + } + } +} \ No newline at end of file diff --git a/src/ext/Sql/wixext/Symbols/SqlStringSymbol.cs b/src/ext/Sql/wixext/Symbols/SqlStringSymbol.cs new file mode 100644 index 00000000..73a8206e --- /dev/null +++ b/src/ext/Sql/wixext/Symbols/SqlStringSymbol.cs @@ -0,0 +1,87 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using WixToolset.Data; + using WixToolset.Sql.Symbols; + + public static partial class SqlSymbolDefinitions + { + public static readonly IntermediateSymbolDefinition SqlString = new IntermediateSymbolDefinition( + SqlSymbolDefinitionType.SqlString.ToString(), + new[] + { + new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.SqlDbRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.ComponentRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.SQL), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.UserRef), IntermediateFieldType.String), + new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.Attributes), IntermediateFieldType.Number), + new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.Sequence), IntermediateFieldType.Number), + }, + typeof(SqlStringSymbol)); + } +} + +namespace WixToolset.Sql.Symbols +{ + using WixToolset.Data; + + public enum SqlStringSymbolFields + { + SqlDbRef, + ComponentRef, + SQL, + UserRef, + Attributes, + Sequence, + } + + public class SqlStringSymbol : IntermediateSymbol + { + public SqlStringSymbol() : base(SqlSymbolDefinitions.SqlString, null, null) + { + } + + public SqlStringSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlString, sourceLineNumber, id) + { + } + + public IntermediateField this[SqlStringSymbolFields index] => this.Fields[(int)index]; + + public string SqlDbRef + { + get => this.Fields[(int)SqlStringSymbolFields.SqlDbRef].AsString(); + set => this.Set((int)SqlStringSymbolFields.SqlDbRef, value); + } + + public string ComponentRef + { + get => this.Fields[(int)SqlStringSymbolFields.ComponentRef].AsString(); + set => this.Set((int)SqlStringSymbolFields.ComponentRef, value); + } + + public string SQL + { + get => this.Fields[(int)SqlStringSymbolFields.SQL].AsString(); + set => this.Set((int)SqlStringSymbolFields.SQL, value); + } + + public string UserRef + { + get => this.Fields[(int)SqlStringSymbolFields.UserRef].AsString(); + set => this.Set((int)SqlStringSymbolFields.UserRef, value); + } + + public int Attributes + { + get => this.Fields[(int)SqlStringSymbolFields.Attributes].AsNumber(); + set => this.Set((int)SqlStringSymbolFields.Attributes, value); + } + + public int? Sequence + { + get => this.Fields[(int)SqlStringSymbolFields.Sequence].AsNullableNumber(); + set => this.Set((int)SqlStringSymbolFields.Sequence, value); + } + } +} \ No newline at end of file diff --git a/src/ext/Sql/wixext/Symbols/SqlSymbolDefinitions.cs b/src/ext/Sql/wixext/Symbols/SqlSymbolDefinitions.cs new file mode 100644 index 00000000..336f1546 --- /dev/null +++ b/src/ext/Sql/wixext/Symbols/SqlSymbolDefinitions.cs @@ -0,0 +1,51 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Sql +{ + using System; + using WixToolset.Data; + + public enum SqlSymbolDefinitionType + { + SqlDatabase, + SqlFileSpec, + SqlScript, + SqlString, + } + + public static partial class SqlSymbolDefinitions + { + public static readonly Version Version = new Version("4.0.0"); + + public static IntermediateSymbolDefinition ByName(string name) + { + if (!Enum.TryParse(name, out SqlSymbolDefinitionType type)) + { + return null; + } + + return ByType(type); + } + + public static IntermediateSymbolDefinition ByType(SqlSymbolDefinitionType type) + { + switch (type) + { + case SqlSymbolDefinitionType.SqlDatabase: + return SqlSymbolDefinitions.SqlDatabase; + + case SqlSymbolDefinitionType.SqlFileSpec: + return SqlSymbolDefinitions.SqlFileSpec; + + case SqlSymbolDefinitionType.SqlScript: + return SqlSymbolDefinitions.SqlScript; + + case SqlSymbolDefinitionType.SqlString: + return SqlSymbolDefinitions.SqlString; + + default: + throw new ArgumentOutOfRangeException(nameof(type)); + } + } + } +} diff --git a/src/ext/Sql/wixext/WixToolset.Sql.wixext.csproj b/src/ext/Sql/wixext/WixToolset.Sql.wixext.csproj new file mode 100644 index 00000000..5a1ebeb0 --- /dev/null +++ b/src/ext/Sql/wixext/WixToolset.Sql.wixext.csproj @@ -0,0 +1,30 @@ + + + + + + netstandard2.0 + WixToolset.Sql + WiX Toolset Sql Extension + WiX Toolset Sql Extension + embedded + true + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/Sql/wixext/WixToolset.Sql.wixext.nuspec b/src/ext/Sql/wixext/WixToolset.Sql.wixext.nuspec new file mode 100644 index 00000000..ba3eaade --- /dev/null +++ b/src/ext/Sql/wixext/WixToolset.Sql.wixext.nuspec @@ -0,0 +1,25 @@ + + + + $id$ + $version$ + $title$ + $description$ + $authors$ + MS-RL + false + $copyright$ + $projectUrl$ + + + + + + + + + + + + + diff --git a/src/ext/Sql/wixext/WixToolset.Sql.wixext.targets b/src/ext/Sql/wixext/WixToolset.Sql.wixext.targets new file mode 100644 index 00000000..4950e119 --- /dev/null +++ b/src/ext/Sql/wixext/WixToolset.Sql.wixext.targets @@ -0,0 +1,11 @@ + + + + + + $(MSBuildThisFileDirectory)..\tools\WixToolset.Sql.wixext.dll + + + + + diff --git a/src/ext/Sql/wixlib/SqlExtension.wxi b/src/ext/Sql/wixlib/SqlExtension.wxi new file mode 100644 index 00000000..c9261f1d --- /dev/null +++ b/src/ext/Sql/wixlib/SqlExtension.wxi @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/Sql/wixlib/SqlExtension.wxs b/src/ext/Sql/wixlib/SqlExtension.wxs new file mode 100644 index 00000000..8b5320fa --- /dev/null +++ b/src/ext/Sql/wixlib/SqlExtension.wxs @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/src/ext/Sql/wixlib/SqlExtension_arm64.wxs b/src/ext/Sql/wixlib/SqlExtension_arm64.wxs new file mode 100644 index 00000000..e8d22f69 --- /dev/null +++ b/src/ext/Sql/wixlib/SqlExtension_arm64.wxs @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/ext/Sql/wixlib/SqlExtension_x64.wxs b/src/ext/Sql/wixlib/SqlExtension_x64.wxs new file mode 100644 index 00000000..e55a14e4 --- /dev/null +++ b/src/ext/Sql/wixlib/SqlExtension_x64.wxs @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/ext/Sql/wixlib/SqlExtension_x86.wxs b/src/ext/Sql/wixlib/SqlExtension_x86.wxs new file mode 100644 index 00000000..1a51ed91 --- /dev/null +++ b/src/ext/Sql/wixlib/SqlExtension_x86.wxs @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/ext/Sql/wixlib/caDecor.wxi b/src/ext/Sql/wixlib/caDecor.wxi new file mode 100644 index 00000000..b1711518 --- /dev/null +++ b/src/ext/Sql/wixlib/caDecor.wxi @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ext/Sql/wixlib/caerr.wxi b/src/ext/Sql/wixlib/caerr.wxi new file mode 100644 index 00000000..ff7ec121 --- /dev/null +++ b/src/ext/Sql/wixlib/caerr.wxi @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ext/Sql/wixlib/de-de.wxl b/src/ext/Sql/wixlib/de-de.wxl new file mode 100644 index 00000000..ed2313a4 --- /dev/null +++ b/src/ext/Sql/wixlib/de-de.wxl @@ -0,0 +1,16 @@ + + + + + Fehler [2]: Erstellen der SQL-Datenbank fehlgeschlagen: [3], Fehlerbeschreibung: [4]. + Fehler [2]: Löschen der SQL-Datenbank fehlgeschlagen: [3], Fehlerbeschreibung: [4]. + Verbinden mit der SQL-Datenbank fehlgeschlagen. ([2] [3] [4] [5]) + Fehler [2]: Das Erstellen der SQL Zeichenfolge ist fehlgeschlagen, Fehlerbeschreibung: [3], SQL-Schlüssel: [4] SQL-Zeichenfolge: [5] + Die Datenbank [3] existiert bereits. Wollen Sie fortfahren? + + Konfiguriere SQL Server + Erstelle Datenbanken + Lösche Datenbanken + SQL-Zeichenfolgen werden erstellt + SQL-Zeichenfolgen werden zurückgesetzt + diff --git a/src/ext/Sql/wixlib/en-us.wxl b/src/ext/Sql/wixlib/en-us.wxl new file mode 100644 index 00000000..d3ffd5eb --- /dev/null +++ b/src/ext/Sql/wixlib/en-us.wxl @@ -0,0 +1,16 @@ + + + + + Error [2]: failed to create SQL database: [3], error detail: [4]. + Error [2]: failed to drop SQL database: [3], error detail: [4]. + Failed to connect to SQL database. ([2] [3] [4] [5]) + Error [2]: failed to execute SQL string, error detail: [3], SQL key: [4] SQL string: [5] + The database [3] already exists. Do you want to continue? + + Configuring SQL Server + Creating Databases + Dropping Databases + Executing SQL Strings + Rolling back SQL Strings + diff --git a/src/ext/Sql/wixlib/es-es.wxl b/src/ext/Sql/wixlib/es-es.wxl new file mode 100644 index 00000000..b2e5d499 --- /dev/null +++ b/src/ext/Sql/wixlib/es-es.wxl @@ -0,0 +1,17 @@ + + + + + Error [2]: falla al crear la base de datos SQL: [3], detalle del error: [4]. + Error [2]: falla al poner la base de datos SQL: [3], detalle del error: [4]. + Falla al conectarse con la base de datos SQL. ([2] [3] [4] [5]) + Error [2]: falla al ejecutar la cadena SQL, detalle del error: [3], Clave SQL: [4] Cadena SQL: [5] + La base de datos [3] ya existe. ¿Desea continuar? + + Configurando SQL Server + Creando Bases de Datos + Colocando Bases de Datos + Ejecutando cadenas SQL + Revirtiendo cadenas SQL + + diff --git a/src/ext/Sql/wixlib/ja-jp.wxl b/src/ext/Sql/wixlib/ja-jp.wxl new file mode 100644 index 00000000..6e35fd17 --- /dev/null +++ b/src/ext/Sql/wixlib/ja-jp.wxl @@ -0,0 +1,16 @@ + + + + + エラー [2]: SQL データベース [3] 作成に失敗しました、エラー詳細: [4]。 + エラー [2]: SQL データベース [3] の削除に失敗しました、エラー詳細: [4]。 + SQL データベースへ接続できませんでした。 ([2] [3] [4] [5]) + エラー [2]: SQL ストリングの実行に失敗しました、エラー詳細: [3]、 SQL キー: [4] SQL ストリング: [5] + データベース [3] は既に存在します。続行しますか? + + SQL サーバーを構成しています + データベースを作成しています + データベースを削除しています + SQL ストリングを実行しています + SQL ストリングをロールバックしています + diff --git a/src/ext/Sql/wixlib/pl-pl.wxl b/src/ext/Sql/wixlib/pl-pl.wxl new file mode 100644 index 00000000..6200e0e9 --- /dev/null +++ b/src/ext/Sql/wixlib/pl-pl.wxl @@ -0,0 +1,16 @@ + + + + + Błąd [2]: nie udało się utworzyć bazy danych: [3]. Szczegóły błędu: [4]. + Błąd [2]: nie udało się usunąć bazy danych: [3]. Szczegóły błędu: [4]. + Nie udało się połączyć z bazą danych. ([2] [3] [4] [5]) + Błąd [2]: nie udało się wykonać zapytania SQL. Szczegóły błędu: [3], klucz: [4] zapytanie SQL: [5] + Baza danych [3] już istnieje. Czy chcesz kontynuować? + + Konfigurowanie programu SQL Server + Tworzenie baz danych + Usuwanie baz danych + Wykonywanie zapytań SQL + Cofanie zapytań SQL + diff --git a/src/ext/Sql/wixlib/pt-br.wxl b/src/ext/Sql/wixlib/pt-br.wxl new file mode 100644 index 00000000..74c53313 --- /dev/null +++ b/src/ext/Sql/wixlib/pt-br.wxl @@ -0,0 +1,16 @@ + + + + + Error [2]: falha ao criar o Banco de Dados: [3], detalhes: [4]. + Error [2]: falha ao remover o Banco de Dados: [3], detalhes: [4]. + Falhou a ligação ao Banco de Dados. ([2] [3] [4] [5]) + Erro [2]: falha ao executar o comando de SQL, detalhes: [3], Comando: [4] Conteúdo: [5] + O Banco de Dados [3] já existe. Deseja continuar? + + Configurando o Servidor de SQL + Criando os Bancos de Dados + Removendo os Bancos de Dados + Executando comandos de SQL + Revertendo os comandos de SQL + diff --git a/src/ext/Sql/wixlib/pt-pt.wxl b/src/ext/Sql/wixlib/pt-pt.wxl new file mode 100644 index 00000000..90d9df4f --- /dev/null +++ b/src/ext/Sql/wixlib/pt-pt.wxl @@ -0,0 +1,16 @@ + + + + + Error [2]: falha ao criar a Base de Dados: [3], detalhes: [4]. + Error [2]: falha ao remover a Base de Dados: [3], detalhes: [4]. + Falhou a ligação à Base de Dados. ([2] [3] [4] [5]) + Erro [2]: falha ao executar o comando de SQL, detalhes: [3], Comando: [4] Conteúdo: [5] + A Base de Dados [3] já existe. Deseja continuar? + + Configurar o Servidor de SQL + Criar as Bases de Dados + Remover as Bases de Dados + Executar comandos de SQL + Reverter os comandos de SQL + diff --git a/src/ext/Sql/wixlib/sql.v3.ncrunchproject b/src/ext/Sql/wixlib/sql.v3.ncrunchproject new file mode 100644 index 00000000..319cd523 --- /dev/null +++ b/src/ext/Sql/wixlib/sql.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/src/ext/Sql/wixlib/sql.wixproj b/src/ext/Sql/wixlib/sql.wixproj new file mode 100644 index 00000000..ac994e6b --- /dev/null +++ b/src/ext/Sql/wixlib/sql.wixproj @@ -0,0 +1,24 @@ + + + + + Library + true + + + + + + + + + + + + + + + + + + diff --git a/src/ext/global.json b/src/ext/global.json new file mode 100644 index 00000000..23dd3fa6 --- /dev/null +++ b/src/ext/global.json @@ -0,0 +1,5 @@ +{ + "msbuild-sdks": { + "WixToolset.Sdk": "4.0.0-build-0211" + } +} diff --git a/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs b/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs deleted file mode 100644 index aa9d7a1f..00000000 --- a/src/test/WixToolsetTest.Sql/SqlExtensionFixture.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolsetTest.Sql -{ - using System.Linq; - using WixBuildTools.TestSupport; - using WixToolset.Core.TestPackage; - using WixToolset.Sql; - using Xunit; - - public class SqlExtensionFixture - { - [Fact] - public void CanBuildUsingSqlStuff() - { - var folder = TestData.Get(@"TestData\UsingSql"); - var build = new Builder(folder, typeof(SqlExtensionFactory), new[] { folder }); - - var results = build.BuildAndQuery(Build, "Wix4SqlDatabase", "Wix4SqlFileSpec", "Wix4SqlScript", "Wix4SqlString"); - WixAssert.CompareLineByLine(new[] - { - "Wix4SqlDatabase:TestDB\tMySQLHostName\tMyInstanceName\tMyDB\tDatabaseComponent\t\tTestFileSpecId\tTestLogFileSpecId\t35", - "Wix4SqlFileSpec:TestFileSpecId\tTestFileSpecLogicalName\tTestFileSpec\t10MB\t100MB\t10%", - "Wix4SqlFileSpec:TestLogFileSpecId\tTestLogFileSpecLogicalName\tTestLogFileSpec\t1MB\t10MB\t1%", - "Wix4SqlScript:TestScript\tTestDB\tDatabaseComponent\tScriptBinary\t\t1\t", - "Wix4SqlString:TestString\tTestDB\tDatabaseComponent\tCREATE TABLE TestTable1(name varchar(20), value varchar(20))\t\t1\t", - }, results.ToArray()); - } - - private static void Build(string[] args) - { - var result = WixRunner.Execute(args) - .AssertSuccess(); - } - } -} diff --git a/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.en-us.wxl b/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.en-us.wxl deleted file mode 100644 index 38c12ac1..00000000 --- a/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.en-us.wxl +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - A newer version of [ProductName] is already installed. - MsiPackage - - diff --git a/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs b/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs deleted file mode 100644 index ee3bc921..00000000 --- a/src/test/WixToolsetTest.Sql/TestData/UsingSql/Package.wxs +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs b/src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs deleted file mode 100644 index f7626926..00000000 --- a/src/test/WixToolsetTest.Sql/TestData/UsingSql/PackageComponents.wxs +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/src/test/WixToolsetTest.Sql/TestData/UsingSql/example.txt b/src/test/WixToolsetTest.Sql/TestData/UsingSql/example.txt deleted file mode 100644 index 1b4ffe8a..00000000 --- a/src/test/WixToolsetTest.Sql/TestData/UsingSql/example.txt +++ /dev/null @@ -1 +0,0 @@ -This is example.txt. \ No newline at end of file diff --git a/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj b/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj deleted file mode 100644 index bbf3041d..00000000 --- a/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.csproj +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - netcoreapp3.1 - false - - - - NU1701 - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.v3.ncrunchproject b/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.v3.ncrunchproject deleted file mode 100644 index 7b5b2139..00000000 --- a/src/test/WixToolsetTest.Sql/WixToolsetTest.Sql.v3.ncrunchproject +++ /dev/null @@ -1,5 +0,0 @@ - - - True - - \ No newline at end of file diff --git a/src/version.json b/src/version.json new file mode 100644 index 00000000..5f857771 --- /dev/null +++ b/src/version.json @@ -0,0 +1,11 @@ +{ + "version": "4.0", + "publicReleaseRefSpec": [ + "^refs/heads/master$" + ], + "cloudBuild": { + "buildNumber": { + "enabled": true + } + } +} diff --git a/src/wix.snk b/src/wix.snk deleted file mode 100644 index 3908a66a..00000000 Binary files a/src/wix.snk and /dev/null differ diff --git a/src/wixext/SqlCompiler.cs b/src/wixext/SqlCompiler.cs deleted file mode 100644 index 46196e95..00000000 --- a/src/wixext/SqlCompiler.cs +++ /dev/null @@ -1,804 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Sql -{ - using System; - using System.Collections.Generic; - using System.Xml.Linq; - using WixToolset.Data; - using WixToolset.Extensibility; - using WixToolset.Extensibility.Data; - using WixToolset.Sql.Symbols; - - /// - /// The compiler for the WiX Toolset SQL Server Extension. - /// - public sealed class SqlCompiler : BaseCompilerExtension - { - // sql database attributes definitions (from sca.h) - internal const int DbCreateOnInstall = 0x00000001; - internal const int DbDropOnUninstall = 0x00000002; - internal const int DbContinueOnError = 0x00000004; - internal const int DbDropOnInstall = 0x00000008; - internal const int DbCreateOnUninstall = 0x00000010; - internal const int DbConfirmOverwrite = 0x00000020; - internal const int DbCreateOnReinstall = 0x00000040; - internal const int DbDropOnReinstall = 0x00000080; - - // sql string/script attributes definitions (from sca.h) - internal const int SqlExecuteOnInstall = 0x00000001; - internal const int SqlExecuteOnUninstall = 0x00000002; - internal const int SqlContinueOnError = 0x00000004; - internal const int SqlRollback = 0x00000008; - internal const int SqlExecuteOnReinstall = 0x00000010; - - public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/sql"; - - /// - /// Processes an element for the Compiler. - /// - /// - /// - /// Parent element of element to process. - /// Element to process. - /// Extra information about the context in which this element is being parsed. - public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary context) - { - switch (parentElement.Name.LocalName) - { - case "Component": - var componentId = context["ComponentId"]; - - switch (element.Name.LocalName) - { - case "SqlDatabase": - this.ParseSqlDatabaseElement(intermediate, section, element, componentId); - break; - case "SqlScript": - this.ParseSqlScriptElement(intermediate, section, element, componentId, null); - break; - case "SqlString": - this.ParseSqlStringElement(intermediate, section, element, componentId, null); - break; - default: - this.ParseHelper.UnexpectedElement(parentElement, element); - break; - } - break; - case "Fragment": - case "Module": - case "Package": - switch (element.Name.LocalName) - { - case "SqlDatabase": - this.ParseSqlDatabaseElement(intermediate, section, element, null); - break; - default: - this.ParseHelper.UnexpectedElement(parentElement, element); - break; - } - break; - default: - this.ParseHelper.UnexpectedElement(parentElement, element); - break; - } - } - - /// - /// Parses a sql database element - /// - /// - /// - /// Element to parse. - /// Identifier for parent component. - private void ParseSqlDatabaseElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId) - { - var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); - Identifier id = null; - int attributes = 0; - string database = null; - Identifier fileSpec = null; - string instance = null; - Identifier logFileSpec = null; - string server = null; - string user = null; - - foreach (var attrib in element.Attributes()) - { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) - { - switch (attrib.Name.LocalName) - { - case "Id": - id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "ConfirmOverwrite": - if (null == componentId) - { - this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); - } - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= DbConfirmOverwrite; - } - break; - case "ContinueOnError": - if (null == componentId) - { - this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); - } - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= DbContinueOnError; - } - break; - case "CreateOnInstall": - if (null == componentId) - { - this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); - } - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= DbCreateOnInstall; - } - break; - case "CreateOnReinstall": - if (null == componentId) - { - this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); - } - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= DbCreateOnReinstall; - } - break; - case "CreateOnUninstall": - if (null == componentId) - { - this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); - } - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= DbCreateOnUninstall; - } - break; - case "Database": - database = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "DropOnInstall": - if (null == componentId) - { - this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); - } - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= DbDropOnInstall; - } - break; - case "DropOnReinstall": - if (null == componentId) - { - this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); - } - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= DbDropOnReinstall; - } - break; - - case "DropOnUninstall": - if (null == componentId) - { - this.Messaging.Write(SqlErrors.IllegalAttributeWithoutComponent(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName)); - } - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= DbDropOnUninstall; - } - break; - case "Instance": - instance = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Server": - server = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "User": - user = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - if (!this.ParseHelper.ContainsProperty(user)) - { - user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "User", user); - } - break; - default: - this.ParseHelper.UnexpectedAttribute(element, attrib); - break; - } - } - else - { - this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); - } - } - - if (null == id) - { - id = this.ParseHelper.CreateIdentifier("sdb", componentId, server, database); - } - - if (null == database) - { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Database")); - } - else if (128 < database.Length) - { - this.Messaging.Write(ErrorMessages.IdentifierTooLongError(sourceLineNumbers, element.Name.LocalName, "Database", database, 128)); - } - - if (null == server) - { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Server")); - } - - if (0 == attributes && null != componentId) - { - this.Messaging.Write(SqlErrors.OneOfAttributesRequiredUnderComponent(sourceLineNumbers, element.Name.LocalName, "CreateOnInstall", "CreateOnUninstall", "DropOnInstall", "DropOnUninstall")); - } - - foreach (var child in element.Elements()) - { - if (this.Namespace == child.Name.Namespace) - { - var childSourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(child); - switch (child.Name.LocalName) - { - case "SqlScript": - if (null == componentId) - { - this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); - } - - this.ParseSqlScriptElement(intermediate, section, child, componentId, id?.Id); - break; - case "SqlString": - if (null == componentId) - { - this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); - } - - this.ParseSqlStringElement(intermediate, section, child, componentId, id?.Id); - break; - case "SqlFileSpec": - if (null == componentId) - { - this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); - } - else if (null != fileSpec) - { - this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, element.Name.LocalName, child.Name.LocalName, 1)); - } - - fileSpec = this.ParseSqlFileSpecElement(intermediate, section, child, id?.Id); - break; - case "SqlLogFileSpec": - if (null == componentId) - { - this.Messaging.Write(SqlErrors.IllegalElementWithoutComponent(childSourceLineNumbers, child.Name.LocalName)); - } - else if (null != logFileSpec) - { - this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, element.Name.LocalName, child.Name.LocalName, 1)); - } - - logFileSpec = this.ParseSqlFileSpecElement(intermediate, section, child, id?.Id); - break; - default: - this.ParseHelper.UnexpectedElement(element, child); - break; - } - } - else - { - this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, element, child); - } - } - - if (null != componentId) - { - // Reference InstallSqlData and UninstallSqlData since nothing will happen without it - this.AddReferenceToInstallSqlData(section, sourceLineNumbers); - } - - if (!this.Messaging.EncounteredError) - { - var symbol = section.AddSymbol(new SqlDatabaseSymbol(sourceLineNumbers, id) - { - Server = server, - Instance = instance, - Database = database, - ComponentRef = componentId, - UserRef = user, - FileSpecRef = fileSpec?.Id, - LogFileSpecRef = logFileSpec?.Id, - }); - - if (0 != attributes) - { - symbol.Attributes = attributes; - } - } - } - - /// - /// Parses a sql file specification element. - /// - /// - /// - /// Element to parse. - /// Identifier of sql file specification. - private Identifier ParseSqlFileSpecElement(Intermediate intermediate, IntermediateSection section, XElement element, string parentId) - { - var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); - Identifier id = null; - string fileName = null; - string growthSize = null; - string maxSize = null; - string name = null; - string size = null; - - foreach (var attrib in element.Attributes()) - { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) - { - switch (attrib.Name.LocalName) - { - case "Id": - id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Name": - name = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Filename": - fileName = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Size": - size = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "MaxSize": - maxSize = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "GrowthSize": - growthSize = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.ParseHelper.UnexpectedAttribute(element, attrib); - break; - } - } - else - { - this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); - } - } - - if (null == id) - { - id = this.ParseHelper.CreateIdentifier("sfs", parentId, name, fileName); - } - - if (null == name) - { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Name")); - } - - if (null == fileName) - { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Filename")); - } - - this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); - - if (!this.Messaging.EncounteredError) - { - var symbol = section.AddSymbol(new SqlFileSpecSymbol(sourceLineNumbers, id) - { - Name = name, - Filename = fileName, - }); - - if (null != size) - { - symbol.Size = size; - } - - if (null != maxSize) - { - symbol.MaxSize = maxSize; - } - - if (null != growthSize) - { - symbol.GrowthSize = growthSize; - } - } - - return id; - } - - /// - /// Parses a sql script element. - /// - /// Element to parse. - /// Identifier for parent component. - /// Optional database to execute script against. - private void ParseSqlScriptElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string sqlDb) - { - var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); - Identifier id = null; - int attributes = 0; - var rollbackAttribute = false; - var nonRollbackAttribute = false; - string binaryRef = null; - var sequence = CompilerConstants.IntegerNotSet; - string user = null; - - foreach (var attrib in element.Attributes()) - { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) - { - switch (attrib.Name.LocalName) - { - case "Id": - id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "BinaryRef": - binaryRef = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.Binary, binaryRef); - break; - case "Sequence": - sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); - break; - case "SqlDb": - if (null != sqlDb) - { - this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, element.Parent.Name.LocalName)); - } - sqlDb = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SqlSymbolDefinitions.SqlDatabase, sqlDb); - break; - case "User": - user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "User", user); - break; - - // Flag-setting attributes - case "ContinueOnError": - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= SqlContinueOnError; - } - break; - case "ExecuteOnInstall": - if (rollbackAttribute) - { - this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); - } - nonRollbackAttribute = true; - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= SqlExecuteOnInstall; - } - break; - case "ExecuteOnReinstall": - if (rollbackAttribute) - { - this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); - } - nonRollbackAttribute = true; - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= SqlExecuteOnReinstall; - } - break; - case "ExecuteOnUninstall": - if (rollbackAttribute) - { - this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); - } - nonRollbackAttribute = true; - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= SqlExecuteOnUninstall; - } - break; - case "RollbackOnInstall": - if (nonRollbackAttribute) - { - this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); - } - rollbackAttribute = true; - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= SqlExecuteOnInstall; - attributes |= SqlRollback; - } - break; - case "RollbackOnReinstall": - if (nonRollbackAttribute) - { - this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); - } - rollbackAttribute = true; - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= SqlExecuteOnReinstall; - attributes |= SqlRollback; - } - break; - case "RollbackOnUninstall": - if (nonRollbackAttribute) - { - this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); - } - rollbackAttribute = true; - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= SqlExecuteOnUninstall; - attributes |= SqlRollback; - } - break; - default: - this.ParseHelper.UnexpectedAttribute(element, attrib); - break; - } - } - else - { - this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); - } - } - - if (null == id) - { - id = this.ParseHelper.CreateIdentifier("ssc", componentId, binaryRef, sqlDb); - } - - if (null == binaryRef) - { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "BinaryRef")); - } - - if (null == sqlDb) - { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "SqlDb")); - } - - if (0 == attributes) - { - this.Messaging.Write(ErrorMessages.ExpectedAttributes(sourceLineNumbers, element.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall", "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); - } - - this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); - - // Reference InstallSqlData and UninstallSqlData since nothing will happen without it - this.AddReferenceToInstallSqlData(section, sourceLineNumbers); - - if (!this.Messaging.EncounteredError) - { - var symbol = section.AddSymbol(new SqlScriptSymbol(sourceLineNumbers, id) - { - SqlDbRef = sqlDb, - ComponentRef = componentId, - ScriptBinaryRef = binaryRef, - UserRef = user, - Attributes = attributes, - }); - - if (CompilerConstants.IntegerNotSet != sequence) - { - symbol.Sequence = sequence; - } - } - } - - /// - /// Parses a sql string element. - /// - /// Element to parse. - /// Identifier for parent component. - /// Optional database to execute string against. - private void ParseSqlStringElement(Intermediate intermediate, IntermediateSection section, XElement element, string componentId, string sqlDb) - { - var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); - Identifier id = null; - int attributes = 0; - var rollbackAttribute = false; - var nonRollbackAttribute = false; - var sequence = CompilerConstants.IntegerNotSet; - string sql = null; - string user = null; - - foreach (var attrib in element.Attributes()) - { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) - { - switch (attrib.Name.LocalName) - { - case "Id": - id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "ContinueOnError": - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= SqlContinueOnError; - } - break; - case "ExecuteOnInstall": - if (rollbackAttribute) - { - this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); - } - nonRollbackAttribute = true; - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= SqlExecuteOnInstall; - } - break; - case "ExecuteOnReinstall": - if (rollbackAttribute) - { - this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); - } - nonRollbackAttribute = true; - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= SqlExecuteOnReinstall; - } - break; - case "ExecuteOnUninstall": - if (rollbackAttribute) - { - this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); - } - nonRollbackAttribute = true; - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= SqlExecuteOnUninstall; - } - break; - case "RollbackOnInstall": - if (nonRollbackAttribute) - { - this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); - } - rollbackAttribute = true; - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= SqlExecuteOnInstall; - attributes |= SqlRollback; - } - break; - case "RollbackOnReinstall": - if (nonRollbackAttribute) - { - this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); - } - rollbackAttribute = true; - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= SqlExecuteOnReinstall; - attributes |= SqlRollback; - } - break; - case "RollbackOnUninstall": - if (nonRollbackAttribute) - { - this.Messaging.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, element.Name.LocalName, attrib.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall")); - } - rollbackAttribute = true; - - if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= SqlExecuteOnUninstall; - attributes |= SqlRollback; - } - break; - case "Sequence": - sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); - break; - case "SQL": - sql = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "SqlDb": - if (null != sqlDb) - { - this.Messaging.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, element.Name.LocalName, "SqlDb", "SqlDatabase")); - } - - sqlDb = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SqlSymbolDefinitions.SqlDatabase, sqlDb); - break; - case "User": - user = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "User", user); - break; - default: - this.ParseHelper.UnexpectedAttribute(element, attrib); - break; - } - } - else - { - this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, element, attrib); - } - } - - if (null == id) - { - id = this.ParseHelper.CreateIdentifier("sst", componentId, sql, sqlDb); - } - - if (null == sql) - { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "SQL")); - } - - if (null == sqlDb) - { - this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "SqlDb")); - } - - if (0 == attributes) - { - this.Messaging.Write(ErrorMessages.ExpectedAttributes(sourceLineNumbers, element.Name.LocalName, "ExecuteOnInstall", "ExecuteOnReinstall", "ExecuteOnUninstall", "RollbackOnInstall", "RollbackOnReinstall", "RollbackOnUninstall")); - } - - this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); - - // Reference InstallSqlData and UninstallSqlData since nothing will happen without it - this.AddReferenceToInstallSqlData(section, sourceLineNumbers); - - if (!this.Messaging.EncounteredError) - { - var symbol = section.AddSymbol(new SqlStringSymbol(sourceLineNumbers, id) - { - SqlDbRef = sqlDb, - ComponentRef = componentId, - SQL = sql, - UserRef = user, - Attributes = attributes, - }); - - if (CompilerConstants.IntegerNotSet != sequence) - { - symbol.Sequence = sequence; - } - } - } - - private void AddReferenceToInstallSqlData(IntermediateSection section, SourceLineNumber sourceLineNumbers) - { - this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4InstallSqlData", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); - this.ParseHelper.CreateCustomActionReference(sourceLineNumbers, section, "Wix4UninstallSqlData", this.Context.Platform, CustomActionPlatforms.X86 | CustomActionPlatforms.X64 | CustomActionPlatforms.ARM64); - } - } -} diff --git a/src/wixext/SqlDecompiler.cs b/src/wixext/SqlDecompiler.cs deleted file mode 100644 index 52436b87..00000000 --- a/src/wixext/SqlDecompiler.cs +++ /dev/null @@ -1,514 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Sql -{ -#if TODO_CONSIDER_DECOMPILER - using System.Collections; - using WixToolset.Data; - using WixToolset.Extensibility; - using Sql = WixToolset.Extensions.Serialize.Sql; - using Wix = WixToolset.Data.Serialize; - - /// - /// The decompiler for the WiX Toolset SQL Server Extension. - /// - public sealed class SqlDecompiler : DecompilerExtension - { - /// - /// Creates a decompiler for SQL Extension. - /// - public SqlDecompiler() - { - this.TableDefinitions = SqlExtensionData.GetExtensionTableDefinitions(); - } - - /// - /// Get the extensions library to be removed. - /// - /// Table definitions for library. - /// Library to remove from decompiled output. - public override Library GetLibraryToRemove(TableDefinitionCollection tableDefinitions) - { - return SqlExtensionData.GetExtensionLibrary(tableDefinitions); - } - - /// - /// Decompiles an extension table. - /// - /// The table to decompile. - public override void DecompileTable(Table table) - { - switch (table.Name) - { - case "SqlDatabase": - this.DecompileSqlDatabaseTable(table); - break; - case "SqlFileSpec": - // handled in FinalizeSqlFileSpecTable - break; - case "SqlScript": - this.DecompileSqlScriptTable(table); - break; - case "SqlString": - this.DecompileSqlStringTable(table); - break; - default: - base.DecompileTable(table); - break; - } - } - - /// - /// Finalize decompilation. - /// - /// The collection of all tables. - public override void Finish(TableIndexedCollection tables) - { - this.FinalizeSqlFileSpecTable(tables); - this.FinalizeSqlScriptAndSqlStringTables(tables); - } - - /// - /// Decompile the SqlDatabase table. - /// - /// The table to decompile. - private void DecompileSqlDatabaseTable(Table table) - { - foreach (Row row in table.Rows) - { - Sql.SqlDatabase sqlDatabase = new Sql.SqlDatabase(); - - sqlDatabase.Id = (string)row[0]; - - if (null != row[1]) - { - sqlDatabase.Server = (string)row[1]; - } - - if (null != row[2]) - { - sqlDatabase.Instance = (string)row[2]; - } - - sqlDatabase.Database = (string)row[3]; - - if (null != row[5]) - { - sqlDatabase.User = (string)row[5]; - } - - // the FileSpec_ and FileSpec_Log columns will be handled in FinalizeSqlFileSpecTable - - if (null != row[8]) - { - int attributes = (int)row[8]; - - if (SqlCompiler.DbCreateOnInstall == (attributes & SqlCompiler.DbCreateOnInstall)) - { - sqlDatabase.CreateOnInstall = Sql.YesNoType.yes; - } - - if (SqlCompiler.DbDropOnUninstall == (attributes & SqlCompiler.DbDropOnUninstall)) - { - sqlDatabase.DropOnUninstall = Sql.YesNoType.yes; - } - - if (SqlCompiler.DbContinueOnError == (attributes & SqlCompiler.DbContinueOnError)) - { - sqlDatabase.ContinueOnError = Sql.YesNoType.yes; - } - - if (SqlCompiler.DbDropOnInstall == (attributes & SqlCompiler.DbDropOnInstall)) - { - sqlDatabase.DropOnInstall = Sql.YesNoType.yes; - } - - if (SqlCompiler.DbCreateOnUninstall == (attributes & SqlCompiler.DbCreateOnUninstall)) - { - sqlDatabase.CreateOnUninstall = Sql.YesNoType.yes; - } - - if (SqlCompiler.DbConfirmOverwrite == (attributes & SqlCompiler.DbConfirmOverwrite)) - { - sqlDatabase.ConfirmOverwrite = Sql.YesNoType.yes; - } - - if (SqlCompiler.DbCreateOnReinstall == (attributes & SqlCompiler.DbCreateOnReinstall)) - { - sqlDatabase.CreateOnReinstall = Sql.YesNoType.yes; - } - - if (SqlCompiler.DbDropOnReinstall == (attributes & SqlCompiler.DbDropOnReinstall)) - { - sqlDatabase.DropOnReinstall = Sql.YesNoType.yes; - } - } - - if (null != row[4]) - { - Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[4]); - - if (null != component) - { - component.AddChild(sqlDatabase); - } - else - { - this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, table.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[4], "Component")); - } - } - else - { - this.Core.RootElement.AddChild(sqlDatabase); - } - this.Core.IndexElement(row, sqlDatabase); - } - } - - /// - /// Decompile the SqlScript table. - /// - /// The table to decompile. - private void DecompileSqlScriptTable(Table table) - { - foreach (Row row in table.Rows) - { - Sql.SqlScript sqlScript = new Sql.SqlScript(); - - sqlScript.Id = (string)row[0]; - - // the Db_ and Component_ columns are handled in FinalizeSqlScriptAndSqlStringTables - - sqlScript.BinaryKey = (string)row[3]; - - if (null != row[4]) - { - sqlScript.User = (string)row[4]; - } - - int attributes = (int)row[5]; - - if (SqlCompiler.SqlContinueOnError == (attributes & SqlCompiler.SqlContinueOnError)) - { - sqlScript.ContinueOnError = Sql.YesNoType.yes; - } - - if (SqlCompiler.SqlExecuteOnInstall == (attributes & SqlCompiler.SqlExecuteOnInstall)) - { - sqlScript.ExecuteOnInstall = Sql.YesNoType.yes; - } - - if (SqlCompiler.SqlExecuteOnReinstall == (attributes & SqlCompiler.SqlExecuteOnReinstall)) - { - sqlScript.ExecuteOnReinstall = Sql.YesNoType.yes; - } - - if (SqlCompiler.SqlExecuteOnUninstall == (attributes & SqlCompiler.SqlExecuteOnUninstall)) - { - sqlScript.ExecuteOnUninstall = Sql.YesNoType.yes; - } - - if ((SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnInstall) == (attributes & (SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnInstall))) - { - sqlScript.RollbackOnInstall = Sql.YesNoType.yes; - } - - if ((SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnReinstall) == (attributes & (SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnReinstall))) - { - sqlScript.RollbackOnReinstall = Sql.YesNoType.yes; - } - - if ((SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnUninstall) == (attributes & (SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnUninstall))) - { - sqlScript.RollbackOnUninstall = Sql.YesNoType.yes; - } - - if (null != row[6]) - { - sqlScript.Sequence = (int)row[6]; - } - - this.Core.IndexElement(row, sqlScript); - } - } - - /// - /// Decompile the SqlString table. - /// - /// The table to decompile. - private void DecompileSqlStringTable(Table table) - { - foreach (Row row in table.Rows) - { - Sql.SqlString sqlString = new Sql.SqlString(); - - sqlString.Id = (string)row[0]; - - // the Db_ and Component_ columns are handled in FinalizeSqlScriptAndSqlStringTables - - sqlString.SQL = (string)row[3]; - - if (null != row[4]) - { - sqlString.User = (string)row[4]; - } - - int attributes = (int)row[5]; - - if (SqlCompiler.SqlContinueOnError == (attributes & SqlCompiler.SqlContinueOnError)) - { - sqlString.ContinueOnError = Sql.YesNoType.yes; - } - - if (SqlCompiler.SqlExecuteOnInstall == (attributes & SqlCompiler.SqlExecuteOnInstall)) - { - sqlString.ExecuteOnInstall = Sql.YesNoType.yes; - } - - if (SqlCompiler.SqlExecuteOnReinstall == (attributes & SqlCompiler.SqlExecuteOnReinstall)) - { - sqlString.ExecuteOnReinstall = Sql.YesNoType.yes; - } - - if (SqlCompiler.SqlExecuteOnUninstall == (attributes & SqlCompiler.SqlExecuteOnUninstall)) - { - sqlString.ExecuteOnUninstall = Sql.YesNoType.yes; - } - - if ((SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnInstall) == (attributes & (SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnInstall))) - { - sqlString.RollbackOnInstall = Sql.YesNoType.yes; - } - - if ((SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnReinstall) == (attributes & (SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnReinstall))) - { - sqlString.RollbackOnReinstall = Sql.YesNoType.yes; - } - - if ((SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnUninstall) == (attributes & (SqlCompiler.SqlRollback | SqlCompiler.SqlExecuteOnUninstall))) - { - sqlString.RollbackOnUninstall = Sql.YesNoType.yes; - } - - if (null != row[6]) - { - sqlString.Sequence = (int)row[6]; - } - - this.Core.IndexElement(row, sqlString); - } - } - - /// - /// Finalize the SqlFileSpec table. - /// - /// The collection of all tables. - /// - /// Since rows of the SqlFileSpec table are represented by either - /// the SqlFileSpec or SqlLogFileSpec depending upon the context in - /// which they are used in the SqlDatabase table, decompilation of this - /// table must occur after the SqlDatbase parents are decompiled. - /// - private void FinalizeSqlFileSpecTable(TableIndexedCollection tables) - { - Table sqlDatabaseTable = tables["SqlDatabase"]; - Table sqlFileSpecTable = tables["SqlFileSpec"]; - - if (null != sqlDatabaseTable && null != sqlFileSpecTable) - { - Hashtable sqlFileSpecRows = new Hashtable(); - - // index each SqlFileSpec row by its primary key - foreach (Row row in sqlFileSpecTable.Rows) - { - sqlFileSpecRows.Add(row[0], row); - } - - // create the necessary SqlFileSpec and SqlLogFileSpec elements for each row - foreach (Row row in sqlDatabaseTable.Rows) - { - Sql.SqlDatabase sqlDatabase = (Sql.SqlDatabase)this.Core.GetIndexedElement(row); - - if (null != row[6]) - { - Row sqlFileSpecRow = (Row)sqlFileSpecRows[row[6]]; - - if (null != sqlFileSpecRow) - { - Sql.SqlFileSpec sqlFileSpec = new Sql.SqlFileSpec(); - - sqlFileSpec.Id = (string)sqlFileSpecRow[0]; - - if (null != sqlFileSpecRow[1]) - { - sqlFileSpec.Name = (string)sqlFileSpecRow[1]; - } - - sqlFileSpec.Filename = (string)sqlFileSpecRow[2]; - - if (null != sqlFileSpecRow[3]) - { - sqlFileSpec.Size = (string)sqlFileSpecRow[3]; - } - - if (null != sqlFileSpecRow[4]) - { - sqlFileSpec.MaxSize = (string)sqlFileSpecRow[4]; - } - - if (null != sqlFileSpecRow[5]) - { - sqlFileSpec.GrowthSize = (string)sqlFileSpecRow[5]; - } - - sqlDatabase.AddChild(sqlFileSpec); - } - else - { - this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, sqlDatabaseTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "FileSpec_", (string)row[6], "SqlFileSpec")); - } - } - - if (null != row[7]) - { - Row sqlFileSpecRow = (Row)sqlFileSpecRows[row[7]]; - - if (null != sqlFileSpecRow) - { - Sql.SqlLogFileSpec sqlLogFileSpec = new Sql.SqlLogFileSpec(); - - sqlLogFileSpec.Id = (string)sqlFileSpecRow[0]; - - if (null != sqlFileSpecRow[1]) - { - sqlLogFileSpec.Name = (string)sqlFileSpecRow[1]; - } - - sqlLogFileSpec.Filename = (string)sqlFileSpecRow[2]; - - if (null != sqlFileSpecRow[3]) - { - sqlLogFileSpec.Size = (string)sqlFileSpecRow[3]; - } - - if (null != sqlFileSpecRow[4]) - { - sqlLogFileSpec.MaxSize = (string)sqlFileSpecRow[4]; - } - - if (null != sqlFileSpecRow[5]) - { - sqlLogFileSpec.GrowthSize = (string)sqlFileSpecRow[5]; - } - - sqlDatabase.AddChild(sqlLogFileSpec); - } - else - { - this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, sqlDatabaseTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "FileSpec_Log", (string)row[7], "SqlFileSpec")); - } - } - } - } - } - - /// - /// Finalize the SqlScript table. - /// - /// The collection of all tables. - /// - /// The SqlScript and SqlString tables contain a foreign key into the SqlDatabase - /// and Component tables. Depending upon the parent of the SqlDatabase - /// element, the SqlScript and SqlString elements are nested under either the - /// SqlDatabase or the Component element. - /// - private void FinalizeSqlScriptAndSqlStringTables(TableIndexedCollection tables) - { - Table sqlDatabaseTable = tables["SqlDatabase"]; - Table sqlScriptTable = tables["SqlScript"]; - Table sqlStringTable = tables["SqlString"]; - - Hashtable sqlDatabaseRows = new Hashtable(); - - // index each SqlDatabase row by its primary key - if (null != sqlDatabaseTable) - { - foreach (Row row in sqlDatabaseTable.Rows) - { - sqlDatabaseRows.Add(row[0], row); - } - } - - if (null != sqlScriptTable) - { - foreach (Row row in sqlScriptTable.Rows) - { - Sql.SqlScript sqlScript = (Sql.SqlScript)this.Core.GetIndexedElement(row); - - Row sqlDatabaseRow = (Row)sqlDatabaseRows[row[1]]; - string databaseComponent = (string)sqlDatabaseRow[4]; - - // determine if the SqlScript element should be nested under the database or another component - if (null != databaseComponent && databaseComponent == (string)row[2]) - { - Sql.SqlDatabase sqlDatabase = (Sql.SqlDatabase)this.Core.GetIndexedElement(sqlDatabaseRow); - - sqlDatabase.AddChild(sqlScript); - } - else // nest under the component of the SqlDatabase row - { - Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[2]); - - // set the Database value - sqlScript.SqlDb = (string)row[1]; - - if (null != component) - { - component.AddChild(sqlScript); - } - else - { - this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, sqlScriptTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[2], "Component")); - } - } - } - } - - if (null != sqlStringTable) - { - foreach (Row row in sqlStringTable.Rows) - { - Sql.SqlString sqlString = (Sql.SqlString)this.Core.GetIndexedElement(row); - - Row sqlDatabaseRow = (Row)sqlDatabaseRows[row[1]]; - string databaseComponent = (string)sqlDatabaseRow[4]; - - // determine if the SqlScript element should be nested under the database or another component - if (null != databaseComponent && databaseComponent == (string)row[2]) - { - Sql.SqlDatabase sqlDatabase = (Sql.SqlDatabase)this.Core.GetIndexedElement(sqlDatabaseRow); - - sqlDatabase.AddChild(sqlString); - } - else // nest under the component of the SqlDatabase row - { - Wix.Component component = (Wix.Component)this.Core.GetIndexedElement("Component", (string)row[2]); - - // set the Database value - sqlString.SqlDb = (string)row[1]; - - if (null != component) - { - component.AddChild(sqlString); - } - else - { - this.Core.OnMessage(WixWarnings.ExpectedForeignRow(row.SourceLineNumbers, sqlStringTable.Name, row.GetPrimaryKey(DecompilerConstants.PrimaryKeyDelimiter), "Component_", (string)row[2], "Component")); - } - } - } - } - } - } -#endif -} diff --git a/src/wixext/SqlErrors.cs b/src/wixext/SqlErrors.cs deleted file mode 100644 index f25728bd..00000000 --- a/src/wixext/SqlErrors.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Sql -{ - using System.Resources; - using WixToolset.Data; - - public static class SqlErrors - { - public static Message IllegalAttributeWithoutComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName) - { - return Message(sourceLineNumbers, Ids.IllegalAttributeWithoutComponent, "The {0}/@{1} attribute cannot be specified unless the element has a Component as an ancestor. A {0} that does not have a Component ancestor is not installed.", elementName, attributeName); - } - - public static Message IllegalElementWithoutComponent(SourceLineNumber sourceLineNumbers, string elementName) - { - return Message(sourceLineNumbers, Ids.IllegalElementWithoutComponent, "The {0} element cannot be specified unless the element has a Component as an ancestor. A {0} that does not have a Component ancestor is not installed.", elementName); - } - - public static Message OneOfAttributesRequiredUnderComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName1, string attributeName2, string attributeName3, string attributeName4) - { - return Message(sourceLineNumbers, Ids.OneOfAttributesRequiredUnderComponent, "When nested under a Component, the {0} element must have one of the following attributes specified: {1}, {2}, {3} or {4}.", elementName, attributeName1, attributeName2, attributeName3, attributeName4); - } - - public static Message DeprecatedBinaryChildElement(SourceLineNumber sourceLineNumbers, string elementName) - { - return Message(sourceLineNumbers, Ids.DeprecatedBinaryChildElement, "The {0} element contains a deprecated child Binary element. Please move the Binary element under a Fragment, Module, or Product element and set the {0}/@BinaryKey attribute to the value of the Binary/@Id attribute.", elementName); - } - - private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) - { - return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); - } - - private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args) - { - return new Message(sourceLineNumber, MessageLevel.Error, (int)id, resourceManager, resourceName, args); - } - - public enum Ids - { - IllegalAttributeWithoutComponent = 5100, - IllegalElementWithoutComponent = 5101, - OneOfAttributesRequiredUnderComponent = 5102, - DeprecatedBinaryChildElement = 5103, - } - } -} \ No newline at end of file diff --git a/src/wixext/SqlExtensionData.cs b/src/wixext/SqlExtensionData.cs deleted file mode 100644 index 60de94fe..00000000 --- a/src/wixext/SqlExtensionData.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Sql -{ - using WixToolset.Data; - using WixToolset.Extensibility; - - /// - /// The WiX Toolset SQL Server Extension. - /// - public sealed class SqlExtensionData : BaseExtensionData - { - /// - /// Gets the default culture. - /// - /// The default culture. - public override string DefaultCulture => "en-US"; - - public override bool TryGetSymbolDefinitionByName(string name, out IntermediateSymbolDefinition symbolDefinition) - { - symbolDefinition = SqlSymbolDefinitions.ByName(name); - return symbolDefinition != null; - } - - public override Intermediate GetLibrary(ISymbolDefinitionCreator symbolDefinitions) - { - return Intermediate.Load(typeof(SqlExtensionData).Assembly, "WixToolset.Sql.sql.wixlib", symbolDefinitions); - } - } -} diff --git a/src/wixext/SqlExtensionFactory.cs b/src/wixext/SqlExtensionFactory.cs deleted file mode 100644 index 279106d3..00000000 --- a/src/wixext/SqlExtensionFactory.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Sql -{ - using System; - using System.Collections.Generic; - using WixToolset.Extensibility; - - public class SqlExtensionFactory : BaseExtensionFactory - { - protected override IReadOnlyCollection ExtensionTypes => new[] - { - typeof(SqlCompiler), - typeof(SqlExtensionData), - typeof(SqlWindowsInstallerBackendBinderExtension), - }; - } -} diff --git a/src/wixext/SqlTableDefinitions.cs b/src/wixext/SqlTableDefinitions.cs deleted file mode 100644 index 029a092e..00000000 --- a/src/wixext/SqlTableDefinitions.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Sql -{ - using WixToolset.Data.WindowsInstaller; - - public static class SqlTableDefinitions - { - public static readonly TableDefinition SqlDatabase = new TableDefinition( - "Wix4SqlDatabase", - SqlSymbolDefinitions.SqlDatabase, - new[] - { - new ColumnDefinition("SqlDb", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("Server", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Primary key, name of server running SQL Server"), - new ColumnDefinition("Instance", ColumnType.String, 255, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Primary key, name of SQL Server instance"), - new ColumnDefinition("Database", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Primary key, name of database in a SQL Server"), - new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key, Component used to determine install state ", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "User", keyColumn: 1, description: "Foreign key, User used to log into database", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("FileSpec_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "Wix4SqlFileSpec", keyColumn: 1, description: "Foreign key referencing SqlFileSpec.", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("FileSpec_Log", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "Wix4SqlFileSpec", keyColumn: 1, description: "Foreign key referencing SqlFileSpec.", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, minValue: 0, maxValue: 255, description: "1 == create on install, 2 == drop on uninstall, 4 == continue on error, 8 == drop on install, 16 == create on uninstall, 32 == confirm update existing table, 64 == create on reinstall, 128 == drop on reinstall"), - }, - symbolIdIsPrimaryKey: true - ); - - public static readonly TableDefinition SqlFileSpec = new TableDefinition( - "Wix4SqlFileSpec", - SqlSymbolDefinitions.SqlFileSpec, - new[] - { - new ColumnDefinition("FileSpec", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("Name", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Logical name of filespec", modularizeType: ColumnModularizeType.Property), - new ColumnDefinition("Filename", ColumnType.String, 255, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "Filename to use (path must exist)", modularizeType: ColumnModularizeType.Property), - new ColumnDefinition("Size", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Initial size for file", modularizeType: ColumnModularizeType.Property), - new ColumnDefinition("MaxSize", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Maximum size for file", modularizeType: ColumnModularizeType.Property), - new ColumnDefinition("GrowthSize", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Formatted, description: "Size file should grow when necessary", modularizeType: ColumnModularizeType.Property), - }, - symbolIdIsPrimaryKey: true - ); - - public static readonly TableDefinition SqlScript = new TableDefinition( - "Wix4SqlScript", - SqlSymbolDefinitions.SqlScript, - new[] - { - new ColumnDefinition("Script", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Primary key, non-localized token"), - new ColumnDefinition("SqlDb_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Wix4SqlDatabase", keyColumn: 1, description: "Foreign key, SQL Server key", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key, Component used to determine install state", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("ScriptBinary_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Binary", keyColumn: 1, description: "Foreign key, Binary stream that contains SQL Script to execute", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "User", keyColumn: 1, description: "Foreign key, User used to log into database", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, possibilities: "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31", description: "1 == execute on install, 2 == execute on uninstall, 4 == continue on error, 8 == rollback on install, 16 == rollback on uninstall"), - new ColumnDefinition("Sequence", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Order to execute SQL Queries in"), - }, - symbolIdIsPrimaryKey: true - ); - - public static readonly TableDefinition SqlString = new TableDefinition( - "Wix4SqlString", - SqlSymbolDefinitions.SqlString, - new[] - { - new ColumnDefinition("String", ColumnType.String, 72, primaryKey: true, nullable: false, ColumnCategory.Identifier, description: "Id for the Wix4SqlString", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("SqlDb_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Wix4SqlDatabase", keyColumn: 1, description: "Foreign key, SQL Server key", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("Component_", ColumnType.String, 72, primaryKey: false, nullable: false, ColumnCategory.Identifier, keyTable: "Component", keyColumn: 1, description: "Foreign key, Component used to determine install state", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("SQL", ColumnType.String, 0, primaryKey: false, nullable: false, ColumnCategory.Formatted, description: "SQL query to execute"), - new ColumnDefinition("User_", ColumnType.String, 72, primaryKey: false, nullable: true, ColumnCategory.Identifier, keyTable: "User", keyColumn: 1, description: "Foreign key, User used to log into database", modularizeType: ColumnModularizeType.Column), - new ColumnDefinition("Attributes", ColumnType.Number, 2, primaryKey: false, nullable: false, ColumnCategory.Unknown, possibilities: "1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31", description: "1 == execute on install, 2 == execute on uninstall, 4 == continue on error, 8 == rollback on install, 16 == rollback on uninstall"), - new ColumnDefinition("Sequence", ColumnType.Number, 2, primaryKey: false, nullable: true, ColumnCategory.Unknown, description: "Order to execute SQL Queries in"), - }, - symbolIdIsPrimaryKey: true - ); - - public static readonly TableDefinition[] All = new[] - { - SqlDatabase, - SqlFileSpec, - SqlScript, - SqlString, - }; - } -} diff --git a/src/wixext/SqlWindowsInstallerBackendExtension.cs b/src/wixext/SqlWindowsInstallerBackendExtension.cs deleted file mode 100644 index 2ccdcc56..00000000 --- a/src/wixext/SqlWindowsInstallerBackendExtension.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Sql -{ - using System.Collections.Generic; - using WixToolset.Data.WindowsInstaller; - using WixToolset.Extensibility; - - public class SqlWindowsInstallerBackendBinderExtension : BaseWindowsInstallerBackendBinderExtension - { - public override IReadOnlyCollection TableDefinitions => SqlTableDefinitions.All; - } -} diff --git a/src/wixext/Symbols/SqlDatabaseSymbol.cs b/src/wixext/Symbols/SqlDatabaseSymbol.cs deleted file mode 100644 index 6f0820ac..00000000 --- a/src/wixext/Symbols/SqlDatabaseSymbol.cs +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Sql -{ - using WixToolset.Data; - using WixToolset.Sql.Symbols; - - public static partial class SqlSymbolDefinitions - { - public static readonly IntermediateSymbolDefinition SqlDatabase = new IntermediateSymbolDefinition( - SqlSymbolDefinitionType.SqlDatabase.ToString(), - new[] - { - new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Server), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Instance), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Database), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.ComponentRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.UserRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.FileSpecRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.LogFileSpecRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlDatabaseSymbolFields.Attributes), IntermediateFieldType.Number), - }, - typeof(SqlDatabaseSymbol)); - } -} - -namespace WixToolset.Sql.Symbols -{ - using WixToolset.Data; - - public enum SqlDatabaseSymbolFields - { - Server, - Instance, - Database, - ComponentRef, - UserRef, - FileSpecRef, - LogFileSpecRef, - Attributes, - } - - public class SqlDatabaseSymbol : IntermediateSymbol - { - public SqlDatabaseSymbol() : base(SqlSymbolDefinitions.SqlDatabase, null, null) - { - } - - public SqlDatabaseSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlDatabase, sourceLineNumber, id) - { - } - - public IntermediateField this[SqlDatabaseSymbolFields index] => this.Fields[(int)index]; - - public string Server - { - get => this.Fields[(int)SqlDatabaseSymbolFields.Server].AsString(); - set => this.Set((int)SqlDatabaseSymbolFields.Server, value); - } - - public string Instance - { - get => this.Fields[(int)SqlDatabaseSymbolFields.Instance].AsString(); - set => this.Set((int)SqlDatabaseSymbolFields.Instance, value); - } - - public string Database - { - get => this.Fields[(int)SqlDatabaseSymbolFields.Database].AsString(); - set => this.Set((int)SqlDatabaseSymbolFields.Database, value); - } - - public string ComponentRef - { - get => this.Fields[(int)SqlDatabaseSymbolFields.ComponentRef].AsString(); - set => this.Set((int)SqlDatabaseSymbolFields.ComponentRef, value); - } - - public string UserRef - { - get => this.Fields[(int)SqlDatabaseSymbolFields.UserRef].AsString(); - set => this.Set((int)SqlDatabaseSymbolFields.UserRef, value); - } - - public string FileSpecRef - { - get => this.Fields[(int)SqlDatabaseSymbolFields.FileSpecRef].AsString(); - set => this.Set((int)SqlDatabaseSymbolFields.FileSpecRef, value); - } - - public string LogFileSpecRef - { - get => this.Fields[(int)SqlDatabaseSymbolFields.LogFileSpecRef].AsString(); - set => this.Set((int)SqlDatabaseSymbolFields.LogFileSpecRef, value); - } - - public int Attributes - { - get => this.Fields[(int)SqlDatabaseSymbolFields.Attributes].AsNumber(); - set => this.Set((int)SqlDatabaseSymbolFields.Attributes, value); - } - } -} \ No newline at end of file diff --git a/src/wixext/Symbols/SqlFileSpecSymbol.cs b/src/wixext/Symbols/SqlFileSpecSymbol.cs deleted file mode 100644 index d9eecc62..00000000 --- a/src/wixext/Symbols/SqlFileSpecSymbol.cs +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Sql -{ - using WixToolset.Data; - using WixToolset.Sql.Symbols; - - public static partial class SqlSymbolDefinitions - { - public static readonly IntermediateSymbolDefinition SqlFileSpec = new IntermediateSymbolDefinition( - SqlSymbolDefinitionType.SqlFileSpec.ToString(), - new[] - { - new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.Name), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.Filename), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.Size), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.MaxSize), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlFileSpecSymbolFields.GrowthSize), IntermediateFieldType.String), - }, - typeof(SqlFileSpecSymbol)); - } -} - -namespace WixToolset.Sql.Symbols -{ - using WixToolset.Data; - - public enum SqlFileSpecSymbolFields - { - Name, - Filename, - Size, - MaxSize, - GrowthSize, - } - - public class SqlFileSpecSymbol : IntermediateSymbol - { - public SqlFileSpecSymbol() : base(SqlSymbolDefinitions.SqlFileSpec, null, null) - { - } - - public SqlFileSpecSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlFileSpec, sourceLineNumber, id) - { - } - - public IntermediateField this[SqlFileSpecSymbolFields index] => this.Fields[(int)index]; - - public string Name - { - get => this.Fields[(int)SqlFileSpecSymbolFields.Name].AsString(); - set => this.Set((int)SqlFileSpecSymbolFields.Name, value); - } - - public string Filename - { - get => this.Fields[(int)SqlFileSpecSymbolFields.Filename].AsString(); - set => this.Set((int)SqlFileSpecSymbolFields.Filename, value); - } - - public string Size - { - get => this.Fields[(int)SqlFileSpecSymbolFields.Size].AsString(); - set => this.Set((int)SqlFileSpecSymbolFields.Size, value); - } - - public string MaxSize - { - get => this.Fields[(int)SqlFileSpecSymbolFields.MaxSize].AsString(); - set => this.Set((int)SqlFileSpecSymbolFields.MaxSize, value); - } - - public string GrowthSize - { - get => this.Fields[(int)SqlFileSpecSymbolFields.GrowthSize].AsString(); - set => this.Set((int)SqlFileSpecSymbolFields.GrowthSize, value); - } - } -} \ No newline at end of file diff --git a/src/wixext/Symbols/SqlScriptSymbol.cs b/src/wixext/Symbols/SqlScriptSymbol.cs deleted file mode 100644 index 94c70390..00000000 --- a/src/wixext/Symbols/SqlScriptSymbol.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Sql -{ - using WixToolset.Data; - using WixToolset.Sql.Symbols; - - public static partial class SqlSymbolDefinitions - { - public static readonly IntermediateSymbolDefinition SqlScript = new IntermediateSymbolDefinition( - SqlSymbolDefinitionType.SqlScript.ToString(), - new[] - { - new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.SqlDbRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.ComponentRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.ScriptBinaryRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.UserRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.Attributes), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(SqlScriptSymbolFields.Sequence), IntermediateFieldType.Number), - }, - typeof(SqlScriptSymbol)); - } -} - -namespace WixToolset.Sql.Symbols -{ - using WixToolset.Data; - - public enum SqlScriptSymbolFields - { - SqlDbRef, - ComponentRef, - ScriptBinaryRef, - UserRef, - Attributes, - Sequence, - } - - public class SqlScriptSymbol : IntermediateSymbol - { - public SqlScriptSymbol() : base(SqlSymbolDefinitions.SqlScript, null, null) - { - } - - public SqlScriptSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlScript, sourceLineNumber, id) - { - } - - public IntermediateField this[SqlScriptSymbolFields index] => this.Fields[(int)index]; - - public string SqlDbRef - { - get => this.Fields[(int)SqlScriptSymbolFields.SqlDbRef].AsString(); - set => this.Set((int)SqlScriptSymbolFields.SqlDbRef, value); - } - - public string ComponentRef - { - get => this.Fields[(int)SqlScriptSymbolFields.ComponentRef].AsString(); - set => this.Set((int)SqlScriptSymbolFields.ComponentRef, value); - } - - public string ScriptBinaryRef - { - get => this.Fields[(int)SqlScriptSymbolFields.ScriptBinaryRef].AsString(); - set => this.Set((int)SqlScriptSymbolFields.ScriptBinaryRef, value); - } - - public string UserRef - { - get => this.Fields[(int)SqlScriptSymbolFields.UserRef].AsString(); - set => this.Set((int)SqlScriptSymbolFields.UserRef, value); - } - - public int Attributes - { - get => this.Fields[(int)SqlScriptSymbolFields.Attributes].AsNumber(); - set => this.Set((int)SqlScriptSymbolFields.Attributes, value); - } - - public int? Sequence - { - get => this.Fields[(int)SqlScriptSymbolFields.Sequence].AsNullableNumber(); - set => this.Set((int)SqlScriptSymbolFields.Sequence, value); - } - } -} \ No newline at end of file diff --git a/src/wixext/Symbols/SqlStringSymbol.cs b/src/wixext/Symbols/SqlStringSymbol.cs deleted file mode 100644 index 73a8206e..00000000 --- a/src/wixext/Symbols/SqlStringSymbol.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Sql -{ - using WixToolset.Data; - using WixToolset.Sql.Symbols; - - public static partial class SqlSymbolDefinitions - { - public static readonly IntermediateSymbolDefinition SqlString = new IntermediateSymbolDefinition( - SqlSymbolDefinitionType.SqlString.ToString(), - new[] - { - new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.SqlDbRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.ComponentRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.SQL), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.UserRef), IntermediateFieldType.String), - new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.Attributes), IntermediateFieldType.Number), - new IntermediateFieldDefinition(nameof(SqlStringSymbolFields.Sequence), IntermediateFieldType.Number), - }, - typeof(SqlStringSymbol)); - } -} - -namespace WixToolset.Sql.Symbols -{ - using WixToolset.Data; - - public enum SqlStringSymbolFields - { - SqlDbRef, - ComponentRef, - SQL, - UserRef, - Attributes, - Sequence, - } - - public class SqlStringSymbol : IntermediateSymbol - { - public SqlStringSymbol() : base(SqlSymbolDefinitions.SqlString, null, null) - { - } - - public SqlStringSymbol(SourceLineNumber sourceLineNumber, Identifier id = null) : base(SqlSymbolDefinitions.SqlString, sourceLineNumber, id) - { - } - - public IntermediateField this[SqlStringSymbolFields index] => this.Fields[(int)index]; - - public string SqlDbRef - { - get => this.Fields[(int)SqlStringSymbolFields.SqlDbRef].AsString(); - set => this.Set((int)SqlStringSymbolFields.SqlDbRef, value); - } - - public string ComponentRef - { - get => this.Fields[(int)SqlStringSymbolFields.ComponentRef].AsString(); - set => this.Set((int)SqlStringSymbolFields.ComponentRef, value); - } - - public string SQL - { - get => this.Fields[(int)SqlStringSymbolFields.SQL].AsString(); - set => this.Set((int)SqlStringSymbolFields.SQL, value); - } - - public string UserRef - { - get => this.Fields[(int)SqlStringSymbolFields.UserRef].AsString(); - set => this.Set((int)SqlStringSymbolFields.UserRef, value); - } - - public int Attributes - { - get => this.Fields[(int)SqlStringSymbolFields.Attributes].AsNumber(); - set => this.Set((int)SqlStringSymbolFields.Attributes, value); - } - - public int? Sequence - { - get => this.Fields[(int)SqlStringSymbolFields.Sequence].AsNullableNumber(); - set => this.Set((int)SqlStringSymbolFields.Sequence, value); - } - } -} \ No newline at end of file diff --git a/src/wixext/Symbols/SqlSymbolDefinitions.cs b/src/wixext/Symbols/SqlSymbolDefinitions.cs deleted file mode 100644 index 336f1546..00000000 --- a/src/wixext/Symbols/SqlSymbolDefinitions.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Sql -{ - using System; - using WixToolset.Data; - - public enum SqlSymbolDefinitionType - { - SqlDatabase, - SqlFileSpec, - SqlScript, - SqlString, - } - - public static partial class SqlSymbolDefinitions - { - public static readonly Version Version = new Version("4.0.0"); - - public static IntermediateSymbolDefinition ByName(string name) - { - if (!Enum.TryParse(name, out SqlSymbolDefinitionType type)) - { - return null; - } - - return ByType(type); - } - - public static IntermediateSymbolDefinition ByType(SqlSymbolDefinitionType type) - { - switch (type) - { - case SqlSymbolDefinitionType.SqlDatabase: - return SqlSymbolDefinitions.SqlDatabase; - - case SqlSymbolDefinitionType.SqlFileSpec: - return SqlSymbolDefinitions.SqlFileSpec; - - case SqlSymbolDefinitionType.SqlScript: - return SqlSymbolDefinitions.SqlScript; - - case SqlSymbolDefinitionType.SqlString: - return SqlSymbolDefinitions.SqlString; - - default: - throw new ArgumentOutOfRangeException(nameof(type)); - } - } - } -} diff --git a/src/wixext/WixToolset.Sql.wixext.csproj b/src/wixext/WixToolset.Sql.wixext.csproj deleted file mode 100644 index 5a1ebeb0..00000000 --- a/src/wixext/WixToolset.Sql.wixext.csproj +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - netstandard2.0 - WixToolset.Sql - WiX Toolset Sql Extension - WiX Toolset Sql Extension - embedded - true - - - - - - - - - - - - - - - - - - - diff --git a/src/wixext/WixToolset.Sql.wixext.nuspec b/src/wixext/WixToolset.Sql.wixext.nuspec deleted file mode 100644 index ba3eaade..00000000 --- a/src/wixext/WixToolset.Sql.wixext.nuspec +++ /dev/null @@ -1,25 +0,0 @@ - - - - $id$ - $version$ - $title$ - $description$ - $authors$ - MS-RL - false - $copyright$ - $projectUrl$ - - - - - - - - - - - - - diff --git a/src/wixext/WixToolset.Sql.wixext.targets b/src/wixext/WixToolset.Sql.wixext.targets deleted file mode 100644 index 4950e119..00000000 --- a/src/wixext/WixToolset.Sql.wixext.targets +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - $(MSBuildThisFileDirectory)..\tools\WixToolset.Sql.wixext.dll - - - - - diff --git a/src/wixlib/SqlExtension.wxi b/src/wixlib/SqlExtension.wxi deleted file mode 100644 index c9261f1d..00000000 --- a/src/wixlib/SqlExtension.wxi +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/wixlib/SqlExtension.wxs b/src/wixlib/SqlExtension.wxs deleted file mode 100644 index 8b5320fa..00000000 --- a/src/wixlib/SqlExtension.wxs +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/wixlib/SqlExtension_arm64.wxs b/src/wixlib/SqlExtension_arm64.wxs deleted file mode 100644 index e8d22f69..00000000 --- a/src/wixlib/SqlExtension_arm64.wxs +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/wixlib/SqlExtension_x64.wxs b/src/wixlib/SqlExtension_x64.wxs deleted file mode 100644 index e55a14e4..00000000 --- a/src/wixlib/SqlExtension_x64.wxs +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/wixlib/SqlExtension_x86.wxs b/src/wixlib/SqlExtension_x86.wxs deleted file mode 100644 index 1a51ed91..00000000 --- a/src/wixlib/SqlExtension_x86.wxs +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/wixlib/caDecor.wxi b/src/wixlib/caDecor.wxi deleted file mode 100644 index b1711518..00000000 --- a/src/wixlib/caDecor.wxi +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/wixlib/caerr.wxi b/src/wixlib/caerr.wxi deleted file mode 100644 index ff7ec121..00000000 --- a/src/wixlib/caerr.wxi +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/wixlib/de-de.wxl b/src/wixlib/de-de.wxl deleted file mode 100644 index ed2313a4..00000000 --- a/src/wixlib/de-de.wxl +++ /dev/null @@ -1,16 +0,0 @@ - - - - - Fehler [2]: Erstellen der SQL-Datenbank fehlgeschlagen: [3], Fehlerbeschreibung: [4]. - Fehler [2]: Löschen der SQL-Datenbank fehlgeschlagen: [3], Fehlerbeschreibung: [4]. - Verbinden mit der SQL-Datenbank fehlgeschlagen. ([2] [3] [4] [5]) - Fehler [2]: Das Erstellen der SQL Zeichenfolge ist fehlgeschlagen, Fehlerbeschreibung: [3], SQL-Schlüssel: [4] SQL-Zeichenfolge: [5] - Die Datenbank [3] existiert bereits. Wollen Sie fortfahren? - - Konfiguriere SQL Server - Erstelle Datenbanken - Lösche Datenbanken - SQL-Zeichenfolgen werden erstellt - SQL-Zeichenfolgen werden zurückgesetzt - diff --git a/src/wixlib/en-us.wxl b/src/wixlib/en-us.wxl deleted file mode 100644 index d3ffd5eb..00000000 --- a/src/wixlib/en-us.wxl +++ /dev/null @@ -1,16 +0,0 @@ - - - - - Error [2]: failed to create SQL database: [3], error detail: [4]. - Error [2]: failed to drop SQL database: [3], error detail: [4]. - Failed to connect to SQL database. ([2] [3] [4] [5]) - Error [2]: failed to execute SQL string, error detail: [3], SQL key: [4] SQL string: [5] - The database [3] already exists. Do you want to continue? - - Configuring SQL Server - Creating Databases - Dropping Databases - Executing SQL Strings - Rolling back SQL Strings - diff --git a/src/wixlib/es-es.wxl b/src/wixlib/es-es.wxl deleted file mode 100644 index b2e5d499..00000000 --- a/src/wixlib/es-es.wxl +++ /dev/null @@ -1,17 +0,0 @@ - - - - - Error [2]: falla al crear la base de datos SQL: [3], detalle del error: [4]. - Error [2]: falla al poner la base de datos SQL: [3], detalle del error: [4]. - Falla al conectarse con la base de datos SQL. ([2] [3] [4] [5]) - Error [2]: falla al ejecutar la cadena SQL, detalle del error: [3], Clave SQL: [4] Cadena SQL: [5] - La base de datos [3] ya existe. ¿Desea continuar? - - Configurando SQL Server - Creando Bases de Datos - Colocando Bases de Datos - Ejecutando cadenas SQL - Revirtiendo cadenas SQL - - diff --git a/src/wixlib/ja-jp.wxl b/src/wixlib/ja-jp.wxl deleted file mode 100644 index 6e35fd17..00000000 --- a/src/wixlib/ja-jp.wxl +++ /dev/null @@ -1,16 +0,0 @@ - - - - - エラー [2]: SQL データベース [3] 作成に失敗しました、エラー詳細: [4]。 - エラー [2]: SQL データベース [3] の削除に失敗しました、エラー詳細: [4]。 - SQL データベースへ接続できませんでした。 ([2] [3] [4] [5]) - エラー [2]: SQL ストリングの実行に失敗しました、エラー詳細: [3]、 SQL キー: [4] SQL ストリング: [5] - データベース [3] は既に存在します。続行しますか? - - SQL サーバーを構成しています - データベースを作成しています - データベースを削除しています - SQL ストリングを実行しています - SQL ストリングをロールバックしています - diff --git a/src/wixlib/pl-pl.wxl b/src/wixlib/pl-pl.wxl deleted file mode 100644 index 6200e0e9..00000000 --- a/src/wixlib/pl-pl.wxl +++ /dev/null @@ -1,16 +0,0 @@ - - - - - Błąd [2]: nie udało się utworzyć bazy danych: [3]. Szczegóły błędu: [4]. - Błąd [2]: nie udało się usunąć bazy danych: [3]. Szczegóły błędu: [4]. - Nie udało się połączyć z bazą danych. ([2] [3] [4] [5]) - Błąd [2]: nie udało się wykonać zapytania SQL. Szczegóły błędu: [3], klucz: [4] zapytanie SQL: [5] - Baza danych [3] już istnieje. Czy chcesz kontynuować? - - Konfigurowanie programu SQL Server - Tworzenie baz danych - Usuwanie baz danych - Wykonywanie zapytań SQL - Cofanie zapytań SQL - diff --git a/src/wixlib/pt-br.wxl b/src/wixlib/pt-br.wxl deleted file mode 100644 index 74c53313..00000000 --- a/src/wixlib/pt-br.wxl +++ /dev/null @@ -1,16 +0,0 @@ - - - - - Error [2]: falha ao criar o Banco de Dados: [3], detalhes: [4]. - Error [2]: falha ao remover o Banco de Dados: [3], detalhes: [4]. - Falhou a ligação ao Banco de Dados. ([2] [3] [4] [5]) - Erro [2]: falha ao executar o comando de SQL, detalhes: [3], Comando: [4] Conteúdo: [5] - O Banco de Dados [3] já existe. Deseja continuar? - - Configurando o Servidor de SQL - Criando os Bancos de Dados - Removendo os Bancos de Dados - Executando comandos de SQL - Revertendo os comandos de SQL - diff --git a/src/wixlib/pt-pt.wxl b/src/wixlib/pt-pt.wxl deleted file mode 100644 index 90d9df4f..00000000 --- a/src/wixlib/pt-pt.wxl +++ /dev/null @@ -1,16 +0,0 @@ - - - - - Error [2]: falha ao criar a Base de Dados: [3], detalhes: [4]. - Error [2]: falha ao remover a Base de Dados: [3], detalhes: [4]. - Falhou a ligação à Base de Dados. ([2] [3] [4] [5]) - Erro [2]: falha ao executar o comando de SQL, detalhes: [3], Comando: [4] Conteúdo: [5] - A Base de Dados [3] já existe. Deseja continuar? - - Configurar o Servidor de SQL - Criar as Bases de Dados - Remover as Bases de Dados - Executar comandos de SQL - Reverter os comandos de SQL - diff --git a/src/wixlib/sql.v3.ncrunchproject b/src/wixlib/sql.v3.ncrunchproject deleted file mode 100644 index 319cd523..00000000 --- a/src/wixlib/sql.v3.ncrunchproject +++ /dev/null @@ -1,5 +0,0 @@ - - - True - - \ No newline at end of file diff --git a/src/wixlib/sql.wixproj b/src/wixlib/sql.wixproj deleted file mode 100644 index ac994e6b..00000000 --- a/src/wixlib/sql.wixproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - - Library - true - - - - - - - - - - - - - - - - - - diff --git a/version.json b/version.json deleted file mode 100644 index 5f857771..00000000 --- a/version.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "version": "4.0", - "publicReleaseRefSpec": [ - "^refs/heads/master$" - ], - "cloudBuild": { - "buildNumber": { - "enabled": true - } - } -} -- cgit v1.2.3-55-g6feb