From 104b42aafc75f9744372f1306dcdd77400dbce5c Mon Sep 17 00:00:00 2001 From: Demian Marty Date: Wed, 2 Sep 2020 08:27:27 +0200 Subject: [PATCH 1/7] add support for refactor log script files --- src/DacpacTool/BuildOptions.cs | 1 + src/DacpacTool/PackageBuilder.cs | 6 +- src/DacpacTool/Program.cs | 8 ++- src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets | 22 +++--- test/DacpacTool.Tests/PackageBuilderTests.cs | 68 ++++++++++++++++--- .../TestProjectWithPrePost.refactorlog | 24 +++++++ 6 files changed, 102 insertions(+), 27 deletions(-) create mode 100644 test/TestProjectWithPrePost/RefactorLog/TestProjectWithPrePost.refactorlog diff --git a/src/DacpacTool/BuildOptions.cs b/src/DacpacTool/BuildOptions.cs index 0bb8718f..0bae5ab1 100644 --- a/src/DacpacTool/BuildOptions.cs +++ b/src/DacpacTool/BuildOptions.cs @@ -15,5 +15,6 @@ public class BuildOptions public string[] SqlCmdVar { get; set; } public FileInfo PreDeploy { get; set; } public FileInfo PostDeploy { get; set; } + public FileInfo RefactorLog { get; set; } } } diff --git a/src/DacpacTool/PackageBuilder.cs b/src/DacpacTool/PackageBuilder.cs index 4fe972b5..820f8ff1 100644 --- a/src/DacpacTool/PackageBuilder.cs +++ b/src/DacpacTool/PackageBuilder.cs @@ -102,13 +102,13 @@ public bool ValidateModel() return _modelValid.Value; } - public void SaveToDisk(FileInfo outputFile) + public void SaveToDisk(FileInfo outputFile, PackageOptions packageOptions = null) { // Ensure that the model has been created and metadata has been set EnsureModelCreated(); EnsureModelValidated(); EnsureMetadataCreated(); - + // Check if the file already exists if (outputFile.Exists) { @@ -118,7 +118,7 @@ public void SaveToDisk(FileInfo outputFile) } Console.WriteLine($"Writing model to {outputFile.FullName}"); - DacPackageExtensions.BuildPackage(outputFile.FullName, Model, Metadata, new PackageOptions { }); + DacPackageExtensions.BuildPackage(outputFile.FullName, Model, Metadata, packageOptions ?? new PackageOptions { }); } public void SetMetadata(string name, string version) diff --git a/src/DacpacTool/Program.cs b/src/DacpacTool/Program.cs index 630e7d10..0b82e5b9 100644 --- a/src/DacpacTool/Program.cs +++ b/src/DacpacTool/Program.cs @@ -3,6 +3,7 @@ using System.CommandLine.Invocation; using System.IO; using System.Threading.Tasks; +using Microsoft.SqlServer.Dac; using Microsoft.SqlServer.Dac.Model; namespace MSBuild.Sdk.SqlProj.DacpacTool @@ -16,11 +17,12 @@ static async Task Main(string[] args) new Option(new string[] { "--name", "-n" }, "Name of the package"), new Option(new string[] { "--version", "-v" }, "Version of the package"), new Option(new string[] { "--output", "-o" }, "Filename of the output package"), - new Option(new string[] { "--sqlServerVersion", "-sv" }, () => SqlServerVersion.Sql150, description: "Target version of the model"), + new Option(new string[] { "--sqlServerVersion", "-sv" }, () => SqlServerVersion.Sql150, description: "Target version of the model"), new Option(new string[] { "--input", "-i" }, "Input file name(s)"), new Option(new string[] { "--reference", "-r" }, "Reference(s) to include"), new Option(new string[] { "--predeploy" }, "Filename of optional pre-deployment script"), new Option(new string[] { "--postdeploy" }, "Filename of optional post-deployment script"), + new Option(new string[] { "--refactorlog" }, "Filename of optional refactor log script"), new Option(new string[] { "--property", "-p" }, "Properties to be set on the model"), new Option(new string[] { "--sqlcmdvar", "-sc" }, "SqlCmdVariable(s) to include"), }; @@ -94,7 +96,7 @@ private static int BuildDacpac(BuildOptions options) } // Save the package to disk - packageBuilder.SaveToDisk(options.Output); + packageBuilder.SaveToDisk(options.Output, new PackageOptions() { RefactorLogPath = options.RefactorLog.FullName }); // Add predeployment and postdeployment scripts (must happen after SaveToDisk) packageBuilder.AddPreDeploymentScript(options.PreDeploy, options.Output); @@ -129,7 +131,7 @@ private static int DeployDacpac(DeployOptions options) } deployer.UseTargetServer(options.TargetServerName); - + if (!string.IsNullOrWhiteSpace(options.TargetUser)) { deployer.UseSqlAuthentication(options.TargetUser, options.TargetPassword); diff --git a/src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets b/src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets index ff7ae161..0620c9cf 100644 --- a/src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets +++ b/src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets @@ -8,7 +8,7 @@ <_IntermediateAssembly Include="@(IntermediateAssembly)" /> @@ -73,10 +73,9 @@ - - @@ -84,7 +83,7 @@ - @@ -110,14 +109,14 @@ location of the package and then checking if a that package contains a .dacpac file inside of the tools folder. --> - + <_ResolvedPackageReference Include="%(PackageReference.Identity)"> @(PackageReference->'%(Identity)'->Replace('.', '_')) $(Pkg%(_ResolvedPackageReference.PackageName)) - @@ -125,7 +124,7 @@ %(_ResolvedPackageReference.PhysicalLocation)/tools/%(Identity).dacpac - + @@ -156,12 +155,13 @@ @(SqlCmdVariable->'-sc %(Identity)', ' ') @(PreDeploy->'--predeploy %(Identity)', ' ') @(PostDeploy->'--postdeploy %(Identity)', ' ') - dotnet $(DacpacToolExe) build $(OutputPathArgument) $(MetadataArguments) $(SqlServerVersionArgument) $(InputFileArguments) $(ReferenceArguments) $(SqlCmdVariableArguments) $(PropertyArguments) $(PreDeploymentScriptArgument) $(PostDeploymentScriptArgument) + @(RefactorLog->'--refactorlog %(Identity)', ' ') + dotnet $(DacpacToolExe) build $(OutputPathArgument) $(MetadataArguments) $(SqlServerVersionArgument) $(InputFileArguments) $(ReferenceArguments) $(SqlCmdVariableArguments) $(PropertyArguments) $(PreDeploymentScriptArgument) $(PostDeploymentScriptArgument) $(RefactorLogScriptArgument) + Condition="'$(DesignTimeBuild)' != 'true' AND '$(BuildingProject)' == 'true'" /> @@ -188,5 +188,5 @@ - + diff --git a/test/DacpacTool.Tests/PackageBuilderTests.cs b/test/DacpacTool.Tests/PackageBuilderTests.cs index 250cad6e..a47c3297 100644 --- a/test/DacpacTool.Tests/PackageBuilderTests.cs +++ b/test/DacpacTool.Tests/PackageBuilderTests.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Reflection; using Microsoft.Data.Tools.Schema.Sql.Packaging; +using Microsoft.SqlServer.Dac; using Microsoft.SqlServer.Dac.Model; using Microsoft.VisualStudio.TestTools.UnitTesting; using Shouldly; @@ -59,7 +60,7 @@ public void AddReference_FileDoesNotExist() packageBuilder.UsingVersion(SqlServerVersion.Sql150); // Act & Assert - Should.Throw(() => packageBuilder.AddReference(new FileInfo("NonExistentFile.dacpac"))); + Should.Throw(() => packageBuilder.AddReference(new FileInfo("NonExistentFile.dacpac"))); } [TestMethod] @@ -77,7 +78,7 @@ public void AddReference_FileExists() // Assert packageBuilder.Model.GetObject(Procedure.TypeClass, new ObjectIdentifier("dbo", "MyStoredProcedure"), DacQueryScopes.All).ShouldNotBeNull(); - + // Cleanup reference.Delete(); } @@ -100,7 +101,7 @@ public void AddSqlCmdvariable() packageBuilder.ValidateModel(); packageBuilder.SaveToDisk(tempFile); var headerParser = new DacpacHeaderParser.HeaderParser(tempFile.FullName); - + headerParser.GetCustomData() .Where(d => d.Category == "SqlCmdVariables" && d.Type == "SqlCmdVariable") @@ -130,10 +131,12 @@ public void AddPreDeployment_FilesExist() packageBuilder.SetMetadata("MyPackage", "1.0.0.0"); packageBuilder.UsingVersion(SqlServerVersion.Sql150); packageBuilder.ValidateModel(); - packageBuilder.SaveToDisk(tempFile); + var packageOptions = new PackageOptions() { RefactorLogPath = "../../../../TestProjectWithPrePost/RefactorLog/TestProjectWithPrePost.refactorlog" }; // Act - packageBuilder.AddPreDeploymentScript( + packageBuilder.SaveToDisk(tempFile, packageOptions); + + packageBuilder.AddPreDeploymentScript( new FileInfo("../../../../TestProjectWithPrePost/Pre-Deployment/Script.PreDeployment.sql"), tempFile); @@ -143,8 +146,9 @@ public void AddPreDeployment_FilesExist() // Assert var package = Package.Open(tempFile.FullName); - var prePart = package.GetPart(new Uri("/predeploy.sql", UriKind.Relative)); + var prePart = package.GetPart(new Uri("/predeploy.sql", UriKind.Relative)); var postPart = package.GetPart(new Uri("/postdeploy.sql", UriKind.Relative)); + var refactorPart = package.GetPart(new Uri("/refactor.xml", UriKind.Relative)); prePart.ShouldNotBeNull(); prePart.ContentType.ShouldBe("text/plain"); @@ -154,6 +158,10 @@ public void AddPreDeployment_FilesExist() postPart.ContentType.ShouldBe("text/plain"); postPart.GetStream().ShouldNotBeNull(); + refactorPart.ShouldNotBeNull(); + refactorPart.ContentType.ShouldBe("text/xml"); + refactorPart.GetStream().ShouldNotBeNull(); + // Cleanup package.Close(); tempFile.Delete(); @@ -177,7 +185,7 @@ public void AddPreDeployment_NoFilePresent() // Assert var package = Package.Open(tempFile.FullName); - + package.GetParts() .Where(p => p.Uri == new Uri("/predeploy.sql", UriKind.Relative)) .FirstOrDefault() @@ -222,6 +230,31 @@ public void AddPostDeployment_NoFilePresent() tempFile.Delete(); } + [TestMethod] + public void AddRefactorLog_NoFilePresent() + { + // Arrange + var tempFile = new FileInfo(Path.GetTempFileName()); + var packageBuilder = new PackageBuilder(); + packageBuilder.SetMetadata("MyPackage", "1.0.0.0"); + packageBuilder.UsingVersion(SqlServerVersion.Sql150); + packageBuilder.ValidateModel(); + + // Act + packageBuilder.SaveToDisk(tempFile, new PackageOptions() { RefactorLogPath = null }); + + // Assert + var package = Package.Open(tempFile.FullName); + + package.GetParts() + .Where(p => p.Uri == new Uri("/refactor.log", UriKind.Relative)) + .FirstOrDefault() + .ShouldBeNull(); + + // Cleanup + package.Close(); + tempFile.Delete(); + } [TestMethod] public void AddPreDeployment_WrongOrder() @@ -232,7 +265,6 @@ public void AddPreDeployment_WrongOrder() packageBuilder.SetMetadata("MyPackage", "1.0.0.0"); packageBuilder.UsingVersion(SqlServerVersion.Sql150); - // Act & Assert Should.Throw(() => packageBuilder.AddPreDeploymentScript(null, tempFile)); } @@ -246,7 +278,6 @@ public void AddPostDeployment_WrongOrder() packageBuilder.SetMetadata("MyPackage", "1.0.0.0"); packageBuilder.UsingVersion(SqlServerVersion.Sql150); - // Act & Assert Should.Throw(() => packageBuilder.AddPostDeploymentScript(null, tempFile)); } @@ -291,6 +322,23 @@ public void AddPostDeployment_PostNotExists() tempFile.Delete(); } + [TestMethod] + public void AddRefactorLog_RefactorNotExists() + { + // Arrange + var tempFile = new FileInfo(Path.GetTempFileName()); + var packageBuilder = new PackageBuilder(); + packageBuilder.SetMetadata("MyPackage", "1.0.0.0"); + packageBuilder.UsingVersion(SqlServerVersion.Sql150); + packageBuilder.ValidateModel(); + + // Act & Assert + Should.Throw(() => packageBuilder.SaveToDisk(tempFile, new PackageOptions() { RefactorLogPath = "NonExistingProject.refactorlog" })); + + // Cleanup + tempFile.Delete(); + } + [TestMethod] [ValidPropertiesTestData] public void SetProperty_Valid(PropertyInfo property, string value, object expected) @@ -407,7 +455,7 @@ public void SaveToFile() tempFile.Delete(); } - class ValidPropertiesTestDataAttribute : Attribute, ITestDataSource + private class ValidPropertiesTestDataAttribute : Attribute, ITestDataSource { public IEnumerable GetData(MethodInfo methodInfo) { diff --git a/test/TestProjectWithPrePost/RefactorLog/TestProjectWithPrePost.refactorlog b/test/TestProjectWithPrePost/RefactorLog/TestProjectWithPrePost.refactorlog new file mode 100644 index 00000000..581ef82c --- /dev/null +++ b/test/TestProjectWithPrePost/RefactorLog/TestProjectWithPrePost.refactorlog @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From f00f79c5e04f74358286b0d889f85d2665cf9207 Mon Sep 17 00:00:00 2001 From: Demian Marty Date: Wed, 2 Sep 2020 09:04:28 +0200 Subject: [PATCH 2/7] added null-check for RefactorLog argument --- src/DacpacTool/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DacpacTool/Program.cs b/src/DacpacTool/Program.cs index 0b82e5b9..b1bfe135 100644 --- a/src/DacpacTool/Program.cs +++ b/src/DacpacTool/Program.cs @@ -96,7 +96,7 @@ private static int BuildDacpac(BuildOptions options) } // Save the package to disk - packageBuilder.SaveToDisk(options.Output, new PackageOptions() { RefactorLogPath = options.RefactorLog.FullName }); + packageBuilder.SaveToDisk(options.Output, new PackageOptions() { RefactorLogPath = options.RefactorLog?.FullName }); // Add predeployment and postdeployment scripts (must happen after SaveToDisk) packageBuilder.AddPreDeploymentScript(options.PreDeploy, options.Output); From 4d7ee7f886d01ea3c0b244356f20b314950c25f4 Mon Sep 17 00:00:00 2001 From: Demian Marty Date: Wed, 2 Sep 2020 09:18:13 +0200 Subject: [PATCH 3/7] rollback whitespace changes --- src/DacpacTool/PackageBuilder.cs | 1 - src/DacpacTool/Program.cs | 1 + src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets | 14 +++++--------- test/DacpacTool.Tests/PackageBuilderTests.cs | 7 ++----- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/DacpacTool/PackageBuilder.cs b/src/DacpacTool/PackageBuilder.cs index 820f8ff1..76452e6e 100644 --- a/src/DacpacTool/PackageBuilder.cs +++ b/src/DacpacTool/PackageBuilder.cs @@ -108,7 +108,6 @@ public void SaveToDisk(FileInfo outputFile, PackageOptions packageOptions = null EnsureModelCreated(); EnsureModelValidated(); EnsureMetadataCreated(); - // Check if the file already exists if (outputFile.Exists) { diff --git a/src/DacpacTool/Program.cs b/src/DacpacTool/Program.cs index b1bfe135..3431827d 100644 --- a/src/DacpacTool/Program.cs +++ b/src/DacpacTool/Program.cs @@ -132,6 +132,7 @@ private static int DeployDacpac(DeployOptions options) deployer.UseTargetServer(options.TargetServerName); + if (!string.IsNullOrWhiteSpace(options.TargetUser)) { deployer.UseSqlAuthentication(options.TargetUser, options.TargetPassword); diff --git a/src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets b/src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets index 0620c9cf..f5a38e88 100644 --- a/src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets +++ b/src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets @@ -8,7 +8,6 @@ <_IntermediateAssembly Include="@(IntermediateAssembly)" /> @@ -73,7 +71,7 @@ - @@ -109,14 +107,14 @@ location of the package and then checking if a that package contains a .dacpac file inside of the tools folder. --> - + <_ResolvedPackageReference Include="%(PackageReference.Identity)"> @(PackageReference->'%(Identity)'->Replace('.', '_')) $(Pkg%(_ResolvedPackageReference.PackageName)) - @@ -124,7 +122,6 @@ %(_ResolvedPackageReference.PhysicalLocation)/tools/%(Identity).dacpac - @@ -161,7 +158,7 @@ + Condition="'$(DesignTimeBuild)' != 'true' AND '$(BuildingProject)' == 'true'"/> @@ -188,5 +185,4 @@ - diff --git a/test/DacpacTool.Tests/PackageBuilderTests.cs b/test/DacpacTool.Tests/PackageBuilderTests.cs index a47c3297..804f2a50 100644 --- a/test/DacpacTool.Tests/PackageBuilderTests.cs +++ b/test/DacpacTool.Tests/PackageBuilderTests.cs @@ -60,7 +60,7 @@ public void AddReference_FileDoesNotExist() packageBuilder.UsingVersion(SqlServerVersion.Sql150); // Act & Assert - Should.Throw(() => packageBuilder.AddReference(new FileInfo("NonExistentFile.dacpac"))); + Should.Throw(() => packageBuilder.AddReference(new FileInfo("NonExistentFile.dacpac"))); } [TestMethod] @@ -78,7 +78,6 @@ public void AddReference_FileExists() // Assert packageBuilder.Model.GetObject(Procedure.TypeClass, new ObjectIdentifier("dbo", "MyStoredProcedure"), DacQueryScopes.All).ShouldNotBeNull(); - // Cleanup reference.Delete(); } @@ -101,7 +100,6 @@ public void AddSqlCmdvariable() packageBuilder.ValidateModel(); packageBuilder.SaveToDisk(tempFile); var headerParser = new DacpacHeaderParser.HeaderParser(tempFile.FullName); - headerParser.GetCustomData() .Where(d => d.Category == "SqlCmdVariables" && d.Type == "SqlCmdVariable") @@ -185,7 +183,6 @@ public void AddPreDeployment_NoFilePresent() // Assert var package = Package.Open(tempFile.FullName); - package.GetParts() .Where(p => p.Uri == new Uri("/predeploy.sql", UriKind.Relative)) .FirstOrDefault() @@ -455,7 +452,7 @@ public void SaveToFile() tempFile.Delete(); } - private class ValidPropertiesTestDataAttribute : Attribute, ITestDataSource + class ValidPropertiesTestDataAttribute : Attribute, ITestDataSource { public IEnumerable GetData(MethodInfo methodInfo) { From 56a0b5db7eb56441cc2b2b4e2a74d76eb1b9e510 Mon Sep 17 00:00:00 2001 From: Demian Marty Date: Wed, 2 Sep 2020 09:26:18 +0200 Subject: [PATCH 4/7] rollback whitespace changes --- src/DacpacTool/PackageBuilder.cs | 1 + src/DacpacTool/Program.cs | 1 - src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets | 5 +++++ test/DacpacTool.Tests/PackageBuilderTests.cs | 5 +++++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/DacpacTool/PackageBuilder.cs b/src/DacpacTool/PackageBuilder.cs index 76452e6e..820f8ff1 100644 --- a/src/DacpacTool/PackageBuilder.cs +++ b/src/DacpacTool/PackageBuilder.cs @@ -108,6 +108,7 @@ public void SaveToDisk(FileInfo outputFile, PackageOptions packageOptions = null EnsureModelCreated(); EnsureModelValidated(); EnsureMetadataCreated(); + // Check if the file already exists if (outputFile.Exists) { diff --git a/src/DacpacTool/Program.cs b/src/DacpacTool/Program.cs index 3431827d..b1bfe135 100644 --- a/src/DacpacTool/Program.cs +++ b/src/DacpacTool/Program.cs @@ -132,7 +132,6 @@ private static int DeployDacpac(DeployOptions options) deployer.UseTargetServer(options.TargetServerName); - if (!string.IsNullOrWhiteSpace(options.TargetUser)) { deployer.UseSqlAuthentication(options.TargetUser, options.TargetPassword); diff --git a/src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets b/src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets index f5a38e88..83a327d7 100644 --- a/src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets +++ b/src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets @@ -8,6 +8,7 @@ <_IntermediateAssembly Include="@(IntermediateAssembly)" /> @@ -74,6 +76,7 @@ + @@ -122,6 +125,7 @@ %(_ResolvedPackageReference.PhysicalLocation)/tools/%(Identity).dacpac + @@ -185,4 +189,5 @@ + diff --git a/test/DacpacTool.Tests/PackageBuilderTests.cs b/test/DacpacTool.Tests/PackageBuilderTests.cs index 804f2a50..dd27a794 100644 --- a/test/DacpacTool.Tests/PackageBuilderTests.cs +++ b/test/DacpacTool.Tests/PackageBuilderTests.cs @@ -78,6 +78,7 @@ public void AddReference_FileExists() // Assert packageBuilder.Model.GetObject(Procedure.TypeClass, new ObjectIdentifier("dbo", "MyStoredProcedure"), DacQueryScopes.All).ShouldNotBeNull(); + // Cleanup reference.Delete(); } @@ -100,6 +101,7 @@ public void AddSqlCmdvariable() packageBuilder.ValidateModel(); packageBuilder.SaveToDisk(tempFile); var headerParser = new DacpacHeaderParser.HeaderParser(tempFile.FullName); + headerParser.GetCustomData() .Where(d => d.Category == "SqlCmdVariables" && d.Type == "SqlCmdVariable") @@ -183,6 +185,7 @@ public void AddPreDeployment_NoFilePresent() // Assert var package = Package.Open(tempFile.FullName); + package.GetParts() .Where(p => p.Uri == new Uri("/predeploy.sql", UriKind.Relative)) .FirstOrDefault() @@ -262,6 +265,7 @@ public void AddPreDeployment_WrongOrder() packageBuilder.SetMetadata("MyPackage", "1.0.0.0"); packageBuilder.UsingVersion(SqlServerVersion.Sql150); + // Act & Assert Should.Throw(() => packageBuilder.AddPreDeploymentScript(null, tempFile)); } @@ -275,6 +279,7 @@ public void AddPostDeployment_WrongOrder() packageBuilder.SetMetadata("MyPackage", "1.0.0.0"); packageBuilder.UsingVersion(SqlServerVersion.Sql150); + // Act & Assert Should.Throw(() => packageBuilder.AddPostDeploymentScript(null, tempFile)); } From 083020763ea7fa1f7ac46bdc07d50310bf8afd86 Mon Sep 17 00:00:00 2001 From: Demian Marty Date: Wed, 2 Sep 2020 09:32:00 +0200 Subject: [PATCH 5/7] rollback whitespace changes --- src/DacpacTool/PackageBuilder.cs | 2 +- src/DacpacTool/Program.cs | 2 +- src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets | 8 ++++---- test/DacpacTool.Tests/PackageBuilderTests.cs | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/DacpacTool/PackageBuilder.cs b/src/DacpacTool/PackageBuilder.cs index 820f8ff1..109068e0 100644 --- a/src/DacpacTool/PackageBuilder.cs +++ b/src/DacpacTool/PackageBuilder.cs @@ -108,7 +108,7 @@ public void SaveToDisk(FileInfo outputFile, PackageOptions packageOptions = null EnsureModelCreated(); EnsureModelValidated(); EnsureMetadataCreated(); - + // Check if the file already exists if (outputFile.Exists) { diff --git a/src/DacpacTool/Program.cs b/src/DacpacTool/Program.cs index b1bfe135..30dca15f 100644 --- a/src/DacpacTool/Program.cs +++ b/src/DacpacTool/Program.cs @@ -131,7 +131,7 @@ private static int DeployDacpac(DeployOptions options) } deployer.UseTargetServer(options.TargetServerName); - + if (!string.IsNullOrWhiteSpace(options.TargetUser)) { deployer.UseSqlAuthentication(options.TargetUser, options.TargetPassword); diff --git a/src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets b/src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets index 83a327d7..978eb724 100644 --- a/src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets +++ b/src/MSBuild.Sdk.SqlProj/Sdk/Sdk.targets @@ -8,7 +8,7 @@ <_IntermediateAssembly Include="@(IntermediateAssembly)" /> @@ -125,7 +125,7 @@ %(_ResolvedPackageReference.PhysicalLocation)/tools/%(Identity).dacpac - + @@ -189,5 +189,5 @@ - + diff --git a/test/DacpacTool.Tests/PackageBuilderTests.cs b/test/DacpacTool.Tests/PackageBuilderTests.cs index dd27a794..1559fe3c 100644 --- a/test/DacpacTool.Tests/PackageBuilderTests.cs +++ b/test/DacpacTool.Tests/PackageBuilderTests.cs @@ -78,7 +78,7 @@ public void AddReference_FileExists() // Assert packageBuilder.Model.GetObject(Procedure.TypeClass, new ObjectIdentifier("dbo", "MyStoredProcedure"), DacQueryScopes.All).ShouldNotBeNull(); - + // Cleanup reference.Delete(); } @@ -101,7 +101,7 @@ public void AddSqlCmdvariable() packageBuilder.ValidateModel(); packageBuilder.SaveToDisk(tempFile); var headerParser = new DacpacHeaderParser.HeaderParser(tempFile.FullName); - + headerParser.GetCustomData() .Where(d => d.Category == "SqlCmdVariables" && d.Type == "SqlCmdVariable") @@ -185,7 +185,7 @@ public void AddPreDeployment_NoFilePresent() // Assert var package = Package.Open(tempFile.FullName); - + package.GetParts() .Where(p => p.Uri == new Uri("/predeploy.sql", UriKind.Relative)) .FirstOrDefault() From 506139cdd079e7fc58ee1e00dce21ff994404ede Mon Sep 17 00:00:00 2001 From: Demian Marty Date: Wed, 2 Sep 2020 09:33:41 +0200 Subject: [PATCH 6/7] rollback whitespace changes --- test/DacpacTool.Tests/PackageBuilderTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/DacpacTool.Tests/PackageBuilderTests.cs b/test/DacpacTool.Tests/PackageBuilderTests.cs index 1559fe3c..2264bc5a 100644 --- a/test/DacpacTool.Tests/PackageBuilderTests.cs +++ b/test/DacpacTool.Tests/PackageBuilderTests.cs @@ -146,7 +146,7 @@ public void AddPreDeployment_FilesExist() // Assert var package = Package.Open(tempFile.FullName); - var prePart = package.GetPart(new Uri("/predeploy.sql", UriKind.Relative)); + var prePart = package.GetPart(new Uri("/predeploy.sql", UriKind.Relative)); var postPart = package.GetPart(new Uri("/postdeploy.sql", UriKind.Relative)); var refactorPart = package.GetPart(new Uri("/refactor.xml", UriKind.Relative)); From 5a7dadf1f758fa96888300fbb9ffa92e1aded0c5 Mon Sep 17 00:00:00 2001 From: Demian Marty Date: Wed, 2 Sep 2020 09:37:34 +0200 Subject: [PATCH 7/7] add RefactorLog to ItemGroup in test project --- test/TestProjectWithPrePost/TestProjectWithPrePost.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/test/TestProjectWithPrePost/TestProjectWithPrePost.csproj b/test/TestProjectWithPrePost/TestProjectWithPrePost.csproj index c7fb40f5..929584bb 100644 --- a/test/TestProjectWithPrePost/TestProjectWithPrePost.csproj +++ b/test/TestProjectWithPrePost/TestProjectWithPrePost.csproj @@ -14,6 +14,7 @@ +