Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ node_modules/
.idea/

# vscode python env files
.env
.env.nuget/nuget.exe
17 changes: 15 additions & 2 deletions eng/common/SetupNugetSources.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# This script adds internal feeds required to build commits that depend on internal package sources. For instance,
# dotnet6-internal would be added automatically if dotnet6 was found in the nuget.config file. In addition also enables
# disabled internal Maestro (darc-int*) feeds.
# dotnet6-internal would be added automatically if dotnet6 was found in the nuget.config file. Similarly,
# dotnet-eng-internal and dotnet-tools-internal are added if dotnet-eng and dotnet-tools are present.
# In addition, this script also enables disabled internal Maestro (darc-int*) feeds.
#
# Optionally, this script also adds a credential entry for each of the internal feeds if supplied.
#
Expand Down Expand Up @@ -173,4 +174,16 @@ foreach ($dotnetVersion in $dotnetVersions) {
}
}

# Check for dotnet-eng and add dotnet-eng-internal if present
$dotnetEngSource = $sources.SelectSingleNode("add[@key='dotnet-eng']")
if ($dotnetEngSource -ne $null) {
AddOrEnablePackageSource -Sources $sources -DisabledPackageSources $disabledSources -SourceName "dotnet-eng-internal" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-eng-internal/nuget/$feedSuffix" -Creds $creds -Username $userName -pwd $Password
}

# Check for dotnet-tools and add dotnet-tools-internal if present
$dotnetToolsSource = $sources.SelectSingleNode("add[@key='dotnet-tools']")
if ($dotnetToolsSource -ne $null) {
AddOrEnablePackageSource -Sources $sources -DisabledPackageSources $disabledSources -SourceName "dotnet-tools-internal" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-tools-internal/nuget/$feedSuffix" -Creds $creds -Username $userName -pwd $Password
}

$doc.Save($filename)
17 changes: 15 additions & 2 deletions eng/common/SetupNugetSources.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env bash

# This script adds internal feeds required to build commits that depend on internal package sources. For instance,
# dotnet6-internal would be added automatically if dotnet6 was found in the nuget.config file. In addition also enables
# disabled internal Maestro (darc-int*) feeds.
# dotnet6-internal would be added automatically if dotnet6 was found in the nuget.config file. Similarly,
# dotnet-eng-internal and dotnet-tools-internal are added if dotnet-eng and dotnet-tools are present.
# In addition, this script also enables disabled internal Maestro (darc-int*) feeds.
#
# Optionally, this script also adds a credential entry for each of the internal feeds if supplied.
#
Expand Down Expand Up @@ -173,6 +174,18 @@ for DotNetVersion in ${DotNetVersions[@]} ; do
fi
done

# Check for dotnet-eng and add dotnet-eng-internal if present
grep -i "<add key=\"dotnet-eng\"" $ConfigFile > /dev/null
if [ "$?" == "0" ]; then
AddOrEnablePackageSource "dotnet-eng-internal" "https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-eng-internal/nuget/$FeedSuffix"
fi

# Check for dotnet-tools and add dotnet-tools-internal if present
grep -i "<add key=\"dotnet-tools\"" $ConfigFile > /dev/null
if [ "$?" == "0" ]; then
AddOrEnablePackageSource "dotnet-tools-internal" "https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-tools-internal/nuget/$FeedSuffix"
fi

# I want things split line by line
PrevIFS=$IFS
IFS=$'\n'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,129 @@ public async Task ConfigWithExistingInternalFeed_DoesNotDuplicate()
// Should have 4 total sources (3 original + 1 added transport)
modifiedConfig.GetPackageSourceCount().Should().Be(4, "should not duplicate existing sources");
}

