Skip to content

Commit fb1799f

Browse files
Copilotmmitche
andauthored
Add support for dotnet-eng-internal and dotnet-tools-internal feeds in SetupNuGetSources scripts (#16246)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: mmitche <[email protected]>
1 parent 63eed29 commit fb1799f

File tree

3 files changed

+153
-4
lines changed

3 files changed

+153
-4
lines changed

eng/common/SetupNugetSources.ps1

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This script adds internal feeds required to build commits that depend on internal package sources. For instance,
2-
# dotnet6-internal would be added automatically if dotnet6 was found in the nuget.config file. In addition also enables
3-
# disabled internal Maestro (darc-int*) feeds.
2+
# dotnet6-internal would be added automatically if dotnet6 was found in the nuget.config file. Similarly,
3+
# dotnet-eng-internal and dotnet-tools-internal are added if dotnet-eng and dotnet-tools are present.
4+
# In addition, this script also enables disabled internal Maestro (darc-int*) feeds.
45
#
56
# Optionally, this script also adds a credential entry for each of the internal feeds if supplied.
67
#
@@ -173,4 +174,16 @@ foreach ($dotnetVersion in $dotnetVersions) {
173174
}
174175
}
175176

177+
# Check for dotnet-eng and add dotnet-eng-internal if present
178+
$dotnetEngSource = $sources.SelectSingleNode("add[@key='dotnet-eng']")
179+
if ($dotnetEngSource -ne $null) {
180+
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
181+
}
182+
183+
# Check for dotnet-tools and add dotnet-tools-internal if present
184+
$dotnetToolsSource = $sources.SelectSingleNode("add[@key='dotnet-tools']")
185+
if ($dotnetToolsSource -ne $null) {
186+
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
187+
}
188+
176189
$doc.Save($filename)

eng/common/SetupNugetSources.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/usr/bin/env bash
22

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

177+
# Check for dotnet-eng and add dotnet-eng-internal if present
178+
grep -i "<add key=\"dotnet-eng\"" $ConfigFile > /dev/null
179+
if [ "$?" == "0" ]; then
180+
AddOrEnablePackageSource "dotnet-eng-internal" "https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-eng-internal/nuget/$FeedSuffix"
181+
fi
182+
183+
# Check for dotnet-tools and add dotnet-tools-internal if present
184+
grep -i "<add key=\"dotnet-tools\"" $ConfigFile > /dev/null
185+
if [ "$?" == "0" ]; then
186+
AddOrEnablePackageSource "dotnet-tools-internal" "https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-tools-internal/nuget/$FeedSuffix"
187+
fi
188+
176189
# I want things split line by line
177190
PrevIFS=$IFS
178191
IFS=$'\n'

src/Microsoft.DotNet.SetupNugetSources.Tests/InternalFeedAdditionTests.cs

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,129 @@ public async Task ConfigWithExistingInternalFeed_DoesNotDuplicate()
143143
// Should have 4 total sources (3 original + 1 added transport)
144144
modifiedConfig.GetPackageSourceCount().Should().Be(4, "should not duplicate existing sources");
145145
}
146+
147+
[Fact]
148+
public async Task ConfigWithDotNetEng_AddsDotNetEngInternal()
149+
{
150+
// Arrange
151+
var originalConfig = @"<?xml version=""1.0"" encoding=""utf-8""?>
152+
<configuration>
153+
<packageSources>
154+
<add key=""dotnet-public"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json"" />
155+
<add key=""dotnet-eng"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json"" />
156+
</packageSources>
157+
</configuration>";
158+
var configPath = Path.Combine(_testOutputDirectory, "nuget.config");
159+
await Task.Run(() => File.WriteAllText(configPath, originalConfig));
160+
161+
// Act
162+
var result = await _scriptRunner.RunScript(configPath);
163+
164+
// Assert
165+
result.exitCode.Should().Be(0, "Script should succeed, but got error: {0}", result.error);
166+
var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath));
167+
168+
modifiedConfig.ShouldContainPackageSource("dotnet-eng-internal",
169+
"https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-eng-internal/nuget/v3/index.json",
170+
"should add dotnet-eng-internal feed");
171+
172+
// Should have 3 total sources (2 original + 1 added internal)
173+
modifiedConfig.GetPackageSourceCount().Should().Be(3, "should add internal feed");
174+
}
175+
176+
[Fact]
177+
public async Task ConfigWithDotNetTools_AddsDotNetToolsInternal()
178+
{
179+
// Arrange
180+
var originalConfig = @"<?xml version=""1.0"" encoding=""utf-8""?>
181+
<configuration>
182+
<packageSources>
183+
<add key=""dotnet-public"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json"" />
184+
<add key=""dotnet-tools"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json"" />
185+
</packageSources>
186+
</configuration>";
187+
var configPath = Path.Combine(_testOutputDirectory, "nuget.config");
188+
await Task.Run(() => File.WriteAllText(configPath, originalConfig));
189+
190+
// Act
191+
var result = await _scriptRunner.RunScript(configPath);
192+
193+
// Assert
194+
result.exitCode.Should().Be(0, "Script should succeed, but got error: {0}", result.error);
195+
var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath));
196+
197+
modifiedConfig.ShouldContainPackageSource("dotnet-tools-internal",
198+
"https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-tools-internal/nuget/v3/index.json",
199+
"should add dotnet-tools-internal feed");
200+
201+
// Should have 3 total sources (2 original + 1 added internal)
202+
modifiedConfig.GetPackageSourceCount().Should().Be(3, "should add internal feed");
203+
}
204+
205+
[Fact]
206+
public async Task ConfigWithDotNetEngAndTools_AddsBothInternalFeeds()
207+
{
208+
// Arrange
209+
var originalConfig = @"<?xml version=""1.0"" encoding=""utf-8""?>
210+
<configuration>
211+
<packageSources>
212+
<add key=""dotnet-public"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json"" />
213+
<add key=""dotnet-eng"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json"" />
214+
<add key=""dotnet-tools"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json"" />
215+
</packageSources>
216+
</configuration>";
217+
var configPath = Path.Combine(_testOutputDirectory, "nuget.config");
218+
await Task.Run(() => File.WriteAllText(configPath, originalConfig));
219+
220+
// Act
221+
var result = await _scriptRunner.RunScript(configPath);
222+
223+
// Assert
224+
result.exitCode.Should().Be(0, "Script should succeed, but got error: {0}", result.error);
225+
var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath));
226+
227+
modifiedConfig.ShouldContainPackageSource("dotnet-eng-internal",
228+
"https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-eng-internal/nuget/v3/index.json",
229+
"should add dotnet-eng-internal feed");
230+
231+
modifiedConfig.ShouldContainPackageSource("dotnet-tools-internal",
232+
"https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-tools-internal/nuget/v3/index.json",
233+
"should add dotnet-tools-internal feed");
234+
235+
// Should have 5 total sources (3 original + 2 added internal)
236+
modifiedConfig.GetPackageSourceCount().Should().Be(5, "should add both internal feeds");
237+
}
238+
239+
[Fact]
240+
public async Task ConfigWithoutDotNetEngOrTools_DoesNotAddInternalFeeds()
241+
{
242+
// Arrange
243+
var originalConfig = @"<?xml version=""1.0"" encoding=""utf-8""?>
244+
<configuration>
245+
<packageSources>
246+
<add key=""dotnet-public"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json"" />
247+
<add key=""dotnet9"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json"" />
248+
</packageSources>
249+
</configuration>";
250+
var configPath = Path.Combine(_testOutputDirectory, "nuget.config");
251+
await Task.Run(() => File.WriteAllText(configPath, originalConfig));
252+
253+
// Act
254+
var result = await _scriptRunner.RunScript(configPath);
255+
256+
// Assert
257+
result.exitCode.Should().Be(0, "Script should succeed, but got error: {0}", result.error);
258+
var modifiedConfig = await Task.Run(() => File.ReadAllText(configPath));
259+
260+
modifiedConfig.ShouldNotContainPackageSource("dotnet-eng-internal",
261+
"should not add dotnet-eng-internal when dotnet-eng is not present");
262+
modifiedConfig.ShouldNotContainPackageSource("dotnet-tools-internal",
263+
"should not add dotnet-tools-internal when dotnet-tools is not present");
264+
265+
// Should add dotnet9 internal feeds
266+
modifiedConfig.ShouldContainPackageSource("dotnet9-internal");
267+
modifiedConfig.ShouldContainPackageSource("dotnet9-internal-transport");
268+
}
146269
}
147270
}
148271

0 commit comments

Comments
 (0)