-
Notifications
You must be signed in to change notification settings - Fork 379
Update SetupNugetSource.ps1/sh with new functionality and model #16178
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
Conversation
A number of repos have started to use package source mapping. When we add dotnet* internal feeds, the package source mappings don't apply. For static feeds like that (as opposed to darc-*), it would sometimes be better if the repo just kept them in the NuGet.config at all times. This is clearer for the dev as well as easier to manage w.r.t. package source mappings. So this, PR introduces a new method of dealing with internal sources in the NuGet.config. If the source already exists in the config, and is one of the known feed (dotnetN-internal and dotnetN-internal-transport), but is just disabled, enable it. In addition, the following other tweaks were made: - Rename private->internal - Remove 3.1 support - Improve logging a bit. I think that darc* support for package source mappings should be covered by Maestro.
src/Microsoft.DotNet.SetupNugetSources.Tests/Microsoft.DotNet.SetupNugetSources.Tests.csproj
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request updates the SetupNugetSources scripts with new functionality to better handle internal package feeds and package source mappings. The core change is that instead of always adding new internal feeds, the scripts will now enable existing disabled internal feeds when found, making them more compatible with package source mapping configurations.
Key changes:
- Introduced a new approach for handling disabled internal feeds by enabling them instead of adding duplicates
- Renamed terminology from "private" to "internal" for consistency
- Removed support for .NET 3.1 feeds
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| eng/common/SetupNugetSources.sh | Shell script updated with new feed enabling logic and internal terminology |
| eng/common/SetupNugetSources.ps1 | PowerShell script updated with corresponding functionality and improved error handling |
| src/Microsoft.DotNet.SetupNugetSources.Tests/*.cs | New comprehensive test suite covering various scenarios |
| Arcade.slnx | Added the new test project to the solution |
| { | ||
| var relative = Path.GetRelativePath(sourceDir, file); | ||
| var destPath = Path.Combine(destinationDir, relative); | ||
| Directory.CreateDirectory(Path.GetDirectoryName(destPath)!); |
Copilot
AI
Oct 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The null-forgiving operator (!) is used without null checking. Consider using Path.GetDirectoryName(destPath) ?? string.Empty or add a null check before the Directory.CreateDirectory call.
| Directory.CreateDirectory(Path.GetDirectoryName(destPath)!); | |
| Directory.CreateDirectory(Path.GetDirectoryName(destPath) ?? string.Empty); |
| PackageSourceCredentialsTemplate="${TB}<packageSourceCredentials>${NL}${TB}</packageSourceCredentials>" | ||
|
|
||
| sed -i.bak "s|$PackageSourcesNodeFooter|$PackageSourcesNodeFooter${NL}$PackageSourceCredentialsTemplate|" $ConfigFile | ||
| Write-PipelineTelemetryError -Category 'Build' "Error: Eng/common/SetupNugetSources.sh returned a non-zero exit code. NuGet config file must contain a packageSources section: $ConfigFile" |
Copilot
AI
Oct 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PowerShell function call is incorrect in a shell script. It should use the shell equivalent function or proper shell error handling syntax.
| Write-PipelineTelemetryError -Category 'Build' "Error: Eng/common/SetupNugetSources.sh returned a non-zero exit code. NuGet config file must contain a packageSources section: $ConfigFile" | |
| echo "Error: Eng/common/SetupNugetSources.sh returned a non-zero exit code. NuGet config file must contain a packageSources section: $ConfigFile" >&2 |
|
/backport to release/10.0 |
|
Started backporting to release/10.0: https://github.com/dotnet/arcade/actions/runs/18377864292 |
A number of repos have started to use package source mapping. When we add dotnet* internal feeds, the package source mappings don't apply. For static feeds like that (as opposed to darc-*), it would sometimes be better if the repo just kept them in the NuGet.config at all times. This is clearer for the dev as well as easier to manage w.r.t. package source mappings. So this, PR introduces a new method of dealing with internal sources in the NuGet.config. If the source already exists in the config, and is one of the known feed (dotnetN-internal and dotnetN-internal-transport), but is just disabled, enable it.
In addition, the following other tweaks were made:
I think that darc* support for package source mappings should be covered by Maestro.
To double check: