diff --git a/src/Microsoft.Build.Sql/sdk/Sdk.props b/src/Microsoft.Build.Sql/sdk/Sdk.props index 3d28649..ce8586a 100644 --- a/src/Microsoft.Build.Sql/sdk/Sdk.props +++ b/src/Microsoft.Build.Sql/sdk/Sdk.props @@ -100,6 +100,9 @@ $(Platform) Database + + {42EA0DBD-9CF1-443E-919E-BE9C484E4577} + True diff --git a/test/Microsoft.Build.Sql.Tests/BuildTests.cs b/test/Microsoft.Build.Sql.Tests/BuildTests.cs index 946a9e8..424b2fa 100644 --- a/test/Microsoft.Build.Sql.Tests/BuildTests.cs +++ b/test/Microsoft.Build.Sql.Tests/BuildTests.cs @@ -500,5 +500,65 @@ public void VersionCheckTest() this.VerifyDacPackage(); FileAssert.Exists(NuGetClient.GetVersionCacheFilePath("Microsoft.Build.Sql"), "Version cache file should exist after fetching the version."); } + +#if !NETFRAMEWORK + [Test] + [Description("Verifies that a SQL project can be added to a .sln solution and built via dotnet sln add.")] + public void VerifySolutionAddAndBuild() + { + // Create a new solution + int exitCode = this.RunGenericDotnetCommand("new sln -n SDKTestSolution --format sln", out string stdOutput, out string stdError); + Assert.AreEqual(0, exitCode, "Solution creation failed with error " + stdError); + Assert.AreEqual(string.Empty, stdError); + + // Add the existing test project to the solution + string projectPath = Path.GetFileName(this.GetProjectFilePath()); + exitCode = this.RunGenericDotnetCommand($"sln SDKTestSolution.sln add {projectPath}", out stdOutput, out stdError); + Assert.AreEqual(0, exitCode, "Adding project to solution failed with error " + stdError); + Assert.AreEqual(string.Empty, stdError); + StringAssert.Contains("added to the solution", stdOutput, "Expected success message not found."); + + // Verify the solution file contains our project + string slnContent = File.ReadAllText(Path.Combine(this.WorkingDirectory, "SDKTestSolution.sln")); + StringAssert.Contains(".sqlproj", slnContent, "Project not found in solution file."); + + // Build the solution + exitCode = this.RunGenericDotnetCommand("build SDKTestSolution.sln --verbosity normal", out stdOutput, out stdError); + Assert.AreEqual(0, exitCode, "Solution build failed with error " + stdError); + Assert.AreEqual(string.Empty, stdError); + + // Verify dacpac was created + this.VerifyDacPackage(); + } + + [Test] + [Description("Verifies that a SQL project can be added to a .slnx solution and built via dotnet sln add.")] + public void VerifySolutionAddAndBuildSlnx() + { + // Create a new solution using slnx format + int exitCode = this.RunGenericDotnetCommand("new sln -n SDKTestSolution --format slnx", out string stdOutput, out string stdError); + Assert.AreEqual(0, exitCode, "Solution creation failed with error " + stdError); + Assert.AreEqual(string.Empty, stdError); + + // Add the existing test project to the solution + string projectPath = Path.GetFileName(this.GetProjectFilePath()); + exitCode = this.RunGenericDotnetCommand($"sln SDKTestSolution.slnx add {projectPath}", out stdOutput, out stdError); + Assert.AreEqual(0, exitCode, "Adding project to solution failed with error " + stdError); + Assert.AreEqual(string.Empty, stdError); + StringAssert.Contains("added to the solution", stdOutput, "Expected success message not found."); + + // Verify the solution file contains our project + string slnxContent = File.ReadAllText(Path.Combine(this.WorkingDirectory, "SDKTestSolution.slnx")); + StringAssert.Contains(".sqlproj", slnxContent, "Project not found in solution file."); + + // Build the solution + exitCode = this.RunGenericDotnetCommand("build SDKTestSolution.slnx --verbosity normal", out stdOutput, out stdError); + Assert.AreEqual(0, exitCode, "Solution build failed with error " + stdError); + Assert.AreEqual(string.Empty, stdError); + + // Verify dacpac was created + this.VerifyDacPackage(); + } +#endif } } \ No newline at end of file