diff --git a/.gitignore b/.gitignore index a15e008..e699d42 100644 --- a/.gitignore +++ b/.gitignore @@ -252,4 +252,7 @@ paket-files/ *.sln.iml # Build artifacts/ -**/build/ \ No newline at end of file +**/build/ +/src/build.zip +/src/Version/Version.cs +/src/after.ssis-build.sln.targets diff --git a/src/SsisBuild.Core.Tests/DeployArgumentsTests.cs b/src/SsisBuild.Core.Tests/DeployArgumentsTests.cs index c5b7ea3..07ce2db 100644 --- a/src/SsisBuild.Core.Tests/DeployArgumentsTests.cs +++ b/src/SsisBuild.Core.Tests/DeployArgumentsTests.cs @@ -29,8 +29,6 @@ public void Pass_New_AllArguments() var workingFolder = Fakes.RandomString(); var deploymentFilePath = Fakes.RandomString(); var serverInstance = Fakes.RandomString(); - var serverInstanceUserID = Fakes.RandomString(); - var serverInstancePassword = Fakes.RandomString(); var catalog = Fakes.RandomString(); var folder = Fakes.RandomString(); var projectName = Fakes.RandomString(); @@ -39,14 +37,12 @@ public void Pass_New_AllArguments() // Execute - var deployArguments = new DeployArguments(workingFolder, deploymentFilePath, serverInstance, catalog, folder, projectName, projectPassword, eraseSensitiveInfo, serverInstanceUserID, serverInstancePassword); + var deployArguments = new DeployArguments(workingFolder, deploymentFilePath, serverInstance, catalog, folder, projectName, projectPassword, eraseSensitiveInfo); // Assert Assert.Equal(workingFolder, deployArguments.WorkingFolder); Assert.Equal(deploymentFilePath, deployArguments.DeploymentFilePath); Assert.Equal(serverInstance, deployArguments.ServerInstance); - Assert.Equal(serverInstanceUserID, deployArguments.ServerInstanceUserID); - Assert.Equal(serverInstancePassword, deployArguments.ServerInstancePassword); Assert.Equal(catalog, deployArguments.Catalog); Assert.Equal(folder, deployArguments.Folder); Assert.Equal(projectName, deployArguments.ProjectName); @@ -60,7 +56,7 @@ public void Fail_New_MissingServerInstance() // Setup // Execute - var exception = Record.Exception(() => new DeployArguments(null, null, null, Fakes.RandomString(), Fakes.RandomString(), Fakes.RandomString(), null, Fakes.RandomBool(), null, null)); + var exception = Record.Exception(() => new DeployArguments(null, null, null, Fakes.RandomString(), Fakes.RandomString(), Fakes.RandomString(), null, Fakes.RandomBool())); // Assert Assert.NotNull(exception); @@ -74,7 +70,7 @@ public void Fail_New_MissingFolder() // Setup // Execute - var exception = Record.Exception(() => new DeployArguments(null, null, Fakes.RandomString(), Fakes.RandomString(), null, Fakes.RandomString(), null, Fakes.RandomBool(), null, null)); + var exception = Record.Exception(() => new DeployArguments(null, null, Fakes.RandomString(), Fakes.RandomString(), null, Fakes.RandomString(), null, Fakes.RandomBool())); // Assert Assert.NotNull(exception); diff --git a/src/SsisBuild.Core.Tests/PackageTests.cs b/src/SsisBuild.Core.Tests/PackageTests.cs index 93cc256..7d89d8a 100644 --- a/src/SsisBuild.Core.Tests/PackageTests.cs +++ b/src/SsisBuild.Core.Tests/PackageTests.cs @@ -69,6 +69,7 @@ public void Fail_InvalidProtectionLevel() } [Fact] + [Obsolete] public void Fail_NoProtectionLevel() { // Setup diff --git a/src/SsisBuild.Core.Tests/ProjectManifestTests.cs b/src/SsisBuild.Core.Tests/ProjectManifestTests.cs index 4f51955..2e55e0f 100644 --- a/src/SsisBuild.Core.Tests/ProjectManifestTests.cs +++ b/src/SsisBuild.Core.Tests/ProjectManifestTests.cs @@ -139,6 +139,7 @@ public void Pass_SetProtectionLevel(ProtectionLevel protectionLevel, int version [Theory] [InlineData(ProtectionLevel.EncryptAllWithUserKey)] [InlineData(ProtectionLevel.EncryptSensitiveWithUserKey)] + [Obsolete] public void Fail_UserKeyProtectionLevel(ProtectionLevel protectionLevel) { // Setup diff --git a/src/SsisBuild.Core/Builder/Builder.cs b/src/SsisBuild.Core/Builder/Builder.cs index 3d47dc4..ed15c38 100644 --- a/src/SsisBuild.Core/Builder/Builder.cs +++ b/src/SsisBuild.Core/Builder/Builder.cs @@ -84,6 +84,9 @@ public void Build(IBuildArguments buildArguments) // Load and process project _project.LoadFromDtproj(projectPath, buildArguments.Configuration, buildArguments.Password); + _logger.LogMessage("-------------------------------------------------------------------------------"); + _logger.LogMessage($"Finished loading project files from {projectPath}."); + // replace parameter values foreach (var buildArgumentsParameter in buildArguments.Parameters) { diff --git a/src/SsisBuild.Core/Deployer/DeployArguments.cs b/src/SsisBuild.Core/Deployer/DeployArguments.cs index 0810ce0..a254d56 100644 --- a/src/SsisBuild.Core/Deployer/DeployArguments.cs +++ b/src/SsisBuild.Core/Deployer/DeployArguments.cs @@ -18,12 +18,10 @@ namespace SsisBuild.Core.Deployer { public class DeployArguments : IDeployArguments { - public DeployArguments(string workingFolder, string deploymentFilePath, string serverInstance, string catalog, string folder, string projectName, string projectPassword, bool eraseSensitiveInfo, string serverInstanceUserID, string serverInstancePassword) + public DeployArguments(string workingFolder, string deploymentFilePath, string serverInstance, string catalog, string folder, string projectName, string projectPassword, bool eraseSensitiveInfo) { DeploymentFilePath = deploymentFilePath; ServerInstance = serverInstance; - ServerInstanceUserID = serverInstanceUserID; - ServerInstancePassword = serverInstancePassword; Catalog = catalog; Folder = folder; ProjectName = projectName; @@ -39,10 +37,6 @@ public DeployArguments(string workingFolder, string deploymentFilePath, string s public string ServerInstance { get; } - public string ServerInstanceUserID { get; } - - public string ServerInstancePassword { get; } - public string Catalog { get; } public string Folder { get; } @@ -60,12 +54,6 @@ public void Validate() if (string.IsNullOrWhiteSpace(Folder)) throw new MissingRequiredArgumentException(nameof(Folder)); - - if (string.IsNullOrWhiteSpace(ServerInstancePassword) && !string.IsNullOrWhiteSpace(ServerInstanceUserID)) - throw new MissingRequiredArgumentException(nameof(ServerInstancePassword)); - - if (string.IsNullOrWhiteSpace(ServerInstanceUserID) && !string.IsNullOrWhiteSpace(ServerInstancePassword)) - throw new MissingRequiredArgumentException(nameof(ServerInstanceUserID)); } } } diff --git a/src/SsisBuild.Core/Deployer/Deployer.cs b/src/SsisBuild.Core/Deployer/Deployer.cs index df34008..9b4fddc 100644 --- a/src/SsisBuild.Core/Deployer/Deployer.cs +++ b/src/SsisBuild.Core/Deployer/Deployer.cs @@ -79,9 +79,7 @@ public void Deploy(IDeployArguments deployArguments) catalog, deployArguments.Folder, projectName, deployArguments.ProjectPassword, - deployArguments.EraseSensitiveInfo, - deployArguments.ServerInstanceUserID, - deployArguments.ServerInstancePassword + deployArguments.EraseSensitiveInfo ), parametersToDeploy, deploymentProtectionLevel); @@ -90,23 +88,16 @@ public void Deploy(IDeployArguments deployArguments) { ApplicationName = "SSIS Deploy", DataSource = deployArguments.ServerInstance, - InitialCatalog = catalog - }; - - if (string.IsNullOrWhiteSpace(deployArguments.ServerInstanceUserID)) - { - connectionString.IntegratedSecurity = true; - } else { - connectionString.UserID = deployArguments.ServerInstanceUserID; - connectionString.Password = deployArguments.ServerInstancePassword; - } + InitialCatalog = catalog, + IntegratedSecurity = true + }.ConnectionString; using (var zipStream = new MemoryStream()) { _project.Save(zipStream, deploymentProtectionLevel, deployArguments.ProjectPassword); zipStream.Flush(); - _catalogTools.DeployProject(connectionString.ConnectionString, deployArguments.Folder, projectName, deployArguments.EraseSensitiveInfo, parametersToDeploy, zipStream); + _catalogTools.DeployProject(connectionString, deployArguments.Folder, projectName, deployArguments.EraseSensitiveInfo, parametersToDeploy, zipStream); } _logger.LogMessage(""); diff --git a/src/SsisBuild.Core/Deployer/IDeployArguments.cs b/src/SsisBuild.Core/Deployer/IDeployArguments.cs index e0e9609..cfaa300 100644 --- a/src/SsisBuild.Core/Deployer/IDeployArguments.cs +++ b/src/SsisBuild.Core/Deployer/IDeployArguments.cs @@ -21,8 +21,6 @@ public interface IDeployArguments string WorkingFolder { get; } string DeploymentFilePath { get; } string ServerInstance { get; } - string ServerInstanceUserID { get; } - string ServerInstancePassword { get; } string Catalog { get; } string Folder { get; } string ProjectName { get; } diff --git a/src/SsisBuild.Core/Deployer/SsisDeployPowershell.cs b/src/SsisBuild.Core/Deployer/SsisDeployPowershell.cs index 98d31a2..fe3e11a 100644 --- a/src/SsisBuild.Core/Deployer/SsisDeployPowershell.cs +++ b/src/SsisBuild.Core/Deployer/SsisDeployPowershell.cs @@ -28,18 +28,10 @@ public class SsisDeployPowershell : PSCmdlet )] public string DeploymentFilePath { get; set; } - [Parameter(HelpMessage = "Required. Full Name of the target SQL Server instance.", + [Parameter(HelpMessage= "Required. Full Name of the target SQL Server instance.", Mandatory = true)] public string ServerInstance { get; set; } - [Parameter(HelpMessage = "Required. Full Name of the target SQL Server instance.", - Mandatory = true)] - public string ServerInstanceUserID { get; set; } - - [Parameter(HelpMessage = "Required. Full Name of the target SQL Server instance.", - Mandatory = true)] - public string ServerInstancePassword { get; set; } - [Parameter(HelpMessage = "Name of the SSIS Catalog on the target server. If not supplied, then SSISDB value is used.")] public string Catalog { get; set; } @@ -79,9 +71,7 @@ protected override void ProcessRecord() string.IsNullOrWhiteSpace(Folder) ? null : Folder, string.IsNullOrWhiteSpace(ProjectName) ? null : ProjectName, string.IsNullOrWhiteSpace(ProjectPassword) ? null : ProjectPassword, - EraseSensitiveInfo, - string.IsNullOrWhiteSpace(ServerInstanceUserID) ? null : ServerInstanceUserID, - string.IsNullOrWhiteSpace(ServerInstancePassword) ? null : ServerInstancePassword + EraseSensitiveInfo ); _deployer = _deployer ?? new Deployer(); diff --git a/src/SsisBuild.Core/ProjectManagement/Project.cs b/src/SsisBuild.Core/ProjectManagement/Project.cs index f1cf8f8..e6f5ad7 100644 --- a/src/SsisBuild.Core/ProjectManagement/Project.cs +++ b/src/SsisBuild.Core/ProjectManagement/Project.cs @@ -317,6 +317,7 @@ public void LoadFromDtproj(string filePath, string configurationName, string pas } var userConfigurationFilePath = $"{filePath}.user"; + if (File.Exists(userConfigurationFilePath)) { var userConfiguration = new UserConfiguration(configurationName); diff --git a/src/SsisBuild.Core/ProjectManagement/ProjectFile.cs b/src/SsisBuild.Core/ProjectManagement/ProjectFile.cs index d1024c9..97cb4f1 100644 --- a/src/SsisBuild.Core/ProjectManagement/ProjectFile.cs +++ b/src/SsisBuild.Core/ProjectManagement/ProjectFile.cs @@ -134,16 +134,16 @@ private XmlDocument PrepareXmlToSave(ProtectionLevel protectionLevel, string pas var xmlToSave = new XmlDocument(); xmlToSave.LoadXml(FileXmlDocument.OuterXml); - if (!new [] + if (!new[] { ProtectionLevel.DontSaveSensitive, + ProtectionLevel.EncryptSensitiveWithUserKey, ProtectionLevel.EncryptAllWithPassword, ProtectionLevel.EncryptSensitiveWithPassword, ProtectionLevel.ServerStorage }.Contains(protectionLevel)) throw new InvalidProtectionLevelException(protectionLevel); - if (protectionLevel == ProtectionLevel.EncryptAllWithPassword) { EncryptElement(xmlToSave.DocumentElement, password); diff --git a/src/SsisBuild.Core/ProjectManagement/ProjectManifest.cs b/src/SsisBuild.Core/ProjectManagement/ProjectManifest.cs index 3d7e49f..6084434 100644 --- a/src/SsisBuild.Core/ProjectManagement/ProjectManifest.cs +++ b/src/SsisBuild.Core/ProjectManagement/ProjectManifest.cs @@ -279,9 +279,9 @@ protected override IList ExtractParameters() { foreach (XmlNode packageParameterXmlNode in packageParameterXmlNodes) { - var packageName = packageParameterXmlNode.SelectSingleNode("../../@SSIS:Name", NamespaceManager).Value; + var packageName = packageParameterXmlNode.SelectSingleNode("../../SSIS:Properties/SSIS:Property[@SSIS:Name = \"Name\"]", NamespaceManager)?.InnerText; - parameters.Add(new ProjectParameter(packageName.Remove(packageName.Length - 5), packageParameterXmlNode)); + parameters.Add(new ProjectParameter(packageName, packageParameterXmlNode)); } } diff --git a/src/SsisDeploy/Program.cs b/src/SsisDeploy/Program.cs index f903b83..bdb76a9 100644 --- a/src/SsisDeploy/Program.cs +++ b/src/SsisDeploy/Program.cs @@ -31,8 +31,6 @@ class Program nameof(DeployArguments.ProjectName), nameof(DeployArguments.ProjectPassword), nameof(DeployArguments.ServerInstance), - nameof(DeployArguments.ServerInstanceUserID), - nameof(DeployArguments.ServerInstancePassword), }; @@ -71,8 +69,6 @@ internal static DeployArguments ParseCommandLineArguments(string[] args) string deploymentFilePath = null; string serverInstance = null; - string ServerInstanceUserID = null; - string ServerInstancePassword = null; string catalog = null; string folder = null; string projectName = null; @@ -122,20 +118,12 @@ internal static DeployArguments ParseCommandLineArguments(string[] args) projectPassword = args[argPos++ + 1]; break; - case nameof(DeployArguments.ServerInstanceUserID): - ServerInstanceUserID = args[argPos++ + 1]; - break; - - case nameof(DeployArguments.ServerInstancePassword): - ServerInstancePassword = args[argPos++ + 1]; - break; - default: throw new InvalidTokenException(argName); } } - return new DeployArguments(Environment.CurrentDirectory, deploymentFilePath, serverInstance, catalog, folder, projectName, projectPassword, eraseSensitiveInfo, ServerInstanceUserID, ServerInstancePassword); + return new DeployArguments(Environment.CurrentDirectory, deploymentFilePath, serverInstance, catalog, folder, projectName, projectPassword, eraseSensitiveInfo); } @@ -157,10 +145,6 @@ private static void Usage() "", " -ServerInstance: Required. Full Name of the target SQL Server instance.", "", - " -ServerInstanceUserID: User in case SQL Server Authentication is used (e.g. SSIS in ADFv2)", - "", - " -ServerInstancePassword: Password in case SQL Server Authentication is used (e.g. SSIS in ADFv2)", - "", " -Catalog: Required. Name of the SSIS Catalog on the target server.", "", " -Folder: Required. Deployment folder within destination catalog.", diff --git a/src/ps-config/ssis-build.psd1 b/src/ps-config/ssis-build.psd1 new file mode 100644 index 0000000..8a88d6a --- /dev/null +++ b/src/ps-config/ssis-build.psd1 @@ -0,0 +1,13 @@ +@{ + SolutionName="ssis-build" + SqlVersion="130" + SSASVersion="130" + EnableNuGetPackageRestore=$true + IgnorePackageVersioning=$False + Nuget = @( + @{ + Source = "http://nuget.laterooms.io/nuget" + ApiKey = "creat10n" + } + ); +}