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