Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove local testing source from nuget.config #470

Merged
merged 1 commit into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
zijchen marked this conversation as resolved.
Show resolved Hide resolved
}

/// <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>