From eadc806ca3004aea68175d882e5608f4406a571e Mon Sep 17 00:00:00 2001 From: Z Chen <13544267+zijchen@users.noreply.github.com> Date: Fri, 26 Jul 2024 17:16:55 -0700 Subject: [PATCH] Remove local testing source from nuget.config (#470) --- test/Microsoft.Build.Sql.Tests/DotnetTestBase.cs | 14 +++++++++++++- .../Template/nuget.config | 6 ------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/test/Microsoft.Build.Sql.Tests/DotnetTestBase.cs b/test/Microsoft.Build.Sql.Tests/DotnetTestBase.cs index e077a72..d2d1e80 100644 --- a/test/Microsoft.Build.Sql.Tests/DotnetTestBase.cs +++ b/test/Microsoft.Build.Sql.Tests/DotnetTestBase.cs @@ -47,6 +47,13 @@ public void TestTearDown() { try { + // Remove local nuget source + RunGenericDotnetCommand($"nuget remove source TestSource_{TestContext.CurrentContext.Test.Name}", out _, out string stdError); + if (!string.IsNullOrEmpty(stdError)) + { + Assert.Warn("Failed to remove local nuget source: " + stdError); + } + // Delete working directory unless test failed if (TestContext.CurrentContext.Result.Outcome == ResultState.Success && Directory.Exists(this.WorkingDirectory)) { @@ -78,7 +85,8 @@ protected void EnvironmentSetup() } // Copy SDK nuget package to Workingdirectory/pkg/ - TestUtils.CopyDirectoryRecursive("../../../pkg", Path.Combine(this.WorkingDirectory, "pkg")); + string localNugetSource = Path.Combine(this.WorkingDirectory, "pkg"); + TestUtils.CopyDirectoryRecursive("../../../pkg", localNugetSource); // Copy common project files from Template to WorkingDirectory TestUtils.CopyDirectoryRecursive("../../../Template", this.WorkingDirectory); @@ -88,6 +96,10 @@ protected void EnvironmentSetup() { TestUtils.CopyDirectoryRecursive(this.CurrentTestDataDirectory, this.WorkingDirectory); } + + // Add pkg folder as a nuget source + RunGenericDotnetCommand($"nuget add source \"{localNugetSource}\" --name TestSource_{TestContext.CurrentContext.Test.Name}", out _, out string stdError); + Assert.AreEqual("", stdError, "Failed to add local nuget source: " + stdError); } /// diff --git a/test/Microsoft.Build.Sql.Tests/Template/nuget.config b/test/Microsoft.Build.Sql.Tests/Template/nuget.config index fef809b..9f550ad 100644 --- a/test/Microsoft.Build.Sql.Tests/Template/nuget.config +++ b/test/Microsoft.Build.Sql.Tests/Template/nuget.config @@ -5,10 +5,4 @@ - - - - - - \ No newline at end of file