[Fact]
public async Task ConfigWithDotNetEng_AddsDotNetEngInternal()
{
// Arrange
var originalConfig = @"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
<packageSources>
<add key=""dotnet-public"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json"" />
<add key=""dotnet-eng"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json"" />
</packageSources>
</configuration>";
var configPath = Path.Combine(_testOutputDirectory, "nuget.config");
await Task.Run(() => File.WriteAllText(configPath, originalConfig));

// Act
var result = await _scriptRunner.RunScript(configPath);

// Assert
result.exitCode.Should().Be(0, "Script should succeed, but got error: {0}", result.error);
var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath));

modifiedConfig.ShouldContainPackageSource("dotnet-eng-internal",
"https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-eng-internal/nuget/v3/index.json",
"should add dotnet-eng-internal feed");

// Should have 3 total sources (2 original + 1 added internal)
modifiedConfig.GetPackageSourceCount().Should().Be(3, "should add internal feed");
}

[Fact]
public async Task ConfigWithDotNetTools_AddsDotNetToolsInternal()
{
// Arrange
var originalConfig = @"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
<packageSources>
<add key=""dotnet-public"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json"" />
<add key=""dotnet-tools"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json"" />
</packageSources>
</configuration>";
var configPath = Path.Combine(_testOutputDirectory, "nuget.config");
await Task.Run(() => File.WriteAllText(configPath, originalConfig));

// Act
var result = await _scriptRunner.RunScript(configPath);

// Assert
result.exitCode.Should().Be(0, "Script should succeed, but got error: {0}", result.error);
var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath));

modifiedConfig.ShouldContainPackageSource("dotnet-tools-internal",
"https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-tools-internal/nuget/v3/index.json",
"should add dotnet-tools-internal feed");

// Should have 3 total sources (2 original + 1 added internal)
modifiedConfig.GetPackageSourceCount().Should().Be(3, "should add internal feed");
}

[Fact]
public async Task ConfigWithDotNetEngAndTools_AddsBothInternalFeeds()
{
// Arrange
var originalConfig = @"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
<packageSources>
<add key=""dotnet-public"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json"" />
<add key=""dotnet-eng"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json"" />
<add key=""dotnet-tools"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json"" />
</packageSources>
</configuration>";
var configPath = Path.Combine(_testOutputDirectory, "nuget.config");
await Task.Run(() => File.WriteAllText(configPath, originalConfig));

// Act
var result = await _scriptRunner.RunScript(configPath);

// Assert
result.exitCode.Should().Be(0, "Script should succeed, but got error: {0}", result.error);
var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath));

modifiedConfig.ShouldContainPackageSource("dotnet-eng-internal",
"https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-eng-internal/nuget/v3/index.json",
"should add dotnet-eng-internal feed");

modifiedConfig.ShouldContainPackageSource("dotnet-tools-internal",
"https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-tools-internal/nuget/v3/index.json",
"should add dotnet-tools-internal feed");

// Should have 5 total sources (3 original + 2 added internal)
modifiedConfig.GetPackageSourceCount().Should().Be(5, "should add both internal feeds");
}

[Fact]
public async Task ConfigWithoutDotNetEngOrTools_DoesNotAddInternalFeeds()
{
// Arrange
var originalConfig = @"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
<packageSources>
<add key=""dotnet-public"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json"" />
<add key=""dotnet9"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json"" />
</packageSources>
</configuration>";
var configPath = Path.Combine(_testOutputDirectory, "nuget.config");
await Task.Run(() => File.WriteAllText(configPath, originalConfig));

// Act
var result = await _scriptRunner.RunScript(configPath);

// Assert
result.exitCode.Should().Be(0, "Script should succeed, but got error: {0}", result.error);
var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath));

modifiedConfig.ShouldNotContainPackageSource("dotnet-eng-internal",
"should not add dotnet-eng-internal when dotnet-eng is not present");
modifiedConfig.ShouldNotContainPackageSource("dotnet-tools-internal",
"should not add dotnet-tools-internal when dotnet-tools is not present");

// Should add dotnet9 internal feeds
modifiedConfig.ShouldContainPackageSource("dotnet9-internal");
modifiedConfig.ShouldContainPackageSource("dotnet9-internal-transport");
}
}
}

Expand Down
Loading