diff --git a/src/Microsoft.Build.Sql/sdk/Sdk.props b/src/Microsoft.Build.Sql/sdk/Sdk.props
index 5e70888..ca286c5 100644
--- a/src/Microsoft.Build.Sql/sdk/Sdk.props
+++ b/src/Microsoft.Build.Sql/sdk/Sdk.props
@@ -9,6 +9,7 @@
true
false
$(MSBuildThisFileDirectory)..\tools\netstandard2.1
+ netstandard2.1
diff --git a/src/Microsoft.Build.Sql/sdk/Sdk.targets b/src/Microsoft.Build.Sql/sdk/Sdk.targets
index aa8e616..827335e 100644
--- a/src/Microsoft.Build.Sql/sdk/Sdk.targets
+++ b/src/Microsoft.Build.Sql/sdk/Sdk.targets
@@ -22,6 +22,7 @@
+
diff --git a/test/Microsoft.Build.Sql.Tests/BuildTests.cs b/test/Microsoft.Build.Sql.Tests/BuildTests.cs
index 68a4065..1a240bd 100644
--- a/test/Microsoft.Build.Sql.Tests/BuildTests.cs
+++ b/test/Microsoft.Build.Sql.Tests/BuildTests.cs
@@ -224,5 +224,67 @@ public void VerifyBuildWithCentralPackageManagement()
Assert.AreEqual(string.Empty, stdError);
this.VerifyDacPackage();
}
+
+ [Test]
+ // https://github.com/microsoft/DacFx/issues/278
+ public void VerifyBuildWithTransitiveProjectReferences()
+ {
+ string projectA = Path.Combine(WorkingDirectory, "A", "A.sqlproj");
+ string projectB = Path.Combine(WorkingDirectory, "B", "B.sqlproj");
+
+ // Add A.sqlproj as a reference in B.sqlproj
+ ProjectUtils.AddItemGroup(projectB, "ProjectReference", new string[] { projectA });
+
+ // Add B.sqlproj as a reference in the main project
+ this.AddProjectReference(projectB);
+
+ // Build and verify a.dacpac is copied to the output directory
+ int exitCode = this.RunDotnetCommandOnProject("build", out string stdOutput, out string stdError);
+ Assert.AreEqual(0, exitCode, "Build failed with error " + stdError);
+ Assert.AreEqual(string.Empty, stdError);
+ this.VerifyDacPackage();
+ FileAssert.Exists(Path.Combine(this.GetOutputDirectory(), "A.dacpac"));
+ FileAssert.Exists(Path.Combine(this.GetOutputDirectory(), "B.dacpac"));
+ }
+
+ [Test]
+ [TestCase("net46")]
+ [TestCase("net461")]
+ [TestCase("net462")]
+ [TestCase("net47")]
+ [TestCase("net471")]
+ [TestCase("net472")]
+ [TestCase("net48")]
+ [TestCase("net481")]
+ [TestCase("netstandard2.1")]
+ [TestCase("netcoreapp3.1")]
+#if NET5_0_OR_GREATER
+ [TestCase("net5.0")]
+#endif
+#if NET6_0_OR_GREATER
+ [TestCase("net6.0")]
+#endif
+#if NET7_0_OR_GREATER
+ [TestCase("net7.0")]
+#endif
+#if NET8_0_OR_GREATER
+ [TestCase("net8.0")]
+#endif
+ // https://github.com/microsoft/DacFx/issues/330
+ public void VerifyBuildWithDifferentTargetFrameworks(string targetFramework)
+ {
+
+ ProjectUtils.AddProperties(this.GetProjectFilePath(), new Dictionary()
+ {
+ { "TargetFramework", targetFramework }
+ });
+
+ int exitCode = this.RunDotnetCommandOnProject("build", out string stdOutput, out string stdError);
+
+ // Verify success
+ Assert.AreEqual(0, exitCode, "Build failed with error " + stdError);
+ Assert.AreEqual(string.Empty, stdError);
+ this.VerifyDacPackage();
+ }
}
}
\ No newline at end of file
diff --git a/test/Microsoft.Build.Sql.Tests/DotnetTestBase.cs b/test/Microsoft.Build.Sql.Tests/DotnetTestBase.cs
index 59c7069..7af9b19 100644
--- a/test/Microsoft.Build.Sql.Tests/DotnetTestBase.cs
+++ b/test/Microsoft.Build.Sql.Tests/DotnetTestBase.cs
@@ -23,7 +23,7 @@ public abstract class DotnetTestBase
protected string WorkingDirectory
{
- get { return Path.Combine(TestContext.CurrentContext.WorkDirectory, TestContext.CurrentContext.Test.Name); }
+ get { return Path.Combine(TestContext.CurrentContext.WorkDirectory, TestUtils.EscapeTestName(TestContext.CurrentContext.Test.Name)); }
}
protected string CommonTestDataDirectory
@@ -33,7 +33,7 @@ protected string CommonTestDataDirectory
protected string CurrentTestDataDirectory
{
- get { return Path.Combine(this.CommonTestDataDirectory, TestContext.CurrentContext.Test.Name); }
+ get { return Path.Combine(this.CommonTestDataDirectory, TestUtils.EscapeTestName(TestContext.CurrentContext.Test.Name)); }
}
[SetUp]
diff --git a/test/Microsoft.Build.Sql.Tests/TestData/VerifyBuildWithTransitiveProjectReferences/A/A.sqlproj b/test/Microsoft.Build.Sql.Tests/TestData/VerifyBuildWithTransitiveProjectReferences/A/A.sqlproj
new file mode 100644
index 0000000..4529d8d
--- /dev/null
+++ b/test/Microsoft.Build.Sql.Tests/TestData/VerifyBuildWithTransitiveProjectReferences/A/A.sqlproj
@@ -0,0 +1,9 @@
+
+
+
+
+ A
+ Microsoft.Data.Tools.Schema.Sql.Sql150DatabaseSchemaProvider
+ 1033, CI
+
+
\ No newline at end of file
diff --git a/test/Microsoft.Build.Sql.Tests/TestData/VerifyBuildWithTransitiveProjectReferences/B/B.sqlproj b/test/Microsoft.Build.Sql.Tests/TestData/VerifyBuildWithTransitiveProjectReferences/B/B.sqlproj
new file mode 100644
index 0000000..5d66c97
--- /dev/null
+++ b/test/Microsoft.Build.Sql.Tests/TestData/VerifyBuildWithTransitiveProjectReferences/B/B.sqlproj
@@ -0,0 +1,9 @@
+
+
+
+
+ B
+ Microsoft.Data.Tools.Schema.Sql.Sql150DatabaseSchemaProvider
+ 1033, CI
+
+
\ No newline at end of file
diff --git a/test/Microsoft.Build.Sql.Tests/TestUtils.cs b/test/Microsoft.Build.Sql.Tests/TestUtils.cs
index ee858c7..b9b6c42 100644
--- a/test/Microsoft.Build.Sql.Tests/TestUtils.cs
+++ b/test/Microsoft.Build.Sql.Tests/TestUtils.cs
@@ -73,5 +73,10 @@ public static void CopyDirectoryRecursive(string sourceDirectoryPath, string tar
CopyDirectoryRecursive(subDir.FullName, destDirName);
}
}
+
+ public static string EscapeTestName(string testName)
+ {
+ return testName.Replace("\"", "_");
+ }
}
}