Update SetupNugetSource.ps1/sh with new functionality and model#16178
Update SetupNugetSource.ps1/sh with new functionality and model#16178mmitche merged 12 commits intodotnet:mainfrom
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.
There was a problem hiding this comment.
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)!); |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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: