Skip to content

Commit

Permalink
[tests] fix duplicate sources in NuGet.config (#8772)
Browse files Browse the repository at this point in the history
Context: NuGet/Home#13269 (comment)

In 2f4e01e, we saw a problem with no-op NuGet restore, no longer
being a no-op. So we temporarily disabled the failing
`IncrementalFastDeployment` test.

It turns out, it might be related to a duplicate source listed in our
`NuGet.config` during MSBuild tests:

    <add key="dotnet8" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json" />
    <add key="testsource2" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json" />

This might have surfaced a bug in NuGet, but for now let's stop
emitting duplicate sources?

Additionally, use `ExtraNuGetConfigSources.Distinct ()` in case we have a test
that passes in duplicate sources.
  • Loading branch information
jonathanpeppers authored Feb 29, 2024
1 parent 0d489b1 commit e873731
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ public void CopyNuGetConfig (string relativeDirectory)

/// <summary>
/// Updates a NuGet.config based on sources in ExtraNuGetConfigSources
/// If target framework is not the latest or default, sources are added for previous releases
/// </summary>
protected void AddNuGetConfigSources (string nugetConfigPath)
{
Expand All @@ -415,14 +414,8 @@ protected void AddNuGetConfigSources (string nugetConfigPath)
ExtraNuGetConfigSources = new List<string> ();
}

if (TargetFramework?.IndexOf ("net8.0", StringComparison.OrdinalIgnoreCase) != -1
|| TargetFrameworks?.IndexOf ("net8.0", StringComparison.OrdinalIgnoreCase) != -1) {
ExtraNuGetConfigSources.Add ("https://api.nuget.org/v3/index.json");
ExtraNuGetConfigSources.Add ("https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json");
}

int sourceIndex = 0;
foreach (var source in ExtraNuGetConfigSources) {
foreach (var source in ExtraNuGetConfigSources.Distinct ()) {
var sourceElement = new XElement ("add");
sourceElement.SetAttributeValue ("key", $"testsource{++sourceIndex}");
sourceElement.SetAttributeValue ("value", source);
Expand Down
1 change: 0 additions & 1 deletion tests/MSBuildDeviceIntegration/Tests/InstallTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ public void LocalizedAssemblies_ShouldBeFastDeployed ()
[Test]
public void IncrementalFastDeployment ()
{
Assert.Ignore ("https://github.com/NuGet/Home/issues/13269");
AssertCommercialBuild ();

var class1src = new BuildItem.Source ("Class1.cs") {
Expand Down

0 comments on commit e873731

Please sign in to comment.