Skip to content

Commit

Permalink
Remove local testing source from nuget.config (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
zijchen authored Jul 27, 2024
1 parent 96898f6 commit eadc806
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
14 changes: 13 additions & 1 deletion test/Microsoft.Build.Sql.Tests/DotnetTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}

/// <summary>
Expand Down
6 changes: 0 additions & 6 deletions test/Microsoft.Build.Sql.Tests/Template/nuget.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,4 @@
<!-- Overrides default Nuget cache folder to make sure we are using the correct package. -->
<add key="globalPackagesFolder" value="./pkg/cache" />
</config>
<packageSources>
<!-- Clear all global package sources and only use local one for testing. -->
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="local" value="./pkg" />
</packageSources>
</configuration>

0 comments on commit eadc806

Please sign in to comment